/* ============================================
   HarBarBashFM — Spotify × Apple Music hybrid PWA
   Mobile-first, dark theme, glass morphism
   ============================================ */

/* --- Reset & Foundation --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Allow selection only in input fields */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-elevated: #1a1a1a;
  --bg-hover: #222222;
  --bg-active: #2a2a2a;

  --glass-bg: rgba(28, 28, 30, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-tertiary: rgba(255, 255, 255, 0.45);

  --accent: #fc3c44;
  --accent-secondary: #8b2fc9;
  --accent-gradient: linear-gradient(135deg, #fc3c44 0%, #8b2fc9 100%);
  --accent-glow: rgba(252, 60, 68, 0.3);

  --success: #34c759;
  --danger: #ff453a;
  --divider: rgba(255, 255, 255, 0.06);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --mini-player-h: 64px;
  --header-h: 52px;
  --tab-bar-h: 50px;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.2s;
  --duration-normal: 0.35s;
  --duration-slow: 0.5s;
}

html {
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
    'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  height: -webkit-fill-available;
  overflow: hidden;
  position: fixed;
  width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.screen { height: 100%; width: 100%; position: fixed; top: 0; left: 0; }
::-webkit-scrollbar { width: 0; background: transparent; }

/* ==========================================
   GATE / INVITE SCREEN
   ========================================== */
#gate-screen {
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.gate-content {
  text-align: center;
  padding: 32px 24px;
  width: 100%;
  max-width: 340px;
}

.gate-logo { margin-bottom: 48px; }

.gate-logo-icon {
  margin-bottom: 20px;
  animation: gate-float 3s ease-in-out 2;
}

@keyframes gate-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* PWA install gate (mobile only) */
#pwa-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.pwa-gate-content {
  text-align: center;
  max-width: 320px;
}
.pwa-gate-content svg {
  margin-bottom: 20px;
  animation: gate-float 3s ease-in-out infinite;
}
.pwa-gate-content h1 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.pwa-gate-content > p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}
.pwa-gate-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}
.pwa-gate-step {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  color: var(--text-primary);
}
.pwa-gate-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

/* Server notification modal */
.server-notif-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.server-notif-modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}
.server-notif-modal h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.server-notif-modal p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}
.server-notif-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.server-notif-btn {
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-hover);
  color: var(--text-primary);
}
.server-notif-btn.accent {
  background: var(--accent);
  color: white;
}

.gate-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gate-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-username, #login-password {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 17px;
  color: var(--text-primary);
  text-align: center;
  font-weight: 500;
  outline: none;
  transition: border-color var(--duration-fast) ease;
  width: 100%;
}

#login-username::placeholder, #login-password::placeholder {
  font-weight: 400;
  color: var(--text-tertiary);
}

#login-username:focus, #login-password:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 32px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring), opacity var(--duration-fast);
}

.btn-primary:active {
  transform: scale(0.97);
  opacity: 0.9;
}

.gate-error {
  color: var(--accent);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* --- Install PWA Banner --- */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  padding-bottom: calc(16px + var(--safe-bottom));
  background: var(--bg-elevated);
  border-top: 1px solid var(--glass-border);
  z-index: 1000;
  animation: slideUpBanner 0.4s ease-out;
}

@keyframes slideUpBanner {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.install-banner.hidden { display: none; }

.install-banner-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.3;
}

.install-banner-text strong {
  font-size: 15px;
}

.install-banner-text span {
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.inline-share-icon {
  display: inline-block;
  vertical-align: middle;
  color: var(--accent);
}

.install-banner-text em {
  font-style: normal;
  color: var(--text-primary);
  font-weight: 500;
}

.install-banner-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 8px;
  cursor: pointer;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s ease; }

/* ==========================================
   SAFE AREAS
   ========================================== */
.safe-area-top { height: var(--safe-top); flex-shrink: 0; }
.safe-area-bottom { height: var(--safe-bottom); flex-shrink: 0; }

/* ==========================================
   APP CONTAINER
   ========================================== */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: -webkit-fill-available;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--bg-primary);
}

/* ==========================================
   TAB VIEWS
   ========================================== */
.tab-view {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  opacity: 0;
}

.tab-view.active {
  display: flex;
  animation: tab-fade-in 0.25s var(--ease-out) forwards;
}

@keyframes tab-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 0.5px solid var(--divider);
  flex-shrink: 0;
  padding: 12px 20px;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
}

.header-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tab-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--mini-player-h) + var(--tab-bar-h) + var(--safe-bottom) + 16px);
}

/* ==========================================
   BOTTOM TAB BAR (Spotify-style)
   ========================================== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-primary);
  border-top: 0.5px solid var(--divider);
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(var(--tab-bar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: color var(--duration-fast);
}

.tab-bar-item.active {
  color: var(--text-primary);
}

.tab-bar-item:active {
  opacity: 0.7;
}

/* ==========================================
   SEARCH BAR (Apple Music style)
   ========================================== */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 0 14px;
  width: 100%;
  gap: 10px;
  height: 44px;
}

.search-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px;
  padding: 8px 0;
  min-width: 0;
}

#search-input::placeholder {
  color: var(--text-tertiary);
}

/* Remove Safari search decoration */
#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-decoration {
  display: none;
}

.search-clear-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 4px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.search-placeholder {
  display: flex;
  flex-direction: column;
  color: var(--text-tertiary);
  font-size: 15px;
}

/* Search playlist results */
.search-playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
}
.search-playlist-item:active { background: var(--bg-hover); }
.search-playlist-cover {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-playlist-cover img { width: 100%; height: 100%; object-fit: cover; }
.search-playlist-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-playlist-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-playlist-meta { font-size: 13px; color: var(--text-secondary); }

/* ==========================================
   LOADING
   ========================================== */
.section-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 15px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--bg-hover);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================
   HOME GREETING
   ========================================== */
.home-greeting {
  padding: 20px 20px 16px;
}

.greeting-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

.greeting-quote {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
  opacity: 0.7;
}

