/* ── Reset / Base ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --black: #222222;
  --black-75: rgba(34, 34, 34, 0.75);
  --black-50: rgba(34, 34, 34, 0.5);
  --black-25: rgba(34, 34, 34, 0.25);
  --black-10: rgba(34, 34, 34, 0.1);
  --black-02: rgba(34, 34, 34, 0.02);
  --red: #d92323;
  --red-10: rgba(217, 35, 35, 0.1);
  --white: #ffffff;
  --bg: #fbfbfb;
  --border: rgba(34, 34, 34, 0.1);

  --topbar-height: 64px;
  --sidenav-width: 200px;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', sans-serif;
  background-color: var(--white);
  color: var(--black);
  letter-spacing:0.02em;
}

/* ════════════════════════════════════════
   LOGIN PAGE
════════════════════════════════════════ */

#login-page {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: var(--black-02);
  padding-bottom: 80px;
}

.login-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.login-card {
  width: 400px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

.login-instructions {
  font-size: 14px;
  line-height: 22px;
  color: var(--black);
  font-weight: 400;
}

.login-instructions strong {
  font-weight: 700;
}

#login-form {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-input {
  width: 100%;
  height: 37px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 16px;
  font-size: 12px;
  font-family: inherit;
  color: var(--black);
  outline: none;
  transition: border-color 0.15s ease;
}

.login-input::placeholder {
  color: var(--black-25);
}

.login-input:focus {
  border-color: var(--black-25);
}

.login-btn {
  width: 100%;
  height: 37px;
  background: var(--red);
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  color: var(--white);
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.login-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.login-btn:not(:disabled):hover {
  background: #b81e1e;
}

.login-btn:not(:disabled):active {
  background: #9e1a1a;
}

.login-signup {
  margin-top: 40px;
  font-size: 12px;
  line-height: 20px;
  color: var(--black);
}

.login-signup a {
  color: var(--red);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-signup a:hover {
  opacity: 0.8;
}

.powered-by {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.powered-by-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--black-50);
  font-weight: 400;
}

.lastfm-logo {
  width: 80px;
  height: 20px;
}

.wave-decoration {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80px;
  pointer-events: none;
}

.wave-decoration img {
  width: 100%;
  height: 100%;
}


/* ════════════════════════════════════════
   DASHBOARD SHELL
════════════════════════════════════════ */

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 200;
}

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

.brand-text {
  font-size: 20px;
  font-weight: 500;
  color: var(--black);
  line-height: 1;
}

.brand-red {
  color: var(--red);
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.brand-mark {
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--black-10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--black);
  text-transform: uppercase;
  flex-shrink: 0;
  user-select: none;
}

.user-name {
  font-size: 12px;
  color: var(--black);
  white-space: nowrap;
}

.user-chevron {
  width: 9px;
  height: 5px;
  flex-shrink: 0;
}

/* ── App shell ── */
.app-shell {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidenav {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidenav-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 100;
}

.sidenav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  padding: 0 16px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 400;
  color: var(--black);
  opacity: 0.75;
  cursor: pointer;
  transition: background 0.1s ease, opacity 0.1s ease;
}

.sidenav-item.active {
  background: var(--red-10);
  color: var(--red);
  opacity: 1;
  font-weight: 700;
}

.sidenav-item:not(.active):hover {
  background: var(--black-02);
  opacity: 1;
}

.sidenav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── Content area ── */
.content-area {
  margin-left: var(--sidenav-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-height));
}

/* ── Main content ── */
.main-content {
  flex: 1;
  background: var(--bg);
  padding: 36px 40px;
}

/* ── Back to top ── */
.back-to-top {
  position: fixed;
  bottom: 40px;
  right: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 500;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top img {
  width: 40px;
  height: 40px;
  display: block;
}

/* ════════════════════════════════════════
   DARK THEME
════════════════════════════════════════ */

[data-theme="dark"] {
  color-scheme: dark;
  --black:    #e8e8e8;
  --black-75: rgba(232, 232, 232, 0.75);
  --black-50: rgba(232, 232, 232, 0.5);
  --black-25: rgba(232, 232, 232, 0.25);
  --black-10: rgba(232, 232, 232, 0.1);
  --black-02: rgba(232, 232, 232, 0.04);
  --white:    #1e1e1e;
  --bg:       #161616;
  --border:   rgba(232, 232, 232, 0.1);
  --red-10:   rgba(217, 35, 35, 0.18);
}

/* Invert UI chrome icons (chevrons, calendar) so they read as light on dark
   backgrounds. Active sidenav icons (red) and branded/decorative icons are
   intentionally excluded. */
[data-theme="dark"] .sidenav-item:not(.active) .sidenav-icon,
[data-theme="dark"] .mob-nav-item:not(.active) .mob-nav-icon,
[data-theme="dark"] .user-chevron,
[data-theme="dark"] .ov-date-btn-icon,
[data-theme="dark"] .ov-date-btn-chevron,
[data-theme="dark"] .banner-arrow {
  filter: invert(1);
}

/* Skeleton / placeholder backgrounds */
[data-theme="dark"] .top5-skel,
[data-theme="dark"] .top5-skel-bar,
[data-theme="dark"] .genre-btn-skel,
[data-theme="dark"] .cm-skel,
[data-theme="dark"] .cm-skel--line,
[data-theme="dark"] .sc-skel {
  background: #333;
}

[data-theme="dark"] .top5-thumb,
[data-theme="dark"] .artist-thumb,
[data-theme="dark"] .sc-thumb {
  background: #333;
}

[data-theme="dark"] .sc-loader-dot {
  background: #555;
}

/* Table column header subtle fill */
[data-theme="dark"] .sc-col-head {
  background: rgba(232, 232, 232, 0.04);
}

/* Stats tile gradient — bump opacity so it reads on dark card */
[data-theme="dark"] .qs-tile {
  background: linear-gradient(to bottom, rgba(217, 35, 35, 0.14), rgba(217, 35, 35, 0.06) 95.548%);
}

/* Quick Stats tile headings (Listening Time, Unique Listening) */
[data-theme="dark"] .qs-tile-head {
  color: #fff;
}

/* Delta badges — 25% opacity bg, vivid icon + text */
[data-theme="dark"] .qs-delta--up {
  background: rgba(35, 217, 35, 0.25);
  color: #23d923;
}

[data-theme="dark"] .qs-delta--down {
  background: rgba(217, 35, 35, 0.25);
  color: #d92323;
}

/* ── Theme toggle button ── */
.theme-toggle {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--black-50);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.1s ease, color 0.1s ease;
  margin-right: 8px;
}

.theme-toggle:hover {
  background: var(--black-10);
  color: var(--black);
}

/* ════════════════════════════════════════
   MOBILE SHELL
════════════════════════════════════════ */

/* ── Hamburger button (hidden on desktop) ── */
.mob-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--black);
  border-radius: 4px;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.1s ease;
}

.mob-hamburger:hover {
  background: var(--black-10);
}

/* ── Mobile topbar center (hidden on desktop) ── */
.mob-topbar-center {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.mob-brand-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--black);
  line-height: 1;
}

.mob-brand-red {
  color: var(--red);
}

.mob-page-name {
  font-size: 10px;
  color: var(--black-50);
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Full-screen slide-in menu ── */
.mob-menu {
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
}

.mob-menu--open {
  pointer-events: auto;
}

.mob-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mob-menu--open .mob-backdrop {
  opacity: 1;
}

.mob-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.mob-menu--open .mob-panel {
  transform: translateX(0);
}

.mob-panel-head {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mob-head-logos {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mob-close {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.1s ease;
  flex-shrink: 0;
}

.mob-close:hover {
  background: var(--black-10);
}

.mob-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.mob-nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 48px;
  padding: 0 16px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  color: var(--black);
  opacity: 0.75;
  transition: background 0.1s ease, opacity 0.1s ease;
}

.mob-nav-item.active {
  background: var(--red-10);
  color: var(--red);
  opacity: 1;
  font-weight: 700;
}

.mob-nav-item:not(.active):hover {
  background: var(--black-02);
  opacity: 1;
}

.mob-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.mob-panel-foot {
  border-top: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.mob-foot-theme {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mob-foot-label {
  font-size: 12px;
  color: var(--black-50);
}

.mob-foot-logos {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mob-logomark {
  width: 28px;
  height: 16px;
  flex-shrink: 0;
}

.mob-logo-sep {
  width: 1px;
  height: 16px;
  background: var(--black-25);
  margin: 0 2px;
  flex-shrink: 0;
}

.mob-lastfm-logo {
  height: 16px;
  width: 32px;
  flex-shrink: 0;
}


/* ════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── Topbar: 3-column grid ── */
  .topbar {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-brand { display: none; }

  .mob-hamburger { display: flex; }

  .mob-topbar-center { display: flex; }

  .topbar-user { gap: 0; }

  .user-name,
  .user-chevron { display: none; }

  /* Theme toggle moves to mobile menu */
  .topbar-user .theme-toggle { display: none; }

  /* ── Sidebar ── */
  .sidenav { display: none; }

  /* ── Content area fills full width ── */
  .content-area { margin-left: 0; }

  /* ── Main content tighter padding ── */
  .main-content { padding: 24px 16px; }

  /* ── Back to top closer to edge ── */
  .back-to-top {
    right: 16px;
    bottom: 20px;
  }

  /* ── Login card fluid width ── */
  .login-card {
    width: calc(100vw - 32px);
    max-width: 400px;
    padding: 28px 20px;
  }

  #login-page { padding: 24px 0 80px; }
}

/* Hide mob-menu entirely on desktop */
@media (min-width: 769px) {
  .mob-menu { display: none; }
}
