/* =========================================================
   CS DASHBOARD CORE — ENGINE 4.2 NEON
   Production Grade Layout System
   ✔ Single .cs-dashboard selector (no duplicates)
   ✔ Scroll-safe (overflow-x hidden / overflow-y visible)
   ✔ No vh traps — min-height only
   ✔ Footer gap fixed
   ✔ Sidebar stretch fixed
   ✔ Mobile safe-area aware
   ✔ iOS momentum scroll enabled
   ✔ Syntax clean / no duplicates
========================================================= */

/* =========================================================
   ROOT TOKENS
========================================================= */
:root {
  --cs-bg:     #070707;
  --cs-panel:  rgba(18,18,18,.82);
  --cs-border: rgba(255,255,255,.08);

  --cs-text:  #ffffff;
  --cs-muted: #9b9b9b;

  --cs-gold:       #d4af37;
  --cs-gold-hover: #f1cc5b;
  --cs-purple:     #9d4dff;
  --cs-cyan:       #00e6d7;

  --cs-shadow: 0 20px 50px rgba(0,0,0,.45);
  --cs-radius: 18px;
  --cs-transition: all .3s ease;

  /* safe area */
  --cs-safe-t: env(safe-area-inset-top, 0px);
  --cs-safe-b: env(safe-area-inset-bottom, 0px);
}

/* =========================================================
   GLOBAL RESET
========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  /* do NOT set height/overflow here — let body flow */
}

body {
  margin: 0;
  padding: 0;
  background: var(--cs-bg);
  color: var(--cs-text);
  font-family: Inter, system-ui, -apple-system, sans-serif;

  /* horizontal clip is fine; NEVER hide overflow-y */
  overflow-x: hidden;
  overflow-y: visible;

  /* let iOS momentum scroll work */
  -webkit-overflow-scrolling: touch;

  /* do NOT set min-height:100vh or height:100vh here —
     body must grow with content so page scroll works */
}

/* =========================================================
   MEDIA / FORM / LINKS
========================================================= */
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }

/* =========================================================
   DASHBOARD SHELL — SINGLE SOURCE OF TRUTH
   ✔ overflow-x hidden (clip horizontal)
   ✔ overflow-y visible (page scrolls normally)
   ✔ min-height grows with content
   ✔ NO height:100vh (would trap scroll)
   ✔ NO overflow:hidden (would trap scroll)
========================================================= */
.cs-dashboard {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: #120A1F;
  color: #fff;
  margin: 0;
  padding: 0;
  padding-left: 0;

  /* THE FIX — vertical must be visible, horizontal clipped */
  overflow-x: hidden;
  overflow-y: visible;

  transition: padding-left .35s cubic-bezier(.4, 0, .2, 1);
}

body.sidebar-collapsed .cs-dashboard {
  padding-left: 0;
}

/* =========================================================
   SIDEBARS
========================================================= */
.cs-sidebar,
.cs-artist-sidebar,
.cs-client-sidebar,
.cs-studio-sidebar {
  width: 260px;
  background: #0b0b0b;
  border-right: 1px solid rgba(255,255,255,.06);
  padding: 30px;
  margin: 0;
  align-self: stretch;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.cs-sidebar nav,
.cs-artist-sidebar nav,
.cs-client-sidebar nav,
.cs-studio-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cs-sidebar nav a,
.cs-artist-sidebar nav a,
.cs-client-sidebar nav a,
.cs-studio-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  color: #bbbbbb;
  transition: var(--cs-transition);
}

.cs-sidebar nav a:hover,
.cs-artist-sidebar nav a:hover,
.cs-client-sidebar nav a:hover,
.cs-studio-sidebar nav a:hover {
  background: rgba(245,179,1,.12);
  color: var(--cs-gold);
  transform: translateX(6px);
  box-shadow: 0 20px 40px rgba(157,77,255,.25);
}

.cs-sidebar nav a.active,
.cs-artist-sidebar nav a.active,
.cs-client-sidebar nav a.active,
.cs-studio-sidebar nav a.active {
  background: rgba(245,179,1,.14);
  color: var(--cs-gold);
}

/* =========================================================
   ACTIVE INDICATOR
========================================================= */
.cs-sidebar-nav { position: relative; }

.cs-active-indicator {
  position: absolute;
  left: 0;
  width: 4px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(var(--cs-gold), #ff8c42);
  transition: top .3s ease;
}

/* =========================================================
   MAIN CONTENT
========================================================= */
.cs-dashboard-main,
.cs-artist-main,
.cs-client-main,
.cs-studio-main {
  flex: 1;
  min-width: 0;
  padding: 40px;
  margin: 0;
  position: relative;
}

/* =========================================================
   SECTION RHYTHM
========================================================= */
.cs-section { margin-bottom: 60px; }
.cs-section:last-child { margin-bottom: 0; }

/* =========================================================
   HERO
========================================================= */
.cs-dashboard-hero {
  position: relative;
  margin-bottom: 40px;
  padding: 40px;
  border-radius: 28px;
  overflow: hidden;
  background: linear-gradient(135deg, #120a1f, #1b1333);
  border: 1px solid rgba(255,255,255,.05);
}

.cs-dashboard-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(245,179,1,.12), transparent 60%);
  pointer-events: none;
}

.cs-dashboard-hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
}

.cs-dashboard-hero p {
  margin: 0;
  color: var(--cs-muted);
  font-size: 1rem;
  max-width: 640px;
}

/* =========================================================
   ACTION ROW
========================================================= */
.cs-artist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 28px;
}

/* =========================================================
   BUTTONS
========================================================= */
.Btn,
.cs-BTN {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 700;
  transition: var(--cs-transition);
}

.Btn-primary,
.cs-BTN-primary {
  background: linear-gradient(90deg, #f5b301, #ff8c42);
  color: #120a1f;
}
.Btn-primary:hover,
.cs-BTN-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(245,179,1,.35);
}

.Btn-outline,
.cs-BTN-outline {
  background: transparent;
  border: 1px solid rgba(157,77,255,.5);
  color: #9d4dff;
}
.Btn-outline:hover,
.cs-BTN-outline:hover {
  background: rgba(157,77,255,.08);
  box-shadow: 0 0 20px rgba(157,77,255,.25);
}

/* =========================================================
   STATS ROW (grid base — dashboard-core.css refines per role)
========================================================= */
.cs-stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-top: 40px;
}

.cs-stat-card {
  background: var(--cs-panel);
  border: 1px solid var(--cs-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--cs-radius);
  padding: 18px 14px;
  text-align: center;
  box-shadow: var(--cs-shadow);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: var(--cs-transition);
}
.cs-stat-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(157,77,255,.45);
}
.cs-stat-card span {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--cs-gold);
}
.cs-stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--cs-muted);
  font-size: .8rem;
}

/* =========================================================
   SECTION HEAD
========================================================= */
.cs-section-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 30px 0 40px;
}
.cs-section-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -12px;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(245,179,1,.35), rgba(157,77,255,.15), transparent);
}
.cs-section-head h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 700;
}
.cs-section-head span {
  color: #bbbbbb;
  font-size: .92rem;
}

/* =========================================================
   MINI PLAYER
========================================================= */
.cs-mini-player {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 22px;
  border-radius: 24px;
  background: rgba(14,14,14,.95);
  border: 1px solid var(--cs-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--cs-shadow);
}

.play-btn,
#csPlayBtn,
.track-action {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: var(--cs-gold);
  color: #000;
  font-size: 18px;
  font-weight: 700;
  transition: var(--cs-transition);
}
.play-btn:hover,
#csPlayBtn:hover,
.track-action:hover {
  transform: scale(1.05);
}

.cs-player-meta { min-width: 220px; }
#csNowTitle { font-weight: 700; }
#csNowArtist { margin-top: 4px; color: var(--cs-muted); }

.cs-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}
#csSeek { flex: 1; }

/* =========================================================
   PLAYER SECTION
========================================================= */
.cs-artist-player {
  background: #1B1333;
  padding: 1.75rem;
  border-radius: 1.25rem;
  border: 1px solid rgba(245,179,1,.06);
  margin-bottom: 2rem;
}
.cs-artist-player h2 {
  color: #FFFFFF;
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}
.cs-player-box {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#cs-waveform {
  height: 80px;
  background: #120A1F;
  border-radius: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.2);
  border: 1px solid rgba(245,179,1,.05);
  position: relative;
  overflow: hidden;
}
#cs-waveform::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #F5B301, #FF8C42, #9D4DFF);
  opacity: .3;
}

.cs-audio-player {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #120A1F;
  padding: .75rem 1rem;
  border-radius: .75rem;
  border: 1px solid rgba(245,179,1,.05);
}

.play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(90deg, #F5B301, #FF8C42);
  color: #120A1F;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(245,179,1,.2);
}
.play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(245,179,1,.3);
}

.track-info {
  flex: 1;
  color: #EEEEEE;
  font-weight: 500;
  min-width: 120px;
  font-size: .95rem;
}

.progress {
  flex: 2;
  height: 4px;
  background: rgba(255,255,255,.06);
  border-radius: 4px;
  min-width: 80px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #F5B301, #FF8C42);
  border-radius: 4px;
  transition: width .1s;
}

/* =========================================================
   TRACK LIBRARY
========================================================= */
.cs-library { padding-bottom: 40px; }

.cs-track-row {
  display: grid;
  grid-template-columns: 60px 70px 1fr 90px 70px;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 14px;
  border-radius: 18px;
  cursor: pointer;
  background: rgba(18,18,18,.8);
  border: 1px solid var(--cs-border);
  transition: var(--cs-transition);
}
.cs-track-row:hover {
  transform: translateY(-3px);
  border-color: rgba(212,175,55,.4);
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
}

.track-thumb {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: cover;
}
.track-meta { display: flex; flex-direction: column; gap: 6px; }
.track-title { font-weight: 700; }
.track-artist,
.track-duration { color: var(--cs-muted); font-size: .85rem; }

/* =========================================================
   PROJECT / BEAT GRID
========================================================= */
.cs-project-grid,
.cs-beat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.cs-project-card,
.cs-beat-card,
.cs-track-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: 20px;
  background: linear-gradient(135deg, #120a1f, #1b1333);
  border: 1px solid rgba(255,255,255,.05);
  transition: var(--cs-transition);
}
.cs-project-card:hover,
.cs-beat-card:hover,
.cs-track-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 30px rgba(157,77,255,.3);
}

.cs-track-card.active {
  border: 1px solid rgba(212,175,55,.7);
  box-shadow: 0 0 12px rgba(212,175,55,.35), 0 0 28px rgba(212,175,55,.18);
  animation: csPulseGlow 1.8s ease-in-out infinite;
}
.cs-track-card.active::after {
  content: "● PLAYING";
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f5d67b;
  background: rgba(0,0,0,.7);
  padding: 4px 8px;
  border-radius: 999px;
}

/* =========================================================
   FLOATING UPLOADER
========================================================= */
#csFloatingUploader {
  position: fixed;
  right: 24px;
  bottom: calc(24px + var(--cs-safe-b));
  z-index: 9999;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(18,18,18,.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--cs-border);
  box-shadow: var(--cs-shadow);
  animation: csPanelGlow 6s ease-in-out infinite;
}

.cs-drag-handle {
  cursor: move;
  font-size: 12px;
  color: var(--cs-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* =========================================================
   ANIMATIONS
========================================================= */
@keyframes csPulseGlow {
  0%   { box-shadow: 0 0 10px rgba(212,175,55,.25), 0 0 20px rgba(212,175,55,.10); }
  50%  { box-shadow: 0 0 18px rgba(212,175,55,.55), 0 0 36px rgba(212,175,55,.22); }
  100% { box-shadow: 0 0 10px rgba(212,175,55,.25), 0 0 20px rgba(212,175,55,.10); }
}
@keyframes csPanelGlow {
  0%   { box-shadow: 0 10px 40px rgba(0,0,0,.7), 0 0 20px rgba(157,77,255,.2); }
  50%  { box-shadow: 0 15px 50px rgba(0,0,0,.9), 0 0 30px rgba(157,77,255,.35); }
  100% { box-shadow: 0 10px 40px rgba(0,0,0,.7), 0 0 20px rgba(157,77,255,.2); }
}

/* =========================================================
   FOOTER GAP HARD FIX
========================================================= */
.site-footer,
footer {
  margin-top: 0 !important;
  padding-top: 0;
}
.cs-dashboard + footer,
.cs-dashboard + .site-footer {
  margin-top: 0 !important;
}
.cs-dashboard:last-child {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}
body.page-template {
  margin-bottom: 0 !important;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 1024px) {
  .cs-stats-row { grid-template-columns: repeat(3, 1fr); }

  .cs-dashboard-main,
  .cs-artist-main,
  .cs-client-main,
  .cs-studio-main {
    padding: 28px;
  }
}

@media (max-width: 768px) {
  /* sidebar becomes slide-in drawer */
  .cs-sidebar,
  .cs-artist-sidebar,
  .cs-client-sidebar,
  .cs-studio-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh; /* OK — sidebar itself can be fixed height, it's not the shell */
    transform: translateX(100%);
    transition: transform .35s ease;
    z-index: 1001;
    overflow-y: auto;
    background: rgba(20,12,40,.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
  .cs-sidebar.active,
  .cs-artist-sidebar.active,
  .cs-client-sidebar.active,
  .cs-studio-sidebar.active {
    transform: translateX(0);
  }

  .cs-dashboard-main,
  .cs-artist-main,
  .cs-client-main,
  .cs-studio-main {
    padding: 20px;
  }

  .cs-stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .cs-mini-player {
    flex-direction: column;
    align-items: stretch;
  }

  .cs-track-row { grid-template-columns: 45px 55px 1fr; }
  .track-duration,
  .track-action { display: none; }

  .cs-section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  #csFloatingUploader {
    left: 15px;
    right: 15px;
    width: auto;
    bottom: calc(90px + var(--cs-safe-b));
  }
}

@media (max-width: 480px) {
  .cs-dashboard-hero { padding: 28px 22px; }
  .cs-dashboard-hero h1 { font-size: 1.9rem; }
  .cs-stat-card { min-height: 100px; }
}

/* =========================================================
   TRACK FILTERING — library header
========================================================= */
.cs-library-header {
  margin-bottom: 28px;
  padding: 24px;
  border-radius: 22px;
  background: linear-gradient(135deg, #120a1f, #1b1333);
  border: 1px solid rgba(245,179,1,.12);
  box-shadow: 0 20px 40px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.03);
}

.cs-library-top { margin-bottom: 18px; }

.cs-library-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.cs-library-title-wrap h2 {
  margin: 0;
  font-size: 26px;
  color: #fff;
  font-weight: 700;
}
.cs-track-count {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(245,179,1,.08);
  border: 1px solid rgba(245,179,1,.18);
  color: #f5b301;
  font-size: 13px;
  font-weight: 600;
}

.cs-library-controls {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.cs-search-wrap {
  position: relative;
  flex: 1;
  min-width: 260px;
}
.cs-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #f5b301;
  font-size: 18px;
  pointer-events: none;
}
.cs-track-search {
  width: 100%;
  padding: 14px 18px 14px 48px;
  border-radius: 16px;
  border: 1px solid rgba(245,179,1,.14);
  background: rgba(255,255,255,.03);
  color: #fff;
  outline: none;
  font-size: 15px;
  transition: all .25s ease;
}
.cs-track-search::placeholder { color: #bbb; }
.cs-track-search:focus {
  border-color: #f5b301;
  box-shadow: 0 0 0 4px rgba(245,179,1,.08), 0 0 20px rgba(245,179,1,.12);
}

.cs-track-sort {
  min-width: 180px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(157,77,255,.18);
  background: rgba(255,255,255,.03);
  color: #fff;
  outline: none;
  cursor: pointer;
  font-size: 14px;
  transition: all .25s ease;
}
.cs-track-sort:focus,
.cs-track-sort:hover {
  border-color: #9d4dff;
  box-shadow: 0 0 20px rgba(157,77,255,.15);
}

@media (max-width: 768px) {
  .cs-library-header { padding: 18px; }
  .cs-library-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .cs-search-wrap {
    width: 100%;
    min-width: 100%;
  }
  .cs-track-sort {
    width: 100%;
    min-width: 100%;
  }
  .cs-library-title-wrap h2 { font-size: 22px; }
}