/* =============================================
   LiveBD Stream — Main Stylesheet
   ============================================= */

:root {
  --bg:        #080810;
  --surface:   #10101a;
  --surface2:  #18182a;
  --surface3:  #222236;
  --border:    #2e2e48;
  --border2:   #3a3a58;
  --accent:    #e63946;
  --accent-h:  #c1121f;
  --accent2:   #f4a261;
  --text:      #eeeef5;
  --text2:     #a0a0c0;
  --text3:     #606080;
  --live:      #22c55e;
  --info:      #3b82f6;
  --radius:    8px;
  --radius-lg: 14px;
  --transition: 0.18s ease;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, select { font: inherit; }
img { max-width: 100%; display: block; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== LAYOUT ===== */
.app {
  display: grid;
  grid-template-rows: 54px 1fr;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ===== HEADER ===== */
.header {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 16px;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-mark {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.logo-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
}
.logo-name span { color: var(--accent); }

.live-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--live);
  letter-spacing: 0.8px;
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--live);
  border-radius: 50%;
  animation: livePulse 1.5s infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.header-ticker {
  flex: 1;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
}

.ticker-track {
  display: inline-flex;
  white-space: nowrap;
  animation: ticker 35s linear infinite;
  font-size: 13px;
  color: var(--text2);
  gap: 48px;
}

.ticker-track:hover { animation-play-state: paused; }

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.ticker-item { display: flex; align-items: center; gap: 6px; }
.ticker-sep { color: var(--border2); margin: 0 12px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  transition: all var(--transition);
  border: 1px solid transparent;
}
.btn-icon:hover {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}

.btn-login {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-login:hover { background: var(--accent-h); }

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px 8px 34px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }

.cat-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  transition: all var(--transition);
  border: 1px solid transparent;
}
.cat-tab:hover { color: var(--text); background: var(--surface2); }
.cat-tab.active {
  background: rgba(230,57,70,0.12);
  border-color: rgba(230,57,70,0.3);
  color: var(--accent);
}

/* Channel List */
.channel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.ch-section-label {
  padding: 10px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.ch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.ch-item:hover { background: var(--surface2); }
.ch-item.active {
  background: rgba(230,57,70,0.1);
}
.ch-item.active::after {
  content: '';
  position: absolute;
  right: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 3px 0 0 3px;
}

.ch-logo-wrap {
  width: 42px;
  height: 30px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text3);
}
.ch-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
}

.ch-info { flex: 1; min-width: 0; }
.ch-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  font-size: 11px;
  color: var(--text3);
}
.ch-status-dot {
  width: 5px;
  height: 5px;
  background: var(--live);
  border-radius: 50%;
}
.ch-status.offline .ch-status-dot { background: var(--text3); }

/* ===== MAIN PLAYER AREA ===== */
.main-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
}

/* Utility */
.hidden { display: none !important; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease;
  max-width: 300px;
}
.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.error { border-color: rgba(230,57,70,0.4); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  margin: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: background var(--transition);
  margin-top: 8px;
}
.btn-primary:hover { background: var(--accent-h); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 54px 1fr 200px;
  }
  .sidebar {
    order: 3;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .main-area { order: 2; }
  .ch-section-label { display: none; }
  .channel-scroll {
    display: flex;
    flex-direction: row;
    overflow-y: hidden;
    overflow-x: auto;
    padding: 8px;
    gap: 8px;
  }
  .ch-item {
    flex-direction: column;
    min-width: 80px;
    padding: 8px;
    border-radius: var(--radius);
    text-align: center;
  }
  .ch-item.active::after { display: none; }
  .ch-logo-wrap { width: 48px; height: 36px; }
  .header-ticker { display: none; }
}

@media (max-width: 480px) {
  .logo-name { font-size: 16px; }
}