@import url('theme.css');
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  color-scheme: only light;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:root {
  --black: #111111;
  --gray-100: #F9F9F9;
  --gray-200: #F0F0F0;
  --gray-300: #E0E0E0;
  --gray-500: #999999;
  --gray-700: #555555;
  --white: #FFFFFF;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --tab-height: 60px;
  --header-height: 130px;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  font-family: var(--font-body);
  background: var(--theme-page-bg);
  color: var(--black);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* ─── APP SHELL ─────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(430px, 100%);
  min-height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  height: 100dvh;
  height: 100svh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  overflow-x: hidden;
  background: var(--theme-page-elevated);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ─── STATUS BAR SPACER ─────────────────────────── */
.status-spacer {
  height: env(safe-area-inset-top, 12px);
  background: var(--theme-page-elevated);
}

/* ─── HEADER ────────────────────────────────────── */
.app-header {
  padding: 12px 20px 0;
  background: var(--theme-page-elevated);
  z-index: 10;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  min-width: 0;
}

.logo-wrap { display: flex; align-items: center; gap: 10px; }

.logo-mark {
  width: 38px; height: 38px;
  background: var(--theme-logo-bg);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.logo-mark svg { display: block; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }

.logo-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  color: var(--black);
  letter-spacing: -0.3px;
}

.logo-freq {
  font-size: 12px;
  font-weight: 500;
  color: var(--orange);
  letter-spacing: 0.5px;
}

.header-top .live-pill,
.header-top .listeners-pill {
  flex-shrink: 0;
  max-width: 100%;
}

.listeners-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  background: var(--theme-accent-soft);
  border: 1px solid var(--theme-accent-mid);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 700;
  color: var(--theme-accent-strong);
  letter-spacing: 0.4px;
  transition: opacity 0.3s;
}

.listeners-pill svg {
  color: var(--theme-accent);
  flex-shrink: 0;
}

.listeners-pill.updating { opacity: 0.6; }

#listenerCount {
  min-width: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--theme-accent-soft);
  border: 1px solid var(--theme-accent-mid);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--theme-accent-strong);
  letter-spacing: 0.8px;
}

.live-dot {
  width: 6px; height: 6px;
  background: var(--orange);
  border-radius: 50%;
}

.live-dot.pulsing { animation: livePulse 1.2s ease-in-out infinite; }

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ─── PLAYER CARD ───────────────────────────────── */
.player-card {
  background: var(--theme-surface-dark);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 0 20px 16px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.player-glow-1 {
  position: absolute;
  top: -50px; right: -50px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--theme-player-glow-1) 0%, transparent 70%);
  pointer-events: none;
}

.player-glow-2 {
  position: absolute;
  bottom: -40px; left: -30px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, var(--theme-player-glow-2) 0%, transparent 70%);
  pointer-events: none;
}

.player-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  position: relative; z-index: 1;
}

.album-thumb {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--theme-accent), var(--theme-accent-secondary));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.album-thumb .vinyl {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: 2.5px solid rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
}

.album-thumb .vinyl-dot {
  width: 8px; height: 8px;
  background: rgba(255,255,255,0.45);
  border-radius: 50%;
}

.album-thumb.spinning .vinyl { animation: spin 4s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.track-meta { flex: 1; min-width: 0; }

.now-playing-label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 3px;
}

.track-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.track-artist {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

.heart-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.4);
  padding: 4px;
  transition: color 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.heart-btn.liked { color: var(--orange); }
.heart-btn:active { transform: scale(1.25); }

/* Progress */
.progress-wrap {
  position: relative; z-index: 1;
  margin-bottom: 16px;
}

.progress-track {
  height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 2px;
  width: 0%;
  transition: width 1s linear;
  position: relative;
}

.progress-thumb {
  position: absolute;
  right: -5px; top: -4px;
  width: 11px; height: 11px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.progress-times {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
}

/* Controls */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative; z-index: 1;
  margin-bottom: 14px;
}

.ctrl-btn {
  width: 38px; height: 38px;
  background: none; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.55);
  transition: color 0.15s;
  border-radius: 50%;
}

.ctrl-btn:active { color: var(--white); background: rgba(255,255,255,0.08); }

.play-pause-btn {
  width: 54px; height: 54px;
  background: var(--theme-accent);
  border-radius: 50%;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s;
  box-shadow: 0 4px 16px var(--theme-accent-glow-shadow);
}

.play-pause-btn:active { transform: scale(0.94); }
.play-pause-btn:hover { background: var(--theme-accent-hover); }

/* Volume */
.volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative; z-index: 1;
}

.vol-icon { color: rgba(255,255,255,0.4); display: flex; align-items: center; }

.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.vol-slider::-moz-range-track {
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  background: rgba(255,255,255,0.75);
  border-radius: 50%;
  cursor: pointer;
}

.vol-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  background: rgba(255,255,255,0.75);
  border-radius: 50%;
  cursor: pointer;
}

/* ─── TABS ──────────────────────────────────────── */
.tabs-bar {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  background: var(--theme-page-elevated);
  flex-shrink: 0;
  padding: 0 20px;
}

.tab-btn {
  flex: 1;
  padding: 11px 4px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

/* ─── SCROLLABLE CONTENT ────────────────────────── */
.tab-content {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: calc(var(--tab-height) + env(safe-area-inset-bottom, 8px));
}

.tab-content.active { display: block; }

/* Request-only mode (chat disabled): no bottom nav — tighten scroll + toast */
#app.request-only .tab-content.active {
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 8px));
}

#app.request-only .toast {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* ─── SCHEDULE ──────────────────────────────────── */
.section-label {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--black);
  padding: 16px 20px 10px;
  letter-spacing: -0.2px;
}

.dj-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s;
  cursor: default;
}

.dj-row:active { background: var(--gray-100); }

.dj-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.dj-info { flex: 1; min-width: 0; }
.dj-name { font-size: 14px; font-weight: 500; color: var(--black); }
.dj-show { font-size: 12px; color: var(--gray-500); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.time-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  flex-shrink: 0;
  white-space: nowrap;
}

.time-badge.on-air { background: var(--theme-accent-soft); color: var(--theme-accent-strong); border: 1px solid var(--theme-accent-mid); }
.time-badge.next { background: var(--gray-100); color: var(--gray-700); }

/* ─── CHAT ──────────────────────────────────────── */
.chat-messages {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 200px;
}

.msg-row { display: flex; gap: 9px; align-items: flex-start; }
.msg-row.mine { flex-direction: row-reverse; }

.msg-avatar-sm {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-body { max-width: 72%; }
.msg-sender { font-size: 10px; color: var(--gray-500); margin-bottom: 3px; }
.msg-row.mine .msg-sender { text-align: right; }

.msg-bubble {
  background: var(--gray-100);
  border-radius: 4px 14px 14px 14px;
  padding: 9px 13px;
  font-size: 14px;
  color: var(--black);
  line-height: 1.4;
  word-break: break-word;
}

.msg-row.mine .msg-bubble {
  background: var(--orange);
  color: var(--white);
  border-radius: 14px 4px 14px 14px;
}

/* Sticky chat input */
.chat-input-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--theme-page-elevated);
  border-top: 1px solid var(--gray-200);
  align-items: center;
}

.chat-field {
  flex: 1;
  height: 40px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 0 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--black);
  outline: none;
  transition: border-color 0.2s;
}

.chat-field:focus { border-color: var(--gray-300); background: var(--white); }

.send-btn {
  width: 40px; height: 40px;
  background: var(--theme-accent);
  border: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s;
}

.send-btn:active { transform: scale(0.92); }

/* ─── REQUEST ───────────────────────────────────── */
.request-pad { padding: 20px; }

.req-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 8px;
  display: block;
}

.req-input-name {
  width: 100%;
  height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--black);
  outline: none;
  background: var(--gray-100);
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.req-input-name:focus { border-color: var(--theme-accent); background: var(--white); }

.req-textarea {
  width: 100%;
  height: 100px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--black);
  resize: none;
  outline: none;
  background: var(--gray-100);
  margin-bottom: 16px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.req-textarea:focus { border-color: var(--theme-accent); background: var(--white); }

.req-submit {
  width: 100%;
  height: 50px;
  background: var(--theme-accent);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.2px;
  transition: transform 0.12s, background 0.2s;
}

.req-submit:active { transform: scale(0.98); }
.req-submit:hover { background: var(--theme-accent-hover); }

.req-success {
  display: none;
  background: #E8F5E9;
  border: 1px solid #A5D6A7;
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-size: 14px;
  color: #2E7D32;
  font-weight: 500;
  margin-top: 12px;
}

.req-success.show { display: block; }

/* Recent requests */
.recent-requests { margin-top: 28px; }

.req-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.req-item-icon {
  width: 36px; height: 36px;
  background: var(--theme-accent-soft);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.req-item-info { flex: 1; min-width: 0; }
.req-item-track { font-size: 13px; font-weight: 500; color: var(--black); }
.req-item-by { font-size: 11px; color: var(--gray-500); margin-top: 1px; }
.req-item-meta { font-size: 10px; color: var(--gray-500); margin-top: 3px; word-break: break-word; }
.req-item-status { font-size: 11px; color: var(--theme-accent); font-weight: 500; }

/* ─── BUTT STATUS BANNER ────────────────────────── */
.butt-banner {
  margin: 0 20px 14px;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--gray-200);
}

.butt-icon-box {
  width: 32px; height: 32px;
  background: var(--theme-logo-bg);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.butt-text-wrap { flex: 1; min-width: 0; }
.butt-title { font-size: 12px; font-weight: 500; color: var(--black); }
.butt-url { font-size: 10px; font-family: monospace; color: var(--theme-accent); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.butt-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4CAF50;
  flex-shrink: 0;
}

.butt-status-dot.offline { background: var(--gray-300); }

/* ─── BOTTOM NAV ────────────────────────────────── */
.bottom-nav {
  height: var(--tab-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--theme-page-elevated);
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  transition: transform 0.12s;
}

.nav-btn:active { transform: scale(0.9); }

.nav-btn svg { display: block; }

.nav-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-300);
}

.nav-btn.active .nav-label { color: var(--theme-accent); }

/* ─── TOAST ─────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tab-height) + 12px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  max-width: min(360px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  width: max-content;
  background: var(--theme-surface-dark);
  color: var(--white);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 30px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: normal;
  text-align: center;
  line-height: 1.35;
  word-wrap: break-word;
  z-index: 999;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── INSTALL BANNER ────────────────────────────── */
.install-banner {
  display: none;
  margin: 0 20px 14px;
  background: linear-gradient(135deg, var(--theme-surface-dark), var(--theme-surface-dark-muted));
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  align-items: center;
  gap: 12px;
}

.install-banner.show { display: flex; }
.install-text { flex: 1; font-size: 12px; color: rgba(255,255,255,0.8); }
.install-text strong { display: block; color: var(--white); font-size: 13px; margin-bottom: 1px; }

.install-btn {
  background: var(--theme-accent);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── SCROLLBAR ─────────────────────────────────── */
.tab-content::-webkit-scrollbar { width: 0; }

/* ─── MOBILE: touch, small screens, iOS input zoom ─ */
@media (max-width: 480px) {
  .req-input-name,
  .req-textarea,
  .chat-field {
    font-size: 16px;
  }

  .player-card {
    margin: 0 12px 16px;
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .butt-banner,
  .install-banner {
    margin-left: 12px;
    margin-right: 12px;
  }

  .app-header {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tabs-bar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .request-pad {
    padding-left: 16px;
    padding-right: 16px;
  }

  .chat-messages,
  .chat-input-bar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .logo-name {
    font-size: clamp(14px, 4.2vw, 17px);
  }
}

@media (max-width: 360px) {
  .live-pill,
  .listeners-pill {
    padding: 5px 8px;
    font-size: 10px;
    letter-spacing: 0.3px;
  }

  .track-title {
    font-size: 15px;
  }
}

@media (pointer: coarse) {
  .ctrl-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .heart-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .play-pause-btn {
    width: 58px;
    height: 58px;
    min-width: 58px;
    min-height: 58px;
  }

  .send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .tab-btn {
    min-height: 44px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .nav-btn {
    min-height: 48px;
  }

  .req-submit {
    min-height: 48px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .player-card {
    margin-bottom: 10px;
    padding: 12px 14px;
  }

  .player-top {
    margin-bottom: 10px;
  }

  .progress-wrap {
    margin-bottom: 10px;
  }

  .player-controls {
    margin-bottom: 10px;
  }

  .album-thumb {
    width: 52px;
    height: 52px;
  }
}

/* ─── RESPONSIVE: Desktop preview ──────────────── */
@media (min-width: 500px) {
  body { background: var(--theme-page-bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
  #app {
    border-radius: 40px;
    border: 1.5px solid var(--theme-accent-mid);
    box-shadow: 0 24px 64px rgba(0,0,0,0.15);
    height: min(780px, 100dvh);
    height: min(780px, 100svh);
    min-height: min(780px, 100dvh);
  }
  .status-spacer { height: 16px; }
}
