/* ============================================================
   TV CLONE — Design sombre inspiré de TV Time
   ============================================================ */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222222;
  --bg-modal: #1a1a2e;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --accent: #00d2a0;
  --accent-hover: #00e6b0;
  --accent-light: rgba(0,210,160,0.15);
  --green: #00d2a0;
  --green-light: rgba(0,210,160,0.15);
  --orange: #ff9f43;
  --orange-light: rgba(255,159,67,0.15);
  --red: #ff6b6b;
  --red-light: rgba(255,107,107,0.15);
  --border: #2a2a2a;
  --radius: 14px;
  --radius-sm: 10px;
  --nav-height: 70px;
  --header-height: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-top: var(--header-height);
}

/* ===== HEADER ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-primary);
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.app-logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-actions { display: flex; gap: 8px; }

.btn-icon-header {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-icon-header:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ===== TABS ===== */
.tab-content { display: none; padding: 16px 20px; }
.tab-content.active { display: block; }

.tab-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.tab-header h2 { font-size: 1.5rem; font-weight: 700; }

.badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
}

/* ===== FILTER CHIPS ===== */
.filter-row {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-chip:hover:not(.active) { border-color: var(--accent); color: var(--text-primary); }

/* ===== SHOW LIST ===== */
.show-list { display: flex; flex-direction: column; gap: 10px; }

.show-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.show-card:hover { background: var(--bg-card-hover); border-color: var(--border); }

.show-poster {
  width: 60px; height: 85px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.show-poster-placeholder {
  width: 60px; height: 85px;
  border-radius: 8px;
  background: var(--bg-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.show-info { flex: 1; min-width: 0; }
.show-title { font-size: 1rem; font-weight: 700; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.show-meta { font-size: 0.78rem; color: var(--text-secondary); }
.show-progress-bar {
  height: 4px; background: var(--bg-secondary); border-radius: 2px;
  margin-top: 8px; overflow: hidden;
}
.show-progress-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

.progress-watching { background: var(--accent); }
.progress-completed { background: var(--green); }
.progress-paused { background: var(--orange); }
.progress-abandoned { background: var(--red); }

.show-status {
  font-size: 0.7rem; font-weight: 600;
  padding: 3px 10px; border-radius: 10px;
  flex-shrink: 0;
}
.status-watching { background: var(--accent-light); color: var(--accent); }
.status-completed { background: var(--green-light); color: var(--green); }
.status-paused { background: var(--orange-light); color: var(--orange); }
.status-abandoned { background: var(--red-light); color: var(--red); }

.show-actions { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.btn-show-action {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.btn-show-action:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ===== UPCOMING ===== */
.upcoming-list { display: flex; flex-direction: column; gap: 12px; }

.upcoming-group { margin-bottom: 8px; }
.upcoming-date {
  font-size: 0.85rem; font-weight: 700; color: var(--accent);
  margin-bottom: 8px;
  padding: 4px 0;
}

.upcoming-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border-radius: var(--radius);
  padding: 10px 14px;
}

.upcoming-info { flex: 1; min-width: 0; }
.upcoming-show { font-size: 0.9rem; font-weight: 700; }
.upcoming-ep { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state p:first-child { font-size: 3rem; margin-bottom: 10px; }

/* ===== PROFILE ===== */
.profile-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 16px; text-align: center;
}
.stat-value { display: block; font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-label { display: block; font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; }

.profile-section { margin-bottom: 24px; }
.profile-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }

.genre-chart { display: flex; flex-wrap: wrap; gap: 8px; }
.genre-tag {
  padding: 6px 14px; border-radius: 20px;
  background: var(--bg-card); font-size: 0.8rem;
  color: var(--text-secondary);
}

.profile-actions { display: flex; gap: 10px; }
.btn-secondary, .btn-danger {
  flex: 1; padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 500px;
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-around;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
}

.nav-tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; color: var(--text-muted);
  font-size: 0.7rem; font-family: var(--font); font-weight: 500;
  cursor: pointer; transition: color 0.2s; padding: 8px 16px;
}
.nav-tab.active { color: var(--accent); }
.nav-tab:hover { color: var(--text-primary); }

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.85);
  overflow-y: auto;
}
.modal.open { display: flex; align-items: flex-start; justify-content: center; }

.modal-content {
  width: 100%; max-width: 500px; min-height: 100dvh;
  background: var(--bg-modal);
  padding: 20px;
  position: relative;
}

.modal-detail { padding-top: 0; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 1.25rem; font-weight: 700; }

.btn-close {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-close:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* Search */
.search-input-wrapper { margin-bottom: 16px; }
#search-input {
  width: 100%; padding: 14px 18px;
  border-radius: var(--radius-sm); border: 2px solid var(--border);
  background: var(--bg-card); color: var(--text-primary);
  font-size: 1rem; font-family: var(--font); outline: none;
  transition: border-color 0.2s;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--text-muted); }

.search-results { display: flex; flex-direction: column; gap: 8px; }

.search-result-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border-radius: var(--radius);
  padding: 12px; cursor: pointer; transition: all 0.2s;
  border: 1px solid transparent;
}
.search-result-card:hover { background: var(--bg-card-hover); border-color: var(--accent); }
.search-result-card.added { opacity: 0.5; pointer-events: none; }

.empty-search { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* Detail */
.detail-backdrop {
  width: 100%; height: 200px; object-fit: cover;
  border-radius: 0 0 var(--radius) var(--radius);
}
.detail-poster {
  width: 100px; height: 150px; border-radius: 10px;
  object-fit: cover; margin-top: -60px; margin-left: 20px;
  border: 3px solid var(--bg-modal);
}
.detail-info { padding: 16px 20px 0; }
.detail-title { font-size: 1.4rem; font-weight: 800; }
.detail-meta { font-size: 0.82rem; color: var(--text-secondary); margin: 4px 0 12px; }
.detail-overview { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }

.detail-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.btn-status {
  padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s; font-family: var(--font);
}
.btn-status:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-status.selected[data-status="watching"] { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.btn-status.selected[data-status="completed"] { background: var(--green-light); border-color: var(--green); color: var(--green); }
.btn-status.selected[data-status="paused"] { background: var(--orange-light); border-color: var(--orange); color: var(--orange); }
.btn-status.selected[data-status="abandoned"] { background: var(--red-light); border-color: var(--red); color: var(--red); }

.detail-seasons { margin-top: 8px; }
.season-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid var(--border); cursor: pointer;
}
.season-header h3 { font-size: 1rem; font-weight: 700; }
.season-header span { font-size: 0.8rem; color: var(--text-muted); }

.episode-list { padding-bottom: 8px; }
.episode-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(42,42,69,0.5);
}
.episode-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
  background: transparent;
}
.episode-check.watched { background: var(--green); border-color: var(--green); color: #fff; }
.episode-check:hover { border-color: var(--green); }

.episode-info { flex: 1; min-width: 0; }
.episode-title { font-size: 0.88rem; font-weight: 600; }
.episode-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--accent); color: #fff; padding: 12px 24px;
  border-radius: 30px; font-weight: 600; font-size: 0.9rem;
  z-index: 300; transition: transform 0.3s ease; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px; text-align: center; margin: 20px;
  cursor: pointer; transition: all 0.2s; color: var(--text-secondary);
}
.upload-zone:hover { border-color: var(--accent); color: var(--accent); }

/* ===== RESPONSIVE ===== */
@media (min-width: 501px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
