/* ══════════════════════════════════════════════════════════
   MidiCommander — Dark Theme
   ══════════════════════════════════════════════════════════ */

:root {
  --bg:          #0d0f1a;
  --surface:     #161929;
  --surface-2:   #1e2340;
  --border:      #2a2f52;
  --border-2:    #373d6a;
  --accent:      #4f6ef7;
  --accent-dim:  #3a52cc;
  --accent-glow: rgba(79, 110, 247, 0.25);
  --text:        #dde3f5;
  --text-muted:  #7b85ad;
  --danger:      #ef4444;
  --danger-dim:  #b91c1c;
  --success:     #10b981;
  --orange:      #f97316;
  --purple:      #a855f7;
  --radius:      6px;
  --radius-lg:   10px;
  --mono:        'Courier New', Courier, monospace;
}

/* Classe utilitaire — masque un élément (utilisée partout en JS) */
.hidden { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #7b96ff; }

/* ── Layout ──────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.back-link {
  color: var(--text-muted);
  font-size: 13px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

.song-header-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  min-width: 0;
}

#hdr-titre {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-text {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-main { padding: 20px 24px 40px; flex: 1; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  background: none;
  color: var(--text);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover  { background: var(--accent-dim); border-color: var(--accent-dim); }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost { border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Table ───────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table th {
  background: var(--surface);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(79, 110, 247, 0.05); }

/* Ligne mise en évidence par le simulateur */
.data-table tr.ev-triggered td {
  background: rgba(79, 110, 247, 0.18);
  transition: background 0.1s;
}

.num-cell     { text-align: right; font-size: 13px; }
.mono         { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.id-cell      { color: var(--text-muted); font-size: 12px; width: 44px; }
.date-cell    { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.label-cell   { color: var(--text-muted); font-style: italic; font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-cell a { font-weight: 500; color: var(--text); }
.title-cell a:hover { color: var(--accent); }

.actions-cell { white-space: nowrap; }
.actions-cell .btn + .btn { margin-left: 4px; }

.empty, .loading {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-family: var(--mono);
}

.badge-pc {
  background: rgba(249, 115, 22, 0.15);
  color: var(--orange);
  border: 1px solid rgba(249, 115, 22, 0.35);
}
.badge-cc {
  background: rgba(168, 85, 247, 0.15);
  color: var(--purple);
  border: 1px solid rgba(168, 85, 247, 0.35);
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}

.modal-box h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; min-width: 0; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 11px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select option { background: var(--surface); color: var(--text); }
textarea { resize: vertical; line-height: 1.5; }

.hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  font-style: italic;
}

.radio-group {
  display: flex;
  gap: 22px;
  margin-top: 2px;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 7px;
  text-transform: none;
  font-size: 13px;
  color: var(--text);
  font-weight: normal;
  letter-spacing: 0;
  cursor: pointer;
}
.radio-group input[type="radio"] {
  width: auto;
  cursor: pointer;
  accent-color: var(--accent);
}

.export-info {
  background: rgba(79, 110, 247, 0.08);
  border: 1px solid rgba(79, 110, 247, 0.25);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin: 14px 0;
  line-height: 1.65;
}

/* ── Simulateur ──────────────────────────────────────────── */
.sim-panel {
  background: var(--surface);
  border-top: 2px solid var(--accent);
  padding: 14px 24px 16px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  box-shadow: 0 -6px 30px rgba(0,0,0,0.5);
}
.sim-panel.hidden { display: none; }

.sim-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sim-label-text {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-right: 4px;
}

.sim-time {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  min-width: 90px;
  text-align: center;
}

.sim-bar-container {
  background: var(--bg);
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.sim-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #9333ea);
  transition: width 0.08s linear;
  border-radius: 4px;
}

.sim-log {
  max-height: 90px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--mono);
  font-size: 12px;
}

.sim-log::-webkit-scrollbar { width: 4px; }
.sim-log::-webkit-scrollbar-track { background: var(--bg); }
.sim-log::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.sim-entry {
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.sim-entry-pc { border-left: 3px solid var(--orange); }
.sim-entry-cc { border-left: 3px solid var(--purple); }

.sim-time-tag {
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 76px;
}

.sim-ev-label { color: var(--text-muted); font-style: italic; font-size: 11px; }

/* ── Page index — cards stats ────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 { font-size: 16px; font-weight: 600; color: var(--text-muted); }

/* ── Scrollbar globale ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header  { padding: 0 14px; }
  .toolbar     { padding: 10px 14px; flex-wrap: wrap; }
  .app-main    { padding: 16px 14px 220px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .modal-box   { padding: 20px; }
  .form-row    { flex-direction: column; gap: 0; }
  .meta-text   { display: none; }
}
