/* ---------------------------------------------------------
   Thème "studio de nuit" — console audio dans la pénombre :
   charbon chaud (noyer sombre), lueurs ambre des VU-mètres,
   surfaces empilées comme des racks. Space Grotesk en display.
--------------------------------------------------------- */
:root {
  color-scheme: dark;

  --bg: #16110d;
  --surface: #201913;
  --surface-2: #2a2118;
  --line: #3a2e22;
  --line-soft: #2e251c;

  --text: #f2ebe0;
  --text-soft: #a3937f;
  --text-faint: #6f6353;

  --amber: #f0a03c;
  --amber-deep: #c97f1e;
  --amber-glow: rgba(240, 160, 60, 0.35);

  --green: #8fc79a;
  --green-bg: rgba(143, 199, 154, 0.12);
  --red: #e57e64;
  --red-bg: rgba(229, 126, 100, 0.12);

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", monospace;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 14px 34px -16px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 22px 48px -16px rgba(0, 0, 0, 0.75);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 45% at 50% -10%, rgba(240, 160, 60, 0.08), transparent),
    radial-gradient(ellipse 45% 35% at 90% 100%, rgba(240, 160, 60, 0.04), transparent);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

a {
  color: var(--amber);
}

button {
  font-family: var(--font-body);
}

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 4px;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------
   Connexion
--------------------------------------------------------- */
.login-screen {
  min-height: 88vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 384px;
  animation: rise-in 0.45s var(--ease);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card .brand {
  justify-content: center;
  margin-bottom: 26px;
}

.login-card h2 {
  text-align: center;
  margin-bottom: 4px;
}

.login-card .card-hint {
  text-align: center;
}

#login-form .btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

/* ---------------------------------------------------------
   Badge utilisateur (header)
--------------------------------------------------------- */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-soft);
}

.user-badge .btn {
  padding: 7px 15px;
  font-size: 0.78rem;
}

/* ---------------------------------------------------------
   Shell
--------------------------------------------------------- */
.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

.console-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 22px 0;
  margin-bottom: 30px;
  background: rgba(22, 17, 13, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.reel-mark {
  flex-shrink: 0;
  color: var(--amber);
  filter: drop-shadow(0 0 8px var(--amber-glow));
  transition: transform 0.45s var(--ease);
}

.brand:hover .reel-mark {
  transform: rotate(25deg);
}

.brand-text h1 {
  font-size: 1.5rem;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 4px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--amber);
  color: #1d1508;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fade-in 0.3s var(--ease);
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------------------------------------------------
   Cards
--------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 80px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 30px;
}

.card + .card {
  margin-top: 22px;
}

.card-title {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.card-hint {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin: 0 0 22px;
}

/* ---------------------------------------------------------
   Formulaire
--------------------------------------------------------- */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 7px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 4px rgba(240, 160, 60, 0.16);
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.char-count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
  text-align: right;
  margin-top: 5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background: linear-gradient(155deg, #ffb659, var(--amber) 60%);
  color: #241806;
  box-shadow: 0 0 0 1px rgba(240, 160, 60, 0.25), 0 8px 24px -8px var(--amber-glow);
}

.btn-primary:hover {
  box-shadow: 0 0 0 1px rgba(240, 160, 60, 0.4), 0 12px 32px -8px var(--amber-glow);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: var(--surface-2);
  color: var(--text-faint);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--amber);
  color: var(--amber);
  transform: translateY(-1px);
}

/* ---------------------------------------------------------
   VU-mètre — signature du thème, lueur ambre
--------------------------------------------------------- */
.vu-meter {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 18px;
}

.vu-meter span {
  width: 3px;
  background: linear-gradient(180deg, #ffc270, var(--amber));
  border-radius: 1px;
  height: 40%;
  box-shadow: 0 0 6px var(--amber-glow);
}

.vu-meter.animating span {
  animation: vu-bounce 0.9s ease-in-out infinite;
}

.vu-meter.animating span:nth-child(1) { animation-delay: 0s; }
.vu-meter.animating span:nth-child(2) { animation-delay: 0.1s; }
.vu-meter.animating span:nth-child(3) { animation-delay: 0.2s; }
.vu-meter.animating span:nth-child(4) { animation-delay: 0.3s; }
.vu-meter.animating span:nth-child(5) { animation-delay: 0.15s; }

@keyframes vu-bounce {
  0%, 100% { height: 25%; }
  50% { height: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .vu-meter.animating span {
    animation: none;
    height: 70%;
  }
  .tab-panel.active,
  .login-card {
    animation: none;
  }
}

/* ---------------------------------------------------------
   Résultat de génération
--------------------------------------------------------- */
.result {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
}

.result.hidden {
  display: none;
}

.result audio {
  width: 100%;
  margin: 10px 0 14px;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-soft);
  margin-bottom: 14px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text-soft);
}

.error-box {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
  margin-top: 16px;
}

/* ---------------------------------------------------------
   Badges
--------------------------------------------------------- */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-ready {
  background: var(--green-bg);
  color: var(--green);
  border-color: rgba(143, 199, 154, 0.3);
}

.badge-processing {
  background: rgba(240, 160, 60, 0.12);
  color: var(--amber);
  border-color: rgba(240, 160, 60, 0.3);
}

.badge-failed {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(229, 126, 100, 0.3);
}

.badge-provider {
  background: var(--surface-2);
  color: var(--text-soft);
  border-color: var(--line);
}

/* ---------------------------------------------------------
   Tableau de bord
--------------------------------------------------------- */
.dashboard-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.dashboard-toolbar .field {
  margin-bottom: 0;
  min-width: 220px;
  flex: 1;
}

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ticket {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.ticket:hover {
  border-color: var(--amber-deep);
  border-left-color: var(--amber);
  box-shadow: var(--shadow-hover);
}

.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.ticket-title {
  font-weight: 600;
  font-size: 1rem;
}

.ticket-client {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.ticket-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-text {
  font-size: 0.88rem;
  color: var(--text-soft);
  margin: 10px 0;
}

.ticket audio {
  width: 100%;
  margin-top: 6px;
}

.ticket-timestamp {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: 8px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
}

.empty-state .vu-meter {
  margin-bottom: 12px;
}

.add-client-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.add-client-form .field {
  margin-bottom: 0;
  flex: 1;
  min-width: 160px;
}

.music-picker {
  display: flex;
  gap: 8px;
}

.music-picker select {
  flex: 1;
}

.btn-preview {
  white-space: nowrap;
  flex-shrink: 0;
}

.hidden-audio {
  display: none;
}

.upload-music-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.upload-music-form .field {
  margin-bottom: 0;
  flex: 1;
  min-width: 160px;
}

input[type="file"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-soft);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  background: var(--bg);
  transition: border-color 0.2s var(--ease);
}

input[type="file"]:hover {
  border-color: var(--amber);
}

.music-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.music-item:hover {
  box-shadow: var(--shadow-hover);
}

.music-item-info {
  flex: 1;
  min-width: 200px;
}

.music-item-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.music-item-meta {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-faint);
  margin-top: 3px;
}

.music-item-meta a {
  color: var(--green);
}

.music-item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.music-item-actions audio {
  height: 32px;
  max-width: 220px;
}

.btn-danger {
  background: transparent;
  border: 1.5px solid rgba(229, 126, 100, 0.5);
  color: var(--red);
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
  transform: translateY(-1px);
}

.period-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 18px;
}

.period-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.period-btn:hover {
  color: var(--text);
}

.period-btn.active {
  background: var(--amber);
  color: #1d1508;
}

/* ---------------------------------------------------------
   Tableau de données (journal des connexions)
--------------------------------------------------------- */
.table-scroll {
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-soft);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(240, 160, 60, 0.04);
}

.data-table .mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
}

.demo-banner {
  background: rgba(240, 160, 60, 0.1);
  border: 1px solid rgba(240, 160, 60, 0.35);
  color: var(--amber);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  margin-bottom: 20px;
}

/* ---------------------------------------------------------
   Notifications (remplacent alert())
--------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.86rem;
  box-shadow: var(--shadow-hover);
  animation: toast-in 0.25s var(--ease);
}

.toast.toast-success { border-left-color: var(--green); }
.toast.toast-error { border-left-color: var(--red); }

.toast.toast-out {
  animation: toast-out 0.2s var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ---------------------------------------------------------
   Modale de confirmation (remplace confirm())
--------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 360px;
  width: 90%;
  box-shadow: var(--shadow-hover);
}

.modal-box p {
  margin: 0 0 18px;
  font-size: 0.92rem;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------------------------------------------------------
   Message actif
--------------------------------------------------------- */
.badge-active {
  background: rgba(240, 160, 60, 0.16);
  color: var(--amber);
  border-color: rgba(240, 160, 60, 0.35);
}

.btn-set-active {
  padding: 4px 10px;
  font-size: 0.7rem;
}

/* ---------------------------------------------------------
   Responsive
--------------------------------------------------------- */
@media (max-width: 640px) {
  .field-row {
    grid-template-columns: 1fr;
  }

  .console-header {
    padding-top: 18px;
  }

  .card {
    padding: 22px;
  }
}
