@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg: var(--tg-theme-bg-color, #0f0f14);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #1a1a24);
  --text: var(--tg-theme-text-color, #e8e6f0);
  --text-dim: var(--tg-theme-hint-color, #6b6880);
  --accent: var(--tg-theme-button-color, #7c6aef);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #a78bfa);
  --header-bg: rgba(15, 15, 20, 0.85); /* fallback */
  --tab-bar-height: 70px;
  --mini-player-height: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(var(--tab-bar-height) + var(--mini-player-height) + env(safe-area-inset-bottom, 0px) + 20px);
}

/* ── Typography & Helpers ──────────────────────────────── */
.title { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.meta { font-size: 12px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.hidden { display: none !important; }

/* ── Header ──────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 16px 20px 12px; backdrop-filter: blur(20px);
  display: flex; justify-content: space-between; align-items: flex-start;
}

/* ── Screens / Tabs ──────────────────────────────── */
.screen { display: none; padding: 16px 20px; animation: fadeIn 0.3s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ── Shows List (Эфиры) ──────────────────────────────── */
.show-card {
  background: var(--bg-secondary); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px; padding: 16px; margin-bottom: 16px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform 0.2s, background 0.2s;
}
.show-card:active { transform: scale(0.98); background: rgba(255,255,255,0.04); }
.show-card.playing { border-color: var(--accent); }
.show-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.show-date { font-size: 12px; color: var(--accent); font-weight: 600; text-transform: uppercase; }
.show-duration { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim); }
.show-title { font-size: 16px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.show-performer { font-size: 13px; color: var(--text-dim); }
.show-progress-container { width: 100%; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.show-progress-bar { height: 100%; background: var(--accent); width: 0%; border-radius: 2px; }

/* ── Admin Edit Button ──────────────────────────────── */
.btn-admin-edit { position: absolute; top: 12px; right: 12px; padding: 8px; background: rgba(0,0,0,0.2); border: none; color: var(--text-dim); border-radius: 50%; cursor: pointer; }
.btn-admin-edit svg { width: 16px; height: 16px; fill: currentColor; }

/* ── Player Full View ──────────────────────────────── */
.player-full-view {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 20px;
}
.player-cover {
  width: 240px; height: 240px; border-radius: 24px;
  background: linear-gradient(135deg, var(--bg-secondary), #2d2b42);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px; position: relative; overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.player-cover.playing { transform: scale(1.05); }
.player-cover-icon { font-size: 64px; opacity: 0.8; }
.player-info-container { text-align: center; margin-bottom: 24px; width: 100%; }
.player-full-title { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.2; word-break: break-word;}
.player-full-performer { font-size: 15px; color: var(--text-dim); margin-bottom: 12px;}

/* Custom Progress Bar */
.scrubber-container { width: 100%; display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.scrubber-time { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-dim); min-width: 45px; text-align: center;}
.scrubber-wrap { flex: 1; height: 30px; display: flex; align-items: center; cursor: pointer; position: relative;}
.scrubber-track { width: 100%; height: 4px; background: rgba(120, 120, 120, 0.25); border-radius: 2px; position: relative; }
.scrubber-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--accent); border-radius: 2px; width: 0%; pointer-events: none;}
.scrubber-thumb { position: absolute; top: 50%; width: 14px; height: 14px; background: var(--text); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 2px 5px rgba(0,0,0,0.2); pointer-events: none;}

/* Main Controls */
.main-controls { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 30px; }
.btn-ctrl { background: none; border: none; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; transition: transform 0.1s, background 0.2s; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;}
.btn-ctrl:active { transform: scale(0.9); background: rgba(255,255,255,0.06); }
.btn-ctrl svg { width: 28px; height: 28px; fill: currentColor; }
.btn-play-huge { width: 72px; height: 72px; background: var(--accent); color: var(--accent-text); box-shadow: 0 10px 20px rgba(124, 106, 239, 0.4); }
.btn-play-huge:active { background: var(--accent); }
.btn-play-huge svg { width: 36px; height: 36px; }

/* Interactive Tracklist */
.tracklist { width: 100%; display: flex; flex-direction: column; }
.tracklist-header { font-size: 14px; font-weight: 600; color: var(--text-dim); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px;}
.tl-item { display: flex; align-items: center; padding: 12px 10px; border-radius: 12px; cursor: pointer; transition: background 0.2s; gap: 12px; scroll-margin-top: 100px; }
.tl-item:active { background: rgba(255,255,255,0.04); }
.tl-item.active { background: rgba(124, 106, 239, 0.1); }
.tl-time { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--accent); font-weight: 500;}
.tl-title { flex: 1; font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-like { background: none; border: none; color: var(--text-dim); padding: 8px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;}
.tl-like.liked { color: #f43f5e; }
.tl-like svg { width: 20px; height: 20px; fill: currentColor; }

/* ── Favorites ──────────────────────────────── */
.fav-card {
  background: var(--bg-secondary); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px; padding: 16px; margin-bottom: 12px; cursor: pointer; display: flex; align-items: center; gap: 16px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.fav-card.sortable-ghost { opacity: 0.15; }
.fav-card.sortable-chosen { border-color: var(--accent); box-shadow: 0 8px 25px rgba(0,0,0,0.4); }
.fav-card.sortable-fallback { opacity: 1 !important; box-shadow: 0 15px 35px rgba(0,0,0,0.6); border-color: var(--accent); background: var(--bg-secondary); }
.fav-card.active { border-color: var(--accent); background: rgba(124, 106, 239, 0.05); }
.fav-info { flex: 1; overflow: hidden; }
.fav-title { font-size: 15px; font-weight: 500; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.fav-meta { font-size: 12px; color: var(--text-dim); display: flex; gap: 8px; align-items: center;}
.fav-delete { background: none; border: none; color: #f43f5e; padding: 8px; cursor: pointer; opacity: 0.7; }

/* ── Mini Player (sticky bottom before tabs) ──────────────────────────────── */
.mini-player {
  position: fixed; bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0px)); left: 8px; right: 8px;
  background: rgba(45, 43, 66, 0.95); backdrop-filter: blur(10px);
  border-radius: 16px; height: var(--mini-player-height);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4); z-index: 40; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.1);
  transform: translateY(150%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.mini-player.visible { transform: translateY(0); }
.mp-info { flex: 1; overflow: hidden; }
.mp-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text);}
.mp-subtitle { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;}
.mp-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mp-btn { background: none; border: none; color: var(--text); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 50%;}
.mp-btn:active { background: rgba(255,255,255,0.1); }
.mp-btn svg { width: 22px; height: 22px; fill: currentColor; }

/* ── Tab Bar ──────────────────────────────── */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0px));
  background: var(--bg-secondary); border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 50;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-dim); gap: 4px; cursor: pointer; transition: color 0.2s;
}
.tab.active { color: var(--accent); }
.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab span { font-size: 11px; font-weight: 500; }

/* ── Loading / Empty States ──────────────────────────────── */
.loading-view, .empty-view { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 50vh; color: var(--text-dim); gap: 16px; text-align: center;}
.spinner { width: 32px; height: 32px; border: 2px solid rgba(255,255,255,0.1); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal (Admin & Confirmations) ──────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -40%) scale(0.95); width: 90%; max-width: 400px; background: var(--bg-secondary); border-radius: 16px; padding: 24px; z-index: 101; opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.modal.visible { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal input, .modal textarea { width: 100%; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 10px 14px; color: var(--text); font-family: inherit; font-size: 15px; margin-bottom: 12px; }
.modal button.primary { background: var(--accent); color: var(--accent-text); border: none; padding: 12px; border-radius: 10px; width: 100%; font-weight: 600; cursor: pointer; margin-top: 8px;}
.modal button.secondary { background: rgba(255,255,255,0.05); color: var(--text); border: none; padding: 12px; border-radius: 10px; width: 100%; font-weight: 600; cursor: pointer; margin-top: 8px;}

/* Toast Notification */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--accent); color: var(--accent-text); padding: 12px 24px;
  border-radius: 30px; font-size: 14px; font-weight: 600; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  z-index: 1000; opacity: 0; pointer-events: none; transition: all 0.3s ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.scrubber-marker { position: absolute; z-index: 5; top: 0; bottom: 0; height: 100%; width: 2px; background: rgba(0,0,0,0.4); pointer-events: none; border-radius: 0; }
.fav-order-btns { display: flex; flex-direction: column; gap: 4px; border-left: 1px solid rgba(255,255,255,0.1); padding-left: 8px; }
.fav-order-btns button { width: 30px; height: 30px; background: rgba(255,255,255,0.05); border: none; border-radius: 6px; color: var(--text-dim); display: flex; align-items: center; justify-content: center; }
.fav-order-btns button:active { background: rgba(255,255,255,0.1); }

.theme-tab-shows {
  --accent: #f43f5e;
}

.theme-tab-player {
  --accent: #8b5cf6;
}

.theme-tab-favorites {
  --accent: #f06292;
}

/* Light mode overrides for colorful backgrounds */
@media (prefers-color-scheme: light) {
  .theme-tab-player { --text: #1e1b4b; --text-dim: #4c1d95; }
  .theme-tab-favorites { --text: #4c0519; --text-dim: #9f1239; }
  .scrubber-marker { background: rgba(255,255,255,0.8); }
}

.fav-goto {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); cursor: pointer;
  background: none; border: none;
  opacity: 0.8;
}
.fav-goto:active { opacity: 1; transform: scale(1.1); }


.fav-prog-container {
  width: 100%;
  height: 2px;
  background: rgba(255,255,255,0.1);
  margin-top: 6px;
  border-radius: 2px;
  overflow: hidden;
}

#fav-prog-inner {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
}

.show-star:active {
  transform: scale(1.2);
}
