/* =========================================================================
   ENV Manager — "infrastructure console"
   Thème sombre, typographie technique, accent chartreuse.
   ========================================================================= */

:root {
  --bg: #0b0e13;
  --bg-2: #0f131b;
  --panel: #131822;
  --panel-2: #171d29;
  --panel-hover: #1b2230;
  --line: #232c3b;
  --line-soft: #1a212d;

  --text: #e7ecf3;
  --text-dim: #9aa7b8;
  --text-faint: #61708500;
  --muted: #6b7888;

  --accent: #c6f24e;          /* chartreuse signal */
  --accent-dim: #9fc63a;
  --accent-ink: #0c1006;      /* texte sur fond accent */
  --accent-glow: rgba(198, 242, 78, 0.16);

  --danger: #ff6b6b;
  --danger-dim: #c64848;
  --danger-glow: rgba(255, 107, 107, 0.14);

  --amber: #f4b942;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Hanken Grotesk", system-ui, sans-serif;
  --display: "Bricolage Grotesque", var(--sans);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(198, 242, 78, 0.05), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(80, 120, 255, 0.05), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

/* ---------------------------- Boutons ----------------------------------- */
.btn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 6px 18px -8px var(--accent-glow);
}
.btn-primary:hover { background: #d4ff63; box-shadow: 0 8px 24px -8px var(--accent-glow); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}
.btn-ghost:hover { background: var(--panel-hover); color: var(--text); border-color: #2c3849; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-dim);
}
.btn-danger:hover { background: var(--danger-glow); }

.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.13s ease, color 0.13s ease, border-color 0.13s ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--panel-hover); color: var(--text); border-color: var(--line); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger-dim); background: var(--danger-glow); }

/* ---------------------------- Champs ------------------------------------ */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
input, textarea {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}
input:focus, textarea:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; line-height: 1.5; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: -0.01em; }

/* ============================ CONNEXION ================================== */
.login-view {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  overflow: hidden;
}
.login-grid {
  position: absolute; inset: -2px;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 42%, black, transparent 72%);
  opacity: 0.6;
}
.login-card {
  position: relative;
  width: min(92vw, 408px);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 32px 26px;
  box-shadow: var(--shadow);
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.brand-mark {
  width: 46px; height: 46px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 10px 26px -10px var(--accent-glow);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark.sm { width: 30px; height: 30px; border-radius: 8px; }
.brand-mark.sm svg { width: 16px; height: 16px; }
.brand h1 { font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -0.02em; }
.brand p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-glow);
  border: 1px solid var(--danger-dim);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.login-foot {
  text-align: center;
  margin-top: 18px;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ============================ APP : TOPBAR ============================== */
.app-view { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 19, 27, 0.86);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-title { font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line); flex: none; }
.scan-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  height: 38px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search:focus-within { border-color: var(--accent-dim); box-shadow: 0 0 0 3px var(--accent-glow); }
.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.search input { border: none; background: none; padding: 0; width: 220px; box-shadow: none; }
.search input:focus { box-shadow: none; }

/* ============================ APP : LAYOUT ============================== */
.layout { display: grid; grid-template-columns: 288px 1fr; flex: 1; min-height: 0; }

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.pill {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 1px 9px;
}
.project-list { overflow-y: auto; padding: 4px 10px 18px; display: flex; flex-direction: column; gap: 3px; }

.project-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
  text-align: left;
  width: 100%;
  background: none;
  color: inherit;
  font-family: inherit;
}
.project-item:hover { background: var(--panel); }
.project-item.active { background: var(--panel-2); border-color: var(--line); }
.project-item.active .project-name { color: var(--text); }
.project-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 9px var(--accent-glow); }
.project-dot.empty { background: var(--line); box-shadow: none; }
.project-meta { min-width: 0; flex: 1; }
.project-name { font-size: 13.5px; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-sub { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.project-count-badge {
  font-family: var(--mono); font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 7px; flex: none;
}

/* ============================ CONTENU =================================== */
.content { overflow-y: auto; padding: 26px 30px 60px; min-height: 0; }

.empty-state {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; color: var(--muted);
}
.empty-glyph {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 16px;
  border: 1px dashed var(--line);
  color: var(--line);
}
.empty-glyph svg { width: 30px; height: 30px; }
.empty-state p { font-size: 14px; }

.project-header { margin-bottom: 22px; }
.project-header h2 { font-family: var(--display); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.project-header .crumbs { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 6px; }

.envfile { margin-bottom: 26px; }
.envfile-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.envfile-path { display: flex; align-items: center; gap: 10px; min-width: 0; }
.envfile-path svg { width: 15px; height: 15px; color: var(--accent-dim); flex: none; }
.envfile-path code { font-family: var(--mono); font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.envfile-count { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.table {
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  background: var(--panel);
}
.row {
  display: grid;
  grid-template-columns: minmax(160px, 0.9fr) minmax(0, 1.6fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  transition: background 0.1s ease;
}
.row:first-child { border-top: none; }
.row:hover { background: var(--panel-2); }
.row:hover .row-actions { opacity: 1; }

.k { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--accent); word-break: break-all; }
.v-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.v {
  font-family: var(--mono); font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 6px 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v.revealed { color: var(--text); white-space: pre-wrap; word-break: break-all; }
.v.empty-val { color: var(--muted); font-style: italic; }

.row-actions { display: flex; align-items: center; gap: 4px; opacity: 0.35; transition: opacity 0.13s ease; }

.add-row {
  display: flex; justify-content: flex-end;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
}

.file-error {
  padding: 10px 14px;
  font-family: var(--mono); font-size: 12px;
  color: var(--danger);
  border: 1px solid var(--danger-dim);
  border-top: none;
  background: var(--danger-glow);
}
.no-vars { padding: 16px 14px; color: var(--muted); font-size: 13px; }
.no-files {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ============================ MODALES =================================== */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 7, 10, 0.66); backdrop-filter: blur(3px); }
.modal-card {
  position: relative;
  width: min(92vw, 480px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: rise 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; gap: 16px;
}
.modal-card h3 { font-family: var(--display); font-size: 18px; font-weight: 700; }
.danger-title { color: var(--danger); }
.modal-sub { font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.modal-sub code { font-family: var(--mono); color: var(--text); background: var(--bg-2); border: 1px solid var(--line-soft); padding: 1px 6px; border-radius: 5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ============================ TOASTS =================================== */
.toast-stack { position: fixed; bottom: 22px; right: 22px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  min-width: 240px; max-width: 360px;
  animation: toastIn 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.error { border-left-color: var(--danger); }
.toast.error svg { color: var(--danger); }
.toast svg { width: 17px; height: 17px; color: var(--accent); flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ---------------------------- Scrollbars -------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1f2734; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2a3543; }

/* ---------------------------- Responsive -------------------------------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.mobile-open { display: flex; position: fixed; inset: 60px 0 0 0; z-index: 30; }
  .search input { width: 130px; }
  .row { grid-template-columns: 1fr; gap: 8px; }
  .row-actions { opacity: 1; }
  .content { padding: 18px; }
}
