:root {
  --bg: #0d0d10;
  --bg-alt: #17171c;
  --card: #1f1f26;
  --orange: #ff7a00;
  --text: #f2f2f2;
  --gray: #9a9aa2;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { height: 100vh; }

/* Login */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1b1b22, #08080a);
}

.login-box {
  background: var(--bg-alt);
  padding: 32px 36px;
  border-radius: 12px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.login-logo {
  display: block;
  max-height: 120px;
  margin: 0 auto 16px;
}

.login-box label {
  font-size: 12px;
  color: var(--gray);
  margin-top: 8px;
}

.login-box input {
  background: #0d0d10;
  border: 1px solid #333;
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.login-box input:focus { border-color: var(--orange); }

.error-text {
  color: #ff5252;
  font-size: 13px;
  margin: 8px 0 0;
}

.login-box button {
  margin-top: 20px;
  padding: 12px;
  border: none;
  border-radius: 6px;
  background: var(--orange);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.login-box button:disabled { opacity: 0.6; cursor: default; }
.login-box button:hover:not(:disabled) { background: #ff8f26; }

/* Main */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-alt);
  border-bottom: 1px solid #2a2a30;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  height: 52px;
  display: block;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.topbar button {
  background: transparent;
  border: 1px solid #444;
  color: var(--gray);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
.topbar button:hover { border-color: var(--orange); color: var(--orange); }

#main-screen {
  display: flex;
  flex-direction: column;
}

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-alt);
  border-right: 1px solid #2a2a30;
}

.sidebar input[type="search"] {
  margin: 12px 12px 8px;
  background: #0d0d10;
  border: 1px solid #333;
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}
.sidebar input[type="search"]:focus { border-color: var(--orange); }

.categories {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  overflow-x: auto;
  flex-shrink: 0;
}

.categories .cat-item {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--gray);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: 14px;
  background: #22222a;
}

.categories .cat-item:hover { color: var(--text); }
.categories .cat-item.active { background: var(--orange); color: #fff; }

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
  gap: 10px;
}

.player-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.cast-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  z-index: 2;
  --connected-color: var(--orange);
  --disconnected-color: #fff;
}

.cast-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--text);
  text-align: center;
}

.cast-status strong { color: var(--orange); }

.cast-status button {
  background: transparent;
  border: 1px solid #555;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
}
.cast-status button:hover { border-color: var(--orange); color: var(--orange); }

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  font-size: 14px;
  pointer-events: none;
}

.player-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 24px;
  background: rgba(0, 0, 0, 0.75);
  color: #ff8a8a;
  font-size: 14px;
  pointer-events: none;
}

.epg-box {
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 10px 14px;
  flex-shrink: 0;
}
.epg-box strong { color: var(--orange); font-size: 14px; }
.epg-box span { margin-left: 10px; color: var(--gray); font-size: 12px; }
.epg-box p { margin: 6px 0 0; font-size: 12px; color: var(--gray); }

.epg-progress {
  height: 3px;
  background: #333;
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
#epg-progress-bar { height: 100%; background: var(--orange); width: 0%; }

.channel-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 12px;
}

.channel-card {
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  text-align: left;
}

.channel-card:hover { background: #22222a; }
.channel-card.playing { border-color: var(--orange); background: #2a2016; }

.channel-card img {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  object-fit: contain;
  background: #101014;
  border-radius: 6px;
}

.channel-avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, #444, #222);
}

.channel-card .name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--gray);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.fav-btn:hover { color: var(--orange); }
.fav-btn.active { color: var(--orange); }

.empty-msg {
  color: var(--gray);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}
