/* ==========================================================================
   Scaleboard — tokens
   Palette BrokenScale : aubergine quasi-noir, violet en accent primaire,
   sarcelle en accent secondaire (état "actif/sécurisé").
   ========================================================================== */
:root {
  --bg:          #15131F;
  --bg-raised:   #1C1929;
  --bg-card:     rgba(255, 255, 255, 0.035);
  --border:      #322D46;
  --border-soft: rgba(50, 45, 70, 0.55);

  --text:        #F1EEF9;
  --text-dim:    #9A93AE;
  --text-faint:  #6B6480;

  --violet:      #A78BFA;
  --violet-soft: #A78BFA33;
  --teal:        #52D9C4;
  --teal-soft:   #52D9C433;
  --danger:      #FF4D4D;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body:    'IBM Plex Sans', 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Consolas', monospace;

  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  height: 100%;
}

button, input {
  font-family: inherit;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   Login — mise en page split-screen
   ========================================================================== */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(167, 139, 250, 0.05), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(82, 217, 196, 0.05), transparent 40%),
    var(--bg);
}

.deck {
  width: 100%;
  max-width: 980px;
  min-height: 560px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.7);
}

.deck-face {
  position: relative;
  min-width: 0; /* item de grille : même garde-fou, au cas où */
  background:
    linear-gradient(160deg, #15191e 0%, #0d1013 100%);
  border-right: 1px solid var(--border);
  padding: 48px 44px;
  display: flex;
  align-items: center;
}

.deck-face::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.015) 0px,
    rgba(255, 255, 255, 0.015) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
}

.deck-face-inner {
  position: relative;
  width: 100%;
  min-width: 0; /* empêche le SVG 1200px de forcer la largeur du parent flex */
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.02em;
}

.brand-mark {
  color: var(--violet);
  font-size: 16px;
  filter: drop-shadow(0 0 8px var(--violet-soft));
}

.brand-word-accent { color: var(--teal); }

.brand-tagline {
  margin: 10px 0 36px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
  max-width: 30ch;
}

/* Onde d'oscilloscope défilante — signature visuelle de la page */
.scope {
  width: 100%;
  height: 60px;
  overflow: hidden;
  margin-bottom: 28px;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.scope-wave {
  width: 1200px;
  height: 60px;
  display: block;
  fill: none;
  animation: scope-scroll 2.6s linear infinite;
}

.scope-wave path {
  stroke: var(--teal);
  stroke-width: 2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px var(--teal-soft));
}

@keyframes scope-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-100px); }
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}

.status-sep { color: var(--text-faint); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
}

.dot-live {
  box-shadow: 0 0 0 0 var(--teal-soft);
  animation: dot-live-pulse 2s ease-out infinite;
}

@keyframes dot-live-pulse {
  0%   { box-shadow: 0 0 0 0 var(--teal-soft); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Formulaire */
.deck-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--bg-raised);
}

.login-card {
  width: 100%;
  max-width: 320px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 6px;
}

.login-sub {
  color: var(--text-dim);
  font-size: 13.5px;
  margin: 0 0 30px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}

.field-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 14.5px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.field-input:focus {
  outline: none;
  border-color: var(--violet);
  background: rgba(167, 139, 250, 0.04);
}

.field-input:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 1px;
}

.submit-btn {
  position: relative;
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: var(--violet);
  color: var(--bg);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  overflow: hidden;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.submit-btn:hover { filter: brightness(1.08); }
.submit-btn:active { transform: scale(0.995); }

.submit-btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.submit-btn-label { position: relative; z-index: 1; }

.submit-btn-tape {
  position: absolute;
  inset: 0;
  left: -100%;
  background: rgba(0, 0, 0, 0.18);
  transition: left 0.5s ease;
}

.submit-btn.is-loading .submit-btn-tape { left: 0; }
.submit-btn.is-loading { cursor: wait; pointer-events: none; }

.error-line {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13px;
}

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dash-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(167, 139, 250, 0.04), transparent 35%),
    radial-gradient(circle at 90% 100%, rgba(82, 217, 196, 0.04), transparent 35%),
    var(--bg);
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}

.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(to right, var(--violet), var(--teal), transparent 80%);
  opacity: 0.5;
}

.brand-sm { font-size: 17px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.logout-btn {
  margin-left: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 7px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.dash-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 36px 28px 60px;
  display: grid;
  gap: 22px;
}

.panel {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  overflow: hidden;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, var(--violet), var(--teal));
  opacity: 0.7;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 18px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-title-mark {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 6px var(--violet-soft);
  flex-shrink: 0;
}

/* Grille de tuiles — statut, IP, espace disque, outils cliquables */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 26px;
  overflow: hidden;
}

.tile-lg {
  min-height: 200px;
  justify-content: center;
}

.tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, var(--violet), var(--teal));
  opacity: 0.6;
}

.tile-label {
  font-size: 14px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tile-value {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
}

.tile-value.mono { font-family: var(--font-mono); font-size: 21px; }
.tile-value.ok { color: var(--teal); }

.tile-sub {
  font-size: 11.5px;
  color: var(--text-faint);
}

/* Tuiles-outils — cliquables, mènent à une popup */
.tile-tool {
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.tile-tool {
  border: 1px solid var(--border);
}

.tile-tool:hover {
  border-color: var(--violet);
  background: rgba(167, 139, 250, 0.06);
  transform: translateY(-2px);
}

.tile-tool:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

.tile-tool-icon {
  font-size: 40px;
  color: var(--violet);
}

.tile-tool-label {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Anneau (donut) d'espace disque */
.donut-wrap {
  position: relative;
  width: 108px;
  height: 108px;
  margin: 0 auto 8px;
}

.donut {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 9;
}

.donut-fill {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-pct {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
}

.donut-sub {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tile-disk .tile-label {
  text-align: center;
  font-size: 12.5px;
}

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-dim);
}

.dropzone-icon {
  font-size: 26px;
  color: var(--text-faint);
  margin-bottom: 10px;
  animation: dropzone-pulse 3s ease-in-out infinite;
}

@keyframes dropzone-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 0.9; transform: scale(1.08); }
}

.dropzone-text {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text);
}

.dropzone-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-faint);
}

.dropzone-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Sélecteur de destination */
.dest-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dest-label {
  font-size: 13px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.dest-path {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dest-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dest-btn:hover { border-color: var(--violet); }

.dest-btn-confirm {
  background: var(--violet);
  color: var(--bg);
  border: none;
  font-weight: 600;
}

.dest-btn-confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.dest-btn-confirm:hover:not(:disabled) { filter: brightness(1.08); }

/* Dropzone — état actif au survol drag */
.dropzone {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone-active {
  border-color: var(--teal);
  background: rgba(82, 217, 196, 0.04);
}

/* Liste d'upload */
.upload-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.upload-name {
  flex: 0 0 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}

.upload-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.upload-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--violet);
  transition: width 0.15s ease;
}

.upload-pct {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  min-width: 3.5em;
  text-align: right;
}

.upload-item-done .upload-bar-fill { background: var(--teal); }
.upload-item-done .upload-pct { color: var(--teal); }
.upload-item-error .upload-bar-fill { background: var(--danger); }
.upload-item-error .upload-pct { color: var(--danger); }

/* Modale du navigateur de dossiers */
.browse-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none; /* affiché seulement si l'attribut hidden est absent */
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.browse-overlay:not([hidden]) {
  display: flex;
}

.browse-modal {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}

.browse-modal-wide {
  max-width: 620px;
  max-height: 85vh;
}

.browse-modal-wide .pw-form {
  overflow-y: auto;
}

.browse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
}

.browse-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browse-close {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 15px;
  flex-shrink: 0;
}

.browse-close:hover { color: var(--danger); }

.browse-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}

.browse-item {
  padding: 9px 16px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.browse-item:hover { background: var(--bg-card); }
.browse-item-up { color: var(--text-faint); }

.browse-empty {
  padding: 16px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

.browse-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.pw-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.notes-textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--violet);
  background: rgba(167, 139, 250, 0.04);
}

.notes-footer-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.notes-status {
  font-size: 12.5px;
  color: var(--text-faint);
}


/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 760px) {
  .deck { grid-template-columns: 1fr; min-height: 0; }
  .deck-face {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 28px 24px 24px;
  }
  .brand-tagline { margin: 8px 0 20px; max-width: none; }
  .scope { margin-bottom: 14px; }
  .deck-form { padding: 32px 24px; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .topbar-right { gap: 8px; }
  .topbar-user { display: none; } /* trop serré sur petit écran, le nom reste visible dans "Session" plus bas */
  .dash-main { padding: 20px 14px 36px; gap: 16px; }
  .panel { padding: 18px; }

  .dest-row { flex-wrap: wrap; }
  .dest-path { order: 3; flex-basis: 100%; }
  .dest-btn { flex: 1; }

  .dropzone { padding: 28px 16px; }

  .upload-item { flex-wrap: wrap; }
  .upload-name { max-width: 100%; flex-basis: 100%; }

  .browse-modal { max-width: none; width: 100%; max-height: 80vh; }
}

@media (max-width: 420px) {
  .login-title { font-size: 22px; }
  .brand-word { font-size: 18px; }
  .tile-grid { grid-template-columns: 1fr; }
}
