/* TBPlayer — Mobile-first overrides поверх Pico CSS */

:root {
  --tb-primary: #7c3aed;
  --tb-accent: #a78bfa;
  --tb-bg: #0f0f1a;
  --tb-card: #1a1a2e;
  --tb-border: #2d2d4e;
}

html[data-theme="dark"] {
  --pico-background-color: var(--tb-bg);
  --pico-card-background-color: var(--tb-card);
  --pico-primary: var(--tb-primary);
  --pico-primary-hover: var(--tb-accent);
  --pico-border-color: var(--tb-border);
}

body {
  min-height: 100dvh;
}

/* Nav */
.tb-nav {
  border-bottom: 1px solid var(--tb-border);
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--tb-bg);
}

/* Loading */
.tb-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60vh;
}

/* ---- Player ---- */
.tb-player-card {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.tb-book-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}

.tb-book-author {
  color: var(--pico-muted-color);
  margin: 0 0 1rem;
}

.tb-audio-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tb-seek-bar {
  width: 100%;
  margin-bottom: 0.5rem;
}

.tb-time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  margin-bottom: 0.75rem;
}

.tb-speed-btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

.tb-skip-btn {
  font-size: 0.9rem;
}

/* Chapter list */
.tb-chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 40vh;
  overflow-y: auto;
}

.tb-chapter-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--tb-border);
  cursor: pointer;
  border-radius: 0.25rem;
  transition: background 0.15s;
}

.tb-chapter-item:hover { background: rgba(124,58,237,0.1); }
.tb-chapter-item.active { background: rgba(124,58,237,0.2); }

.tb-chapter-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-ready    { background: #22c55e; }
.status-downloading { background: #f59e0b; animation: pulse 1s infinite; }
.status-pending  { background: #6b7280; }
.status-failed   { background: #ef4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Shelf ---- */
.tb-shelf-grid {
  display: grid;
  gap: 1rem;
}

.tb-shelf-card {
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 0.75rem;
  padding: 1rem;
}

.tb-progress-bar {
  height: 6px;
  background: var(--tb-border);
  border-radius: 3px;
  overflow: hidden;
  margin: 0.5rem 0;
}

.tb-progress-fill {
  height: 100%;
  background: var(--tb-primary);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ---- Search ---- */
.tb-search-result {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

.tb-result-meta {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  display: flex;
  gap: 1rem;
}

.tb-seeds { color: #22c55e; }
.tb-leeches { color: #ef4444; }

/* Active nav link */
#nav-links a.active { color: var(--tb-accent); text-decoration: underline; }

/* Muted text helper */
.tb-muted { color: var(--pico-muted-color); }

/* Card center for register */
.tb-card-center {
  max-width: 480px;
  margin: 2rem auto;
  background: var(--tb-card);
  border: 1px solid var(--tb-border);
  border-radius: 1rem;
  padding: 1.5rem;
}

/* Error text */
.tb-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  border-radius: 0.5rem;
  padding: 1rem;
  color: #fca5a5;
}

/* Toast */
.tb-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(120%);
  background: var(--tb-card);
  color: var(--pico-color);
  border: 1px solid var(--tb-border);
  border-radius: 0.75rem;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  z-index: 1000;
  transition: transform 0.25s ease;
  max-width: 90vw;
}
.tb-toast.show { transform: translateX(-50%) translateY(0); }
.tb-toast-success { border-color: #22c55e; }
.tb-toast-error   { border-color: #ef4444; color: #fca5a5; }

/* Responsive */
@media (min-width: 768px) {
  .tb-shelf-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .tb-shelf-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
