/* ── Variables ───────────────────────────────────────────────────────────── */

:root {
  --primary:    #5b50e8;
  --primary-dk: #1e1b4b;
  --radius:     10px;

  /* Light mode tokens */
  --bg-page:      #f4f5f9;
  --bg-surface:   #ffffff;
  --bg-header:    #fafafa;
  --border:       #e5e7eb;
  --text:         #1a1a2e;
  --text-muted:   #6b7280;
  --shadow-sm:    0 1px 4px rgba(0,0,0,.06);
  --shadow-md:    0 4px 14px rgba(0,0,0,.10);
}

[data-bs-theme="dark"] {
  --bg-page:      #0f172a;
  --bg-surface:   #1e293b;
  --bg-header:    #162032;
  --border:       #334155;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --shadow-sm:    0 1px 4px rgba(0,0,0,.3);
  --shadow-md:    0 4px 14px rgba(0,0,0,.4);
}

/* ── Base ────────────────────────────────────────────────────────────────── */

body {
  background: var(--bg-page);
  color: var(--text);
  transition: background .25s, color .25s;
}

/* ── Navbar ──────────────────────────────────────────────────────────────── */

.navbar {
  background: linear-gradient(135deg, var(--primary-dk) 0%, #3730a3 100%) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.navbar-brand {
  font-size: 1.15rem;
  letter-spacing: .5px;
}

/* Dark mode toggle button */
.theme-toggle-btn {
  background: transparent;
  color: rgba(255,255,255,.85);
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s, color .15s;
}
.theme-toggle-btn:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar-sticky {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  padding-right: 4px;
}

.sidebar-sticky::-webkit-scrollbar       { width: 4px; }
.sidebar-sticky::-webkit-scrollbar-track { background: transparent; }
.sidebar-sticky::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Category cards (sidebar) ────────────────────────────────────────────── */

.category-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--cat-color, var(--primary));
  border-radius: var(--radius);
  padding: 10px 13px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  user-select: none;
  outline: none;
}

.category-card:hover,
.category-card:focus {
  box-shadow: var(--shadow-md);
  transform: translateX(5px);
}

.category-card:active {
  transform: translateX(3px);
}

/* ── Plan blocks ─────────────────────────────────────────────────────────── */

.plan-block {
  animation: blockIn .22s ease both;
}

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

.plan-block .card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition: background .25s, border-color .25s;
}

.plan-block .card-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: .55rem 1rem;
  border-left: 5px solid transparent;
  transition: background .25s, border-color .25s;
}

.plan-block .card-body {
  padding: 1rem 1.1rem;
}

/* ── Drag handle ─────────────────────────────────────────────────────────── */

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  line-height: 1;
  font-size: 1.15rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .1s;
}

.drag-handle:hover  { color: var(--text); }
.drag-handle:active { cursor: grabbing; }

/* ── Exercise content ────────────────────────────────────────────────────── */

.exercise-thumb {
  border: 2px solid var(--border);
  border-radius: 6px;
  transition: transform .15s, border-color .15s;
  cursor: zoom-in;
}

.exercise-thumb:hover {
  transform: scale(1.04);
  border-color: var(--primary);
}

.exercise-description {
  white-space: pre-line;
  line-height: 1.6;
}

.block-loading {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── ABC notation ────────────────────────────────────────────────────────── */

.abc-notation svg,
#abc-preview svg {
  max-width: 100%;
  height: auto;
}

/* abcjs renders black-on-white SVG; recolor elements for dark mode */

/* Filled elements (noteheads, stems, beams, barlines, text):
   set fill to light, suppress stroke so no unwanted outline appears */
[data-bs-theme="dark"] .abc-notation svg path:not([fill="none"]),
[data-bs-theme="dark"] .abc-notation svg ellipse,
[data-bs-theme="dark"] .abc-notation svg polygon,
[data-bs-theme="dark"] .abc-notation svg text,
[data-bs-theme="dark"] .abc-notation svg rect:not([fill="white"]):not([fill="#ffffff"]):not([fill="#FFFFFF"]),
[data-bs-theme="dark"] #abc-preview svg path:not([fill="none"]),
[data-bs-theme="dark"] #abc-preview svg ellipse,
[data-bs-theme="dark"] #abc-preview svg polygon,
[data-bs-theme="dark"] #abc-preview svg text,
[data-bs-theme="dark"] #abc-preview svg rect:not([fill="white"]):not([fill="#ffffff"]):not([fill="#FFFFFF"]) {
  fill: #e2e8f0;
  stroke: none;
}

/* Stroke-only elements (slurs, ties): recolor stroke, keep fill:none */
[data-bs-theme="dark"] .abc-notation svg path[fill="none"],
[data-bs-theme="dark"] .abc-notation svg line,
[data-bs-theme="dark"] #abc-preview svg path[fill="none"],
[data-bs-theme="dark"] #abc-preview svg line {
  stroke: #e2e8f0;
  fill: none;
}

/* White background rects abcjs inserts — hide them */
[data-bs-theme="dark"] .abc-notation svg rect[fill="white"],
[data-bs-theme="dark"] .abc-notation svg rect[fill="#ffffff"],
[data-bs-theme="dark"] .abc-notation svg rect[fill="#FFFFFF"],
[data-bs-theme="dark"] #abc-preview svg rect[fill="white"],
[data-bs-theme="dark"] #abc-preview svg rect[fill="#ffffff"],
[data-bs-theme="dark"] #abc-preview svg rect[fill="#FFFFFF"] {
  fill: transparent;
}

#abc-preview {
  background: var(--bg-surface) !important;
  border-color: var(--border) !important;
  min-height: 130px;
  overflow-x: auto;
}

/* ── Transposition controls ──────────────────────────────────────────────── */

.transpose-controls { flex-shrink: 0; }

.transpose-btn {
  padding: .15rem .4rem;
  font-size: .8rem;
  line-height: 1.4;
}

.transpose-label {
  font-size: .8rem;
  font-weight: 600;
  min-width: 5.5rem;
  text-align: center;
  display: inline-block;
  transition: color .2s;
}

/* ── Admin ───────────────────────────────────────────────────────────────── */

.card-hover {
  transition: transform .15s ease, box-shadow .15s ease;
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.18) !important;
}

.cat-card { transition: box-shadow .15s; }
.cat-card:hover { box-shadow: var(--shadow-md) !important; }

.color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.font-mono { font-family: 'Courier New', Courier, monospace !important; }

.min-w-0 { min-width: 0; }
.ls-1    { letter-spacing: .05em; }

.border-dashed { border-style: dashed !important; }

/* ── Print ───────────────────────────────────────────────────────────────── */

@media print {
  .navbar,
  .sidebar-sticky,
  .drag-handle,
  .reroll-btn,
  .remove-btn,
  .theme-toggle-btn,
  #empty-state,
  [data-bs-dismiss],
  .btn {
    display: none !important;
  }

  .col-xl-3, .col-lg-4 {
    display: none !important;
    width: 0 !important;
  }

  .col-xl-9, .col-lg-8 {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  body { background: #fff !important; }

  .plan-block .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
    margin-bottom: .75rem;
  }

  .plan-block .card-header {
    background: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .transpose-controls { display: none !important; }
  .abc-player { display: none !important; }
  [id^="tempo-"] { display: none !important; }

  /* Restore black notes for printing */
  .abc-notation svg path:not([fill="none"]),
  .abc-notation svg text,
  .abc-notation svg ellipse,
  .abc-notation svg polygon,
  .abc-notation svg rect {
    fill: #000 !important;
    stroke: none !important;
  }
  .abc-notation svg path[fill="none"],
  .abc-notation svg line {
    stroke: #000 !important;
    fill: none !important;
  }

  .exercise-thumb { max-height: 120px !important; }

  h4, h5 { page-break-after: avoid; }
}
