* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #0a0a0a; min-height: 100vh; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.iptv-layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.iptv-sidebar {
  width: 340px; min-width: 340px; height: 100vh;
  background: #111; border-right: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column;
}
.iptv-sidebar-header {
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
  background: #141414; flex-shrink: 0;
}
.iptv-sidebar-header h2 { color: #fff; font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; }
.iptv-sidebar-header input[type="text"] {
  width: 100%; padding: 8px 12px; background: #1e1e1e; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; color: #fff; font-size: 0.85rem; outline: none;
}
.iptv-sidebar-header input[type="text"]:focus { border-color: #e50914; }
.iptv-sidebar-header input[type="text"]::placeholder { color: #666; }

.iptv-tabs {
  display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.04);
  overflow-x: auto; flex-shrink: 0;
}
.iptv-tabs::-webkit-scrollbar { height: 0; }
.iptv-tab {
  padding: 5px 12px; border-radius: 6px; font-size: 0.75rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; border: none; background: transparent; color: #888;
}
.iptv-tab.active { background: #e50914; color: #fff; }
.iptv-tab:hover:not(.active) { background: rgba(255,255,255,0.06); color: #ccc; }

.iptv-channel-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.iptv-channel-list::-webkit-scrollbar { width: 4px; }
.iptv-channel-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.iptv-channel-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  cursor: pointer; transition: background 0.15s; border-left: 3px solid transparent;
}
.iptv-channel-item:hover { background: rgba(255,255,255,0.04); }
.iptv-channel-item.active { background: rgba(229,9,20,0.12); border-left-color: #e50914; }
.iptv-channel-item img { width: 32px; height: 32px; border-radius: 6px; object-fit: contain; background: #1a1a1a; flex-shrink: 0; }
.iptv-channel-item .ch-info { flex: 1; min-width: 0; }
.iptv-channel-item .ch-name { color: #ddd; font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iptv-channel-item .ch-group { color: #666; font-size: 0.7rem; margin-top: 2px; }
.iptv-channel-item .ch-status { width: 6px; height: 6px; border-radius: 50%; background: #333; flex-shrink: 0; }
.iptv-channel-item.active .ch-status { background: #e50914; }

.iptv-empty { color: #555; text-align: center; padding: 40px 20px; font-size: 0.85rem; }

/* Player area */
.iptv-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.iptv-player-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #111; border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.iptv-player-header .header-left { display: flex; align-items: center; gap: 10px; }
.iptv-player-header .header-left a { color: #888; text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.iptv-player-header .header-left a:hover { color: #fff; }
.iptv-player-header .ch-title { color: #fff; font-size: 0.95rem; font-weight: 700; }
.iptv-player-header .live-badge {
  background: #e50914; color: #fff; font-size: 0.65rem; font-weight: 800;
  padding: 3px 8px; border-radius: 6px; letter-spacing: 0.5px;
}

.iptv-player-wrap {
  flex: 1; position: relative; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.iptv-player-wrap video,
.iptv-player-wrap iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;
}
.player-overlay {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  color: rgba(255,255,255,0.5); font-size: 0.9rem; text-align: center; z-index: 10;
}
.player-overlay .spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,0.1); border-top-color: #e50914;
  border-radius: 50%; animation: iptvSpin 0.8s linear infinite; margin-bottom: 12px;
}
@keyframes iptvSpin { to { transform: rotate(360deg); } }
.player-overlay.error { color: #ff4444; }

/* Config panel */
.iptv-config {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}
.iptv-config-box {
  background: #1a1a1a; border: 1px solid rgba(255,255,255,0.08); border-radius: 16px;
  padding: 28px; width: 90%; max-width: 480px;
}
.iptv-config-box h3 { color: #fff; font-size: 1.1rem; margin-bottom: 18px; }
.iptv-config-box label { display: block; color: #888; font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; margin-top: 12px; }
.iptv-config-box input[type="text"],
.iptv-config-box input[type="url"],
.iptv-config-box input[type="password"],
.iptv-config-box textarea {
  width: 100%; padding: 10px 14px; background: #111; border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; color: #fff; font-size: 0.85rem; outline: none; font-family: inherit;
}
.iptv-config-box textarea { min-height: 80px; resize: vertical; }
.iptv-config-box input:focus, .iptv-config-box textarea:focus { border-color: #e50914; }
.iptv-config-box .btn-row { display: flex; gap: 8px; margin-top: 20px; }
.iptv-config-box .btn {
  flex: 1; padding: 10px; border: none; border-radius: 8px; font-size: 0.85rem; font-weight: 700;
  cursor: pointer; transition: opacity 0.2s;
}
.iptv-config-box .btn:hover { opacity: 0.85; }
.iptv-config-box .btn-primary { background: #e50914; color: #fff; }
.iptv-config-box .btn-secondary { background: #333; color: #ccc; }
.iptv-config-box .divider { text-align: center; color: #555; font-size: 0.75rem; margin: 14px 0; text-transform: uppercase; letter-spacing: 1px; }

.config-toggle {
  position: fixed; bottom: 16px; right: 16px; z-index: 99;
  background: #333; color: #aaa; border: none; border-radius: 50%; width: 44px; height: 44px;
  font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.config-toggle:hover { background: #444; color: #fff; }

@media (max-width: 768px) {
  .iptv-layout { flex-direction: column; }
  .iptv-sidebar { width: 100%; height: 45vh; min-width: 0; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.06); }
  .iptv-main { height: 55vh; }
}
