/* ========================================================================
   Music Card Studio — UI Stylesheet
   Dark, editorial, professional. Spotify green as accent.
   ======================================================================== */

:root {
  /* Palette */
  --bg-0: #0a0a0b;
  --bg-1: #121214;
  --bg-2: #1a1a1d;
  --bg-3: #232328;
  --bg-4: #2d2d33;

  --line: #2a2a30;
  --line-soft: #1e1e22;

  --text-0: #ffffff;
  --text-1: #e8e8ec;
  --text-2: #a8a8b0;
  --text-3: #6e6e76;
  --text-4: #48484e;

  --accent: #1ED760;       /* Spotify green */
  --accent-soft: #1db95480;
  --accent-glow: #1ed76040;

  --danger: #ff5a5f;
  --warn: #ffb84d;

  /* Layout */
  --header-h: 64px;
  --panel-w: 360px;

  /* Type */
  --font-fa: 'Vazirmatn', system-ui, sans-serif;
  --font-display: 'Instrument Serif', 'DM Serif Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-fa);
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }

::selection { background: var(--accent); color: var(--bg-0); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 10px;
  border: 2px solid var(--bg-0);
}
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* ───────────────────────── TOPBAR ───────────────────────── */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  backdrop-filter: blur(20px);
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #128c3b);
  color: var(--bg-0);
  display: grid;
  place-items: center;
  box-shadow: 0 0 24px var(--accent-glow);
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 19px;
  color: var(--text-0);
  letter-spacing: 0.2px;
  line-height: 1;
}
.brand-text h1 em {
  font-style: italic;
  color: var(--accent);
}
.brand-text p {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
}

.topbar-actions { display: flex; gap: 10px; }

.btn-ghost, .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s var(--ease);
  border: 1px solid transparent;
}

.btn-ghost {
  color: var(--text-2);
  background: var(--bg-2);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--text-0); background: var(--bg-3); border-color: var(--bg-4); }

.btn-primary {
  background: var(--accent);
  color: var(--bg-0);
  font-weight: 600;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  background: #19c557;
  box-shadow: 0 0 24px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* ───────────────────────── WORKSPACE ───────────────────────── */
.workspace {
  position: absolute;
  inset: var(--header-h) 0 0 0;
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  overflow: hidden;
}

/* ───────────────────────── PANEL ───────────────────────── */
.panel {
  background: var(--bg-1);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-inner {
  padding: 22px 20px 60px;
}

.ctrl-section {
  margin-bottom: 32px;
}
.ctrl-section + .ctrl-section {
  padding-top: 28px;
  border-top: 1px solid var(--line-soft);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}
.step-no {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: .5px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  color: var(--text-0);
  letter-spacing: .2px;
}

.ctrl-hint {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 8px;
  line-height: 1.6;
}
.ctrl-hint.error { color: var(--danger); }
.ctrl-hint.success { color: var(--accent); }

/* Spotify input */
.spotify-input {
  display: flex;
  gap: 6px;
}
.spotify-input input {
  flex: 1;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-1);
  direction: ltr;
  text-align: left;
  outline: none;
  transition: border-color .15s;
}
.spotify-input input:focus { border-color: var(--accent); }
.spotify-input button {
  padding: 10px 14px;
  background: var(--accent);
  color: var(--bg-0);
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
  transition: all .15s;
}
.spotify-input button:hover { background: #19c557; }
.spotify-input button:disabled { opacity: .5; cursor: wait; }

.track-info {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.track-info img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}
.track-title {
  font-size: 13px;
  color: var(--text-0);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.track-artist {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Generic field */
.field {
  display: block;
  margin-bottom: 12px;
}
.field > span {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .8px;
}
.field input[type="text"],
.field textarea,
.field select {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
  transition: border-color .15s;
}
.field input[type="text"]:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; font-family: var(--font-fa); min-height: 56px; }
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a8a8b0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
}
.field input[type="color"] {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-0);
  cursor: pointer;
  padding: 2px;
}
.field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

.dual-time { display: flex; gap: 8px; align-items: center; }
.dual-time input { flex: 1; text-align: center; font-family: var(--font-mono); }
.dual-time span { color: var(--text-3); }

/* Switch */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
}
.switch input { appearance: none; width: 32px; height: 18px; background: var(--bg-3); border-radius: 10px; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: var(--text-1);
  border-radius: 50%;
  top: 2px; right: 2px;
  transition: transform .15s var(--ease);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(-14px); background: var(--bg-0); }
.switch span { font-size: 13px; color: var(--text-1); }

/* Segmented control */
.seg {
  display: flex;
  background: var(--bg-0);
  border-radius: 7px;
  padding: 3px;
  border: 1px solid var(--line);
}
.seg button {
  flex: 1;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-3);
  border-radius: 5px;
  transition: all .15s;
}
.seg button.active {
  background: var(--bg-3);
  color: var(--text-0);
}
.seg button:hover:not(.active) { color: var(--text-1); }

/* Layout grid */
.layout-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.layout-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: all .15s;
  text-align: center;
}
.layout-btn:hover { border-color: var(--bg-4); }
.layout-btn.active {
  border-color: var(--accent);
  background: var(--bg-2);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.layout-btn em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--font-display);
}
.layout-btn.active em { color: var(--accent); }

.layout-preview {
  height: 32px;
  border-radius: 4px;
  background: var(--bg-3);
  position: relative;
  overflow: hidden;
}
.layout-preview span {
  position: absolute;
  background: var(--text-3);
}
.lp-a span:nth-child(1) { inset: 4px auto 4px 4px; width: 24px; border-radius: 2px; }
.lp-a span:nth-child(2) { inset: 8px 32px 8px auto; width: 32px; height: 4px; border-radius: 1px; }
.lp-b { background: linear-gradient(135deg, var(--text-3), var(--text-4)); }
.lp-c span:nth-child(1) { inset: 0 0 50% 0; background: var(--text-3); }
.lp-c span:nth-child(2) { inset: 50% 0 0 0; background: var(--bg-3); }
.lp-d span { inset: 4px; border-radius: 50%; }
.lp-e span { inset: 4px 8px; border-radius: 2px; transform: rotate(-3deg); transform-origin: center; }
.lp-f span { inset: 50% 4px 4px 4px; height: 6px; }

/* Theme list */
.theme-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.theme-btn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: all .15s;
  position: relative;
  overflow: hidden;
  text-align: right;
}
.theme-btn:hover { border-color: var(--bg-4); }
.theme-btn.active {
  border-color: var(--accent);
  background: var(--bg-2);
}
.theme-swatch {
  height: 28px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--c1, #000) 0%, var(--c2, #333) 100%);
  position: relative;
  overflow: hidden;
}
.theme-btn em {
  font-style: normal;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-1);
  letter-spacing: .3px;
}
.theme-btn.active em { color: var(--accent); }
.theme-btn small {
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: .3px;
  text-transform: uppercase;
}

/* ───────────────────────── PREVIEW AREA ───────────────────────── */
.preview-area {
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(ellipse at top, rgba(30,215,96,.03) 0%, transparent 60%),
    var(--bg-0);
  position: relative;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}

.side-toggle {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}
.side-toggle button {
  padding: 7px 18px;
  font-size: 12px;
  color: var(--text-3);
  border-radius: 5px;
  transition: all .15s;
  font-weight: 500;
}
.side-toggle button.active {
  background: var(--bg-3);
  color: var(--text-0);
}

.preview-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: .5px;
}
.preview-meta .dot { color: var(--text-4); }

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}
.zoom-controls button {
  width: 28px; height: 28px;
  color: var(--text-2);
  border-radius: 5px;
  font-size: 16px;
}
.zoom-controls button:hover { background: var(--bg-3); color: var(--text-0); }
.zoom-controls span {
  min-width: 50px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

.preview-stage {
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 60px;
  position: relative;
}

/* Decorative grid backdrop in preview */
.preview-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

.card-wrap {
  position: relative;
  transform: scale(var(--zoom, 1));
  transition: transform .25s var(--ease);
  filter: drop-shadow(0 30px 60px rgba(0,0,0,.4)) drop-shadow(0 0 0 1px rgba(255,255,255,.04));
}

/* The card itself — 10cm × 6.5cm at 96dpi: 378×246 px (scaled to preview) */
.card {
  width: 600px;
  height: 390px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  font-family: var(--font-display);
  color: #000;
}

.preview-footer {
  padding: 12px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 11px;
  font-style: italic;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}

/* ───────────────────────── MODAL ───────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none !important; }

.modal-back {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(8px);
  animation: fadeIn .2s var(--ease);
}

.modal-body {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  animation: modalIn .25s var(--ease-out);
}

@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  color: var(--text-0);
}
.modal-head button {
  width: 32px; height: 32px;
  font-size: 22px;
  color: var(--text-3);
  border-radius: 6px;
}
.modal-head button:hover { background: var(--bg-2); color: var(--text-0); }

.modal-content { padding: 22px; }
.modal-content > p { color: var(--text-2); margin-bottom: 16px; }

.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.exp-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: right;
  transition: all .15s;
}
.exp-btn:hover {
  border-color: var(--accent);
  background: var(--bg-2);
  transform: translateY(-2px);
}
.exp-btn strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  color: var(--text-0);
}
.exp-btn em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-3);
}

.export-status {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  min-height: 16px;
}
.export-status.loading { background: var(--bg-0); color: var(--text-2); }
.export-status.success { background: rgba(30,215,96,.1); color: var(--accent); }
.export-status.error { background: rgba(255,90,95,.1); color: var(--danger); }

/* ───────────────────────── TOAST ───────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  color: var(--text-0);
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid var(--bg-4);
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  z-index: 300;
  animation: toastIn .3s var(--ease-out);
}
.toast[hidden] { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
}

/* ───────────────────────── RESPONSIVE ───────────────────────── */
@media (max-width: 900px) {
  :root { --panel-w: 100%; }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .panel {
    max-height: 50vh;
    border-left: none;
    border-bottom: 1px solid var(--line);
  }
  .preview-stage { padding: 30px 20px; }
  .card { width: 360px; height: 234px; }
  .brand-text p { display: none; }
  .preview-meta { display: none; }
}
