* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-page: #f0f0f2;
  --bg-page-light: #fafafa;
  --text-primary: #1a1a1d;
  --text-secondary: #5a5a5e;
  --text-muted: #7a7a80;
  --border: #e2e2e6;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --card-bg: #fff;
  --heart: #e11d48;
  --sidebar-width: 240px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-text-muted: #94a3b8;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg-page);
  min-height: 100vh;
  color: var(--text-primary);
  direction: ltr;
  -webkit-font-smoothing: antialiased;
}

.player-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px);
  min-height: 100vh;
}

/* ----- Header ----- */
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.back-link:hover { text-decoration: underline; }

.header-title {
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  font-weight: 700;
  color: var(--text-primary);
}

.logout-btn {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.logout-btn:hover {
  background: var(--bg-page);
  border-color: var(--accent);
  color: var(--accent);
}

/* ----- Login (Fast IPTV style) ----- */
.login-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 32px 16px;
  text-align: center;
}

.fast-iptv-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.fast-iptv-logo { flex-shrink: 0; }

.tv-icon { display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08)); }

.fast-iptv-text { text-align: left; max-width: 420px; }

.fast-iptv-title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.fast-iptv-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-page-light);
  color: var(--text-primary);
  font-size: 1rem;
}

.login-card input::placeholder { color: var(--text-muted); }

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card-bg);
}

.login-card button {
  width: 100%;
  padding: 12px 16px;
  margin-top: 4px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.login-card button:hover { background: var(--accent-hover); }

.error-msg { color: #dc2626; font-size: 0.9rem; margin-top: 12px; }

.fast-iptv-rate { font-size: 0.9rem; color: var(--text-secondary); }

.fast-iptv-rate .heart { color: var(--heart); }

.rate-link { color: var(--text-primary); text-decoration: underline; font-weight: 500; }

.rate-link:hover { color: var(--accent); }

/* ----- Dashboard: top bar (tabs + search) ----- */
.dashboard-section { padding-bottom: 24px; }

.server-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--card-bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.server-info:empty { display: none; }

.dashboard-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  padding: 11px 22px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.2s;
}

.tab:hover { border-color: var(--accent); color: var(--accent); background: rgba(37, 99, 235, 0.06); }

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.search-wrap { flex: 1; min-width: 200px; }

.search-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-size: 0.95rem;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ----- Content layout: Bob Player style sidebar + main ----- */
.content-layout {
  display: flex;
  gap: 0;
  align-items: stretch;
  min-height: 420px;
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  padding: 0 20px;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-item {
  display: block;
  width: 100%;
  padding: 12px 20px;
  text-align: left;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left-color: #fff;
}

.main-content {
  flex: 1;
  min-width: 0;
  background: var(--card-bg);
  padding: 20px 24px;
  overflow-y: auto;
}

.panel {
  display: none;
}

.panel.active { display: block; }

.panel-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* ----- Content list (channels / VOD rows) ----- */
.content-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.content-list .item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
  color: var(--text-primary);
  font-size: 0.95rem;
  border: none;
  width: 100%;
  background: transparent;
}

.content-list .item-row:hover { background: var(--bg-page); }

.content-list .item-row .item-icon { color: var(--accent); }

.item-row .item-icon { font-size: 1.1rem; opacity: 0.8; flex-shrink: 0; }

.item-row .item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Grid for series (poster-style) */
.content-list--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.content-list--grid .item-row {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px;
}

.content-list--grid .item-poster {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-page);
}

.content-list--grid .item-name {
  margin-top: 8px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Group header (Bob Player style) */
.group-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 20px;
  margin-bottom: 10px;
  padding: 8px 0 6px;
  border-bottom: 2px solid var(--accent);
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.08) 0%, transparent 100%);
  padding-left: 12px;
  border-radius: 4px;
}

.group-header:first-child { margin-top: 0; }

.loading-msg, .empty-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ----- Episodes overlay ----- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay-box {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.overlay-close {
  align-self: flex-end;
  background: var(--bg-page);
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.overlay-close:hover { border-color: var(--accent); color: var(--accent); }

.episodes-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.episodes-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.episodes-list .item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.episodes-list .item-row:hover { background: var(--bg-page); }

/* ----- Video overlay ----- */
.player-overlay .overlay-box { max-width: 900px; }

.video-wrap {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16/9;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
}

.player-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
}

.player-title {
  margin-top: 12px;
  text-align: center;
}

.player-server-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
  .content-layout { flex-direction: column; min-height: auto; }
  .sidebar {
    width: 100%;
    padding: 12px 16px;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
  }
  .sidebar-label { width: 100%; margin-bottom: 8px; padding: 0 0 8px; }
  .sidebar-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .sidebar-item { width: auto; padding: 10px 14px; border-left: none; border-radius: 8px; }
  .sidebar-item.active { border-left: none; }
}

@media (max-width: 480px) {
  .fast-iptv-hero { flex-direction: column; text-align: center; }
  .fast-iptv-text { text-align: center; }
  .login-card { padding: 20px; }
  .content-list--grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
