/* ==========================================================================
   MusiqaApp — Light Design System
   Palette: warm porcelain background, indigo accent, amber highlight
   Type: Space Grotesk (display) + Inter (body)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root{
  --bg:            #F6F5F1;
  --surface:       #FFFFFF;
  --surface-2:     #EFEDE6;
  --ink:           #211F2B;
  --ink-soft:      #6B6878;
  --line:          #E4E1D8;
  --indigo:        #4A3AE3;
  --indigo-dark:   #372CB0;
  --amber:         #F2A93B;
  --amber-soft:    #FDECC8;
  --red:           #E4573D;
  --green:         #2E9E6C;
  --radius-sm:     10px;
  --radius-md:     16px;
  --radius-lg:     24px;
  --shadow-card:   0 1px 2px rgba(33,31,43,.04), 0 8px 24px rgba(33,31,43,.06);
  --shadow-pop:    0 12px 32px rgba(74,58,227,.22);
  --player-h:      82px;
  --nav-w:         232px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:'Inter',system-ui,-apple-system,sans-serif;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4,.brand,.display{
  font-family:'Space Grotesk',sans-serif;
  letter-spacing:-0.01em;
  margin:0;
}
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; cursor:pointer; }
img{ max-width:100%; display:block; }
::selection{ background:var(--amber-soft); color:var(--indigo-dark); }

/* Scrollbar */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background:#D9D5C8; border-radius:8px; }
::-webkit-scrollbar-track{ background:transparent; }

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

/* Sidebar */
.sidebar{
  width:var(--nav-w);
  flex-shrink:0;
  background:var(--surface);
  border-right:1px solid var(--line);
  padding:28px 20px;
  display:flex;
  flex-direction:column;
  gap:28px;
  position:sticky;
  top:0;
  height:100vh;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:20px;
  font-weight:700;
  color:var(--ink);
}
.brand .dot{
  width:11px;height:11px;border-radius:50%;
  background:linear-gradient(135deg,var(--indigo),var(--amber));
  flex-shrink:0;
}
.nav-group{ display:flex; flex-direction:column; gap:4px; }
.nav-label{
  font-size:11px;
  text-transform:uppercase;
  color:var(--ink-soft);
  letter-spacing:.08em;
  margin:14px 10px 6px;
}
.nav-link{
  display:flex; align-items:center; gap:12px;
  padding:10px 12px;
  border-radius:var(--radius-sm);
  font-size:14.5px;
  font-weight:500;
  color:var(--ink-soft);
  transition:background .15s ease, color .15s ease;
}
.nav-link svg{ width:19px; height:19px; flex-shrink:0; }
.nav-link:hover{ background:var(--surface-2); color:var(--ink); }
.nav-link.active{ background:var(--amber-soft); color:var(--indigo-dark); font-weight:600; }

.nav-group-admin{ padding-top:8px; border-top:1px dashed var(--line); }
.nav-label-admin{ display:flex; align-items:center; gap:6px; }
.nav-label-dot{ width:6px; height:6px; border-radius:50%; background:linear-gradient(135deg,var(--indigo),var(--amber)); flex-shrink:0; }
.nav-group-admin .nav-link.active{
  background:linear-gradient(120deg,var(--indigo),#6C5CE9);
  color:#fff;
  box-shadow:0 6px 16px rgba(74,58,227,.28);
}
.sidebar-footer{ margin-top:auto; display:flex; flex-direction:column; gap:10px; }

.user-chip{
  display:flex; align-items:center; gap:10px;
  padding:8px;
  border-radius:var(--radius-sm);
  border:1px solid var(--line);
}
.avatar{
  width:36px;height:36px;border-radius:50%;
  background:var(--surface-2);
  object-fit:cover;
  display:flex;align-items:center;justify-content:center;
  font-weight:600; color:var(--indigo);
  font-family:'Space Grotesk',sans-serif;
  flex-shrink:0;
}
.user-chip .who{ min-width:0; }
.user-chip .name{ font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-chip .role{ font-size:11.5px; color:var(--ink-soft); }

/* Main column */
.main{
  flex:1;
  min-width:0;
  padding-bottom:calc(var(--player-h) + 32px);
}
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  gap:16px;
  padding:22px 32px 10px;
}
.topbar h1{ font-size:26px; font-weight:700; }
.topbar .sub{ color:var(--ink-soft); font-size:14px; margin-top:4px; }
.search-box{
  display:flex; align-items:center; gap:8px;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:999px;
  padding:9px 16px;
  min-width:260px;
}
.search-box input{
  border:none; outline:none; background:transparent;
  font-size:14px; width:100%; color:var(--ink); font-family:inherit;
}
.search-box svg{ width:16px; height:16px; color:var(--ink-soft); flex-shrink:0; }

.content{ padding:8px 32px 24px; }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:11px 20px;
  border-radius:999px;
  border:1px solid transparent;
  font-size:14px; font-weight:600;
  transition:transform .12s ease, box-shadow .12s ease, background .15s ease;
}
.btn:active{ transform:scale(.97); }
.btn-primary{ background:var(--indigo); color:#fff; box-shadow:var(--shadow-pop); }
.btn-primary:hover{ background:var(--indigo-dark); }
.btn-outline{ background:var(--surface); border-color:var(--line); color:var(--ink); }
.btn-outline:hover{ border-color:var(--indigo); color:var(--indigo); }
.btn-ghost{ background:transparent; color:var(--ink-soft); }
.btn-ghost:hover{ color:var(--ink); background:var(--surface-2); }
.btn-danger{ background:#FCEAE6; color:var(--red); }
.btn-danger:hover{ background:#F8D8D1; }
.btn-sm{ padding:7px 14px; font-size:13px; }
.btn-block{ width:100%; }
.btn-icon{
  width:38px;height:38px;border-radius:50%;
  display:inline-flex;align-items:center;justify-content:center;
  background:var(--surface-2); color:var(--ink);
}
.btn-icon:hover{ background:var(--line); }
.btn-icon svg{ width:17px;height:17px; }

/* ---------- Cards ---------- */
.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow-card);
}
.card-pad{ padding:22px; }

.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(178px,1fr));
  gap:20px;
}
.song-card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius-md);
  padding:14px;
  transition:box-shadow .18s ease, transform .18s ease, border-color .18s ease;
  position:relative;
}
.song-card:hover{ box-shadow:var(--shadow-card); transform:translateY(-3px); border-color:#D9D4F5; }
.song-cover{
  position:relative;
  width:100%; aspect-ratio:1/1;
  border-radius:var(--radius-sm);
  overflow:hidden;
  background:linear-gradient(135deg,var(--surface-2),var(--amber-soft));
  margin-bottom:12px;
  display:flex;align-items:center;justify-content:center;
}
.song-cover img{ width:100%; height:100%; object-fit:cover; }
.song-cover .fallback-note{ width:34%; height:34%; color:#C9C4B0; }
.play-overlay{
  position:absolute; inset:0;
  background:rgba(33,31,43,.28);
  display:flex; align-items:center; justify-content:center;
  opacity:0; transition:opacity .18s ease;
}
.song-card:hover .play-overlay{ opacity:1; }
.play-overlay button{
  width:46px;height:46px;border-radius:50%;
  background:var(--amber); color:var(--ink);
  display:flex;align-items:center;justify-content:center;
  border:none; box-shadow:0 6px 18px rgba(0,0,0,.25);
}
.play-overlay button svg{ width:19px;height:19px; margin-left:2px; }
.song-title{ font-size:14.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.song-artist{ font-size:13px; color:var(--ink-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.song-meta-row{ display:flex; align-items:center; justify-content:space-between; margin-top:10px; }
.genre-tag{
  font-size:10.5px; font-weight:600; text-transform:uppercase; letter-spacing:.04em;
  background:var(--surface-2); color:var(--ink-soft);
  padding:3px 9px; border-radius:999px;
}
.like-btn{ color:var(--ink-soft); background:none; border:none; padding:2px; display:flex; }
.like-btn svg{ width:17px;height:17px; }
.like-btn.liked{ color:var(--red); }

/* List row (used in admin & playlists) */
.song-row{
  display:flex; align-items:center; gap:14px;
  padding:10px 12px;
  border-radius:var(--radius-sm);
  transition:background .15s ease;
}
.song-row:hover{ background:var(--surface-2); }
.song-row .idx{ width:22px; text-align:center; color:var(--ink-soft); font-size:13px; flex-shrink:0; }
.song-row .thumb{ width:44px;height:44px;border-radius:8px; background:var(--surface-2); flex-shrink:0; overflow:hidden; }
.song-row .thumb img{ width:100%; height:100%; object-fit:cover; }
.song-row .info{ flex:1; min-width:0; }
.song-row .info .t{ font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.song-row .info .a{ font-size:12.5px; color:var(--ink-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.song-row .dur{ font-size:12.5px; color:var(--ink-soft); flex-shrink:0; }
.song-row.playing .t{ color:var(--indigo); }

/* ---------- Hero ---------- */
.hero{
  border-radius:var(--radius-lg);
  background:linear-gradient(120deg,#2B2154 0%, #4A3AE3 55%, #6C5CE9 100%);
  color:#fff;
  padding:36px 36px;
  display:flex; align-items:center; justify-content:space-between; gap:24px;
  overflow:hidden;
  position:relative;
  margin-bottom:28px;
}
.hero::after{
  content:'';
  position:absolute; right:-40px; top:-60px;
  width:260px; height:260px; border-radius:50%;
  background:radial-gradient(circle, rgba(242,169,59,.35), transparent 70%);
}
.hero h2{ font-size:28px; font-weight:700; max-width:420px; line-height:1.2; }
.hero p{ color:rgba(255,255,255,.78); margin-top:8px; font-size:14.5px; max-width:420px; }
.hero .waves{ display:flex; align-items:flex-end; gap:4px; height:60px; opacity:.85; }
.hero .waves span{ width:5px; border-radius:3px; background:var(--amber); animation:wave 1.2s ease-in-out infinite; }

@keyframes wave{
  0%,100%{ height:14px; }
  50%{ height:52px; }
}

/* ---------- Section headers ---------- */
.section-head{ display:flex; align-items:center; justify-content:space-between; margin:26px 0 14px; }
.section-head h3{ font-size:18px; font-weight:700; }
.section-head a{ font-size:13px; color:var(--indigo); font-weight:600; }

/* ---------- Auth pages ---------- */
.auth-wrap{
  min-height:100vh;
  display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(circle at 15% 20%, rgba(74,58,227,.12), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(242,169,59,.16), transparent 45%),
    var(--bg);
  padding:24px;
}
.auth-card{
  width:100%; max-width:400px;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius-lg);
  padding:38px 34px;
  box-shadow:var(--shadow-card);
}
.auth-card .brand{ justify-content:center; margin-bottom:6px; font-size:22px; }
.auth-card h1{ font-size:22px; text-align:center; margin-bottom:6px; }
.auth-card .sub{ text-align:center; color:var(--ink-soft); font-size:13.5px; margin-bottom:26px; }
.field{ margin-bottom:16px; }
.field label{ display:block; font-size:13px; font-weight:600; margin-bottom:6px; }
.field input, .field select, .field textarea{
  width:100%;
  padding:11px 14px;
  border:1px solid var(--line);
  border-radius:var(--radius-sm);
  background:var(--bg);
  font-size:14px;
  font-family:inherit;
  color:var(--ink);
  outline:none;
  transition:border-color .15s ease, background .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus{
  border-color:var(--indigo); background:var(--surface);
}
.auth-foot{ text-align:center; font-size:13.5px; color:var(--ink-soft); margin-top:18px; }
.auth-foot a{ color:var(--indigo); font-weight:600; }

.alert{
  padding:11px 14px; border-radius:var(--radius-sm);
  font-size:13.5px; margin-bottom:16px;
  display:flex; align-items:center; gap:8px;
}
.alert-error{ background:#FCEAE6; color:#B23B26; }
.alert-success{ background:#E4F5EC; color:#1E7B52; }

/* ---------- Player bar ---------- */
.player-bar{
  position:fixed; left:0; right:0; bottom:0;
  height:var(--player-h);
  background:var(--surface);
  border-top:1px solid var(--line);
  display:flex; align-items:center;
  padding:0 20px;
  gap:20px;
  z-index:50;
  box-shadow:0 -6px 24px rgba(33,31,43,.05);
}
.player-track{ display:flex; align-items:center; gap:12px; width:260px; min-width:0; }
.player-track .thumb{ width:52px;height:52px;border-radius:10px; background:var(--surface-2); overflow:hidden; flex-shrink:0; }
.player-track .thumb img{ width:100%;height:100%;object-fit:cover; }
.player-track .t{ font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.player-track .a{ font-size:12px; color:var(--ink-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.player-center{ flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; max-width:640px; margin:0 auto; }
.player-controls{ display:flex; align-items:center; gap:16px; }
.ctrl-btn{ background:none; border:none; color:var(--ink-soft); display:flex; }
.ctrl-btn:hover{ color:var(--ink); }
.ctrl-btn svg{ width:19px;height:19px; }
.play-main{
  width:38px;height:38px;border-radius:50%;
  background:var(--ink); color:#fff;
  display:flex;align-items:center;justify-content:center;
}
.play-main:hover{ background:var(--indigo); }
.play-main svg{ width:16px;height:16px; }

.seek-row{ display:flex; align-items:center; gap:10px; width:100%; }
.seek-row .time{ font-size:11px; color:var(--ink-soft); width:34px; flex-shrink:0; }
.seek-row .time.end{ text-align:right; }
.range{
  -webkit-appearance:none; appearance:none;
  height:4px; border-radius:2px; background:var(--surface-2);
  flex:1; cursor:pointer; outline:none;
}
.range::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none;
  width:12px;height:12px;border-radius:50%;
  background:var(--indigo); cursor:pointer;
  box-shadow:0 0 0 3px rgba(74,58,227,.15);
}
.player-right{ display:flex; align-items:center; gap:12px; width:200px; justify-content:flex-end; }
.volume-row{ display:flex; align-items:center; gap:8px; width:110px; }
.volume-row svg{ width:16px;height:16px; color:var(--ink-soft); flex-shrink:0; }

/* ---------- Tables (admin) ---------- */
.table-wrap{ overflow-x:auto; }
table.data-table{ width:100%; border-collapse:collapse; font-size:13.5px; }
table.data-table thead th{
  text-align:left; padding:12px;
  background:var(--surface-2);
  color:var(--ink-soft);
  font-weight:700; font-size:11.5px; text-transform:uppercase; letter-spacing:.06em;
  border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:1;
}
table.data-table thead tr:first-child th:first-child{ border-top-left-radius:var(--radius-md); }
table.data-table thead tr:first-child th:last-child{ border-top-right-radius:var(--radius-md); }
table.data-table td{ padding:11px 12px; border-bottom:1px solid var(--line); vertical-align:middle; }
table.data-table tbody tr{ transition:background .15s ease; }
table.data-table tbody tr:hover{ background:var(--surface-2); }
table.data-table tr:last-child td{ border-bottom:none; }
.mini-cover{ width:38px;height:38px;border-radius:9px; object-fit:cover; background:var(--surface-2); box-shadow:0 1px 3px rgba(33,31,43,.08); }
.badge{ font-size:11px; font-weight:700; padding:4px 10px; border-radius:999px; letter-spacing:.02em; }
.badge-admin{ background:linear-gradient(120deg,var(--amber-soft),#FCE0AC); color:#8A5B0B; }
.badge-user{ background:var(--surface-2); color:var(--ink-soft); }

/* Stat cards */
.stats-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:18px; margin-bottom:26px; }
.stat-card{
  padding:20px; border-radius:var(--radius-md); background:var(--surface); border:1px solid var(--line);
  position:relative; overflow:hidden;
  transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card::before{
  content:''; position:absolute; left:0; top:0; right:0; height:3px;
  background:linear-gradient(90deg,var(--indigo),var(--amber));
  opacity:0; transition:opacity .18s ease;
}
.stat-card:hover{ transform:translateY(-3px); box-shadow:var(--shadow-card); border-color:#E2DEF7; }
.stat-card:hover::before{ opacity:1; }
.stat-card .num{ font-family:'Space Grotesk',sans-serif; font-size:30px; font-weight:700; letter-spacing:-.01em; }
.stat-card .label{ font-size:13px; color:var(--ink-soft); margin-top:4px; }
.stat-card .icon{ width:40px;height:40px;border-radius:12px; display:flex;align-items:center;justify-content:center; margin-bottom:14px; }
.stat-card .icon svg{ width:19px;height:19px; }

/* ---------- Admin shell polish ---------- */
.admin-topbar{
  border-radius:var(--radius-lg);
  background:linear-gradient(120deg,#2B2154 0%, #4A3AE3 55%, #6C5CE9 100%);
  color:#fff;
  padding:26px 30px;
  margin:8px 32px 24px;
  display:flex; align-items:center; justify-content:space-between; gap:20px;
  position:relative; overflow:hidden;
}
.admin-topbar::after{
  content:''; position:absolute; right:-30px; top:-50px;
  width:220px; height:220px; border-radius:50%;
  background:radial-gradient(circle, rgba(242,169,59,.30), transparent 70%);
}
.admin-topbar h1{ font-size:24px; font-weight:700; position:relative; }
.admin-topbar .sub{ color:rgba(255,255,255,.75); margin-top:5px; font-size:13.5px; position:relative; }
.admin-topbar .btn-primary{ background:#fff; color:var(--indigo-dark); box-shadow:0 8px 22px rgba(0,0,0,.18); position:relative; }
.admin-topbar .btn-primary:hover{ background:var(--amber-soft); }

.badge-role{
  display:inline-flex; align-items:center; gap:6px;
  font-size:11px; font-weight:700; padding:4px 10px; border-radius:999px;
  background:rgba(255,255,255,.16); color:#fff; letter-spacing:.03em;
  margin-top:8px;
}
.badge-role .dot{ width:6px;height:6px;border-radius:50%; background:var(--amber); }

.song-card.now-playing{ border-color:var(--indigo); box-shadow:0 0 0 2px rgba(74,58,227,.12); }
.song-card.now-playing .song-title{ color:var(--indigo); }

/* Empty state */
.empty-state{ text-align:center; padding:60px 20px; color:var(--ink-soft); }
.empty-state svg{ width:52px;height:52px; margin-bottom:14px; color:#D9D5C8; }
.empty-state h4{ color:var(--ink); font-size:16px; margin-bottom:6px; }

/* Mobile bottom nav */
.mobile-nav{
  display:none;
  position:fixed; left:0; right:0; bottom:0;
  background:var(--surface);
  border-top:1px solid var(--line);
  z-index:60;
}
.mobile-nav ul{ list-style:none; margin:0; padding:6px 8px; display:flex; justify-content:space-around; }
.mobile-nav a{ display:flex; flex-direction:column; align-items:center; gap:3px; padding:6px 10px; font-size:10.5px; color:var(--ink-soft); }
.mobile-nav a.active{ color:var(--indigo); }
.mobile-nav svg{ width:20px;height:20px; }

.hamburger{ display:none; }

/* ---------- Responsive ---------- */
@media (max-width: 980px){
  :root{ --nav-w:0px; }
  .sidebar{ display:none; }
  .topbar{ padding:18px 18px 6px; }
  .content{ padding:0 18px 20px; }
  .hero{ flex-direction:column; align-items:flex-start; padding:26px; }
  .hero .waves{ display:none; }
  .search-box{ min-width:0; flex:1; }
  .player-track{ width:auto; flex:1; }
  .player-right{ width:auto; }
  .volume-row{ display:none; }
  .mobile-nav{ display:block; }
  .main{ padding-bottom:calc(var(--player-h) + 58px + 20px); }
  .player-bar{ bottom:58px; }
}
@media (max-width: 560px){
  .grid{ grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:14px; }
  .stats-grid{ grid-template-columns:1fr 1fr; }
  .player-center{ display:none; }
  .player-bar{ height:70px; }
  .player-track .thumb{ width:44px;height:44px; }
}
