/* ===== CSS VARIABLES & THEME ===== */
:root {
  --sidebar-bg:       #1a1d2e;
  --sidebar-text:     #94a3b8;
  --sidebar-hover:    #242842;
  --sidebar-active:   #3b82f6;
  --sidebar-active-bg:#1e3a5f;
  --topbar-bg:        #ffffff;
  --topbar-border:    #e2e8f0;
  --bg-body:          #f1f5f9;
  --bg-card:          #ffffff;
  --text-primary:     #1e293b;
  --text-muted:       #64748b;
  --border-color:     #e2e8f0;
  --input-bg:         #ffffff;
  --input-border:     #cbd5e1;
  --hover-bg:         #f8fafc;
  --shadow:           0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg:        0 4px 20px rgba(0,0,0,0.10);
  --sidebar-width:    260px;
  --topbar-height:    64px;
}
[data-theme="dark"] {
  --sidebar-bg:       #0f1117;
  --sidebar-text:     #64748b;
  --sidebar-hover:    #1a1d2e;
  --sidebar-active:   #3b82f6;
  --sidebar-active-bg:#1e2847;
  --topbar-bg:        #1a1d2e;
  --topbar-border:    #2d3748;
  --bg-body:          #0f1117;
  --bg-card:          #1a1d2e;
  --text-primary:     #e2e8f0;
  --text-muted:       #64748b;
  --border-color:     #2d3748;
  --input-bg:         #242842;
  --input-border:     #3d4f70;
  --hover-bg:         #242842;
  --shadow:           0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg:        0 4px 20px rgba(0,0,0,0.4);
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  margin: 0;
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
}
a { color: var(--sidebar-active); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-brand {
  display: flex; align-items: center;
  font-size: 1.15rem; font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
}
.sidebar-close { color: #64748b; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-section {
  padding: 8px 20px 4px;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.1em;
  color: #475569;
  text-transform: uppercase;
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #f1f5f9; text-decoration: none; }
.sidebar-link.active { background: var(--sidebar-active-bg); color: #fff; border-left-color: var(--sidebar-active); }
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; }

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left 0.3s;
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky; top: 0; z-index: 1040;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-toggle { background: none; border: none; padding: 6px; cursor: pointer; color: var(--text-muted); border-radius: 8px; }
.topbar-toggle:hover { background: var(--hover-bg); color: var(--text-primary); }
.breadcrumb { font-size: 0.85rem; }
.breadcrumb-item a { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-primary); }

.theme-toggle { background: none; border: 1px solid var(--border-color); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--text-muted); }
.theme-toggle:hover { background: var(--hover-bg); color: var(--text-primary); }
.user-btn { background: none; border: 1px solid var(--border-color); border-radius: 8px; padding: 6px 12px; color: var(--text-primary); }
.user-btn:hover { background: var(--hover-bg); }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; padding: 28px; max-width: 1600px; width: 100%; }
.app-footer { text-align: center; padding: 16px 28px; font-size: 0.85rem; color: #94a3b8; border-top: 1px solid #e2e8f0; }
.app-footer a { color: #3b82f6; text-decoration: none; font-weight: 600; }
.app-footer a:hover { text-decoration: underline; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.4rem; font-weight: 700; margin: 0; color: var(--text-primary); }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  display: flex; align-items: center;
}
.card-body { padding: 20px; }
.card-footer { background: transparent; border-top: 1px solid var(--border-color); padding: 12px 20px; }

/* ===== STATS ===== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; font-size: 1.3rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--text-primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.stat-card.mini { padding: 12px; }

/* ===== COLOR HELPERS ===== */
.bg-primary-soft { background: rgba(59,130,246,0.12); }
.bg-success-soft { background: rgba(34,197,94,0.12); }
.bg-info-soft    { background: rgba(14,165,233,0.12); }
.bg-warning-soft { background: rgba(234,179,8,0.12); }
.bg-danger-soft  { background: rgba(239,68,68,0.12); }
.bg-purple-soft  { background: rgba(168,85,247,0.12); }
.text-purple { color: #a855f7; }

/* ===== TABLES ===== */
.table { color: var(--text-primary); }
.table thead th { background: var(--hover-bg); border-color: var(--border-color); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 12px 16px; }
.table td, .table th { border-color: var(--border-color); padding: 12px 16px; vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--hover-bg); }

/* ===== STATUS DOTS ===== */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); animation: pulse-online 2s infinite; }
.status-dot.offline { background: #64748b; }
@keyframes pulse-online { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* ===== FORMS ===== */
.form-control, .form-select {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
  border-radius: 8px;
}
.form-control:focus, .form-select:focus {
  background: var(--input-bg);
  border-color: #3b82f6;
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }
.input-group-text { background: var(--hover-bg); border-color: var(--input-border); color: var(--text-muted); }
.form-label { font-size: 0.87rem; font-weight: 500; margin-bottom: 6px; color: var(--text-primary); }
.form-text { color: var(--text-muted); font-size: 0.8rem; }
.form-check-input { border-color: var(--input-border); background-color: var(--input-bg); }

/* ===== BUTTONS ===== */
.btn { border-radius: 8px; font-size: 0.9rem; }
.btn-xs { padding: 3px 8px; font-size: 0.78rem; border-radius: 6px; }
.btn-primary { background: #3b82f6; border-color: #3b82f6; }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-outline-secondary { border-color: var(--border-color); color: var(--text-muted); }
.btn-outline-secondary:hover { background: var(--hover-bg); color: var(--text-primary); border-color: var(--border-color); }
.btn-group-sm .btn { padding: 4px 8px; font-size: 0.8rem; }

/* ===== BADGES ===== */
.badge { border-radius: 6px; font-weight: 500; }

/* ===== DROPDOWN MENUS ===== */
.dropdown-menu { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: var(--shadow-lg); }
.dropdown-item { color: var(--text-primary); font-size: 0.9rem; }
.dropdown-item:hover { background: var(--hover-bg); color: var(--text-primary); }
.dropdown-divider { border-color: var(--border-color); }

/* ===== LOGIN PAGE ===== */
.login-page { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 440px; padding: 20px; }
.login-card { background: var(--bg-card); border-radius: 20px; padding: 40px; box-shadow: 0 25px 50px rgba(0,0,0,0.3); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { width: 72px; height: 72px; background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 2rem; color: #fff; padding: 12px; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand-logo { width: 28px; height: 28px; object-fit: contain; }
.login-title { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; }
.login-footer { text-align: center; margin-top: 24px; }

/* ===== UPLOAD ZONE ===== */
.upload-zone { border: 2px dashed var(--border-color); border-radius: 12px; transition: all 0.2s; cursor: pointer; }
.upload-zone.dragover, .upload-zone:hover { border-color: #3b82f6; background: rgba(59,130,246,0.04); }
.upload-zone-inner { text-align: center; padding: 40px 20px; }
.upload-item { background: var(--hover-bg); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.upload-item-info { display: flex; justify-content: space-between; align-items: center; }
.upload-item-name { font-size: 0.85rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.upload-item-size { font-size: 0.78rem; color: var(--text-muted); flex-shrink: 0; }

/* ===== PLAYLIST ITEMS ===== */
.playlist-sortable { min-height: 60px; }
.playlist-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--hover-bg); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--border-color);
  cursor: default;
}
.playlist-item.dragging { opacity: 0.5; border: 2px dashed #3b82f6; }
.playlist-item-drag { cursor: grab; color: var(--text-muted); padding: 4px; flex-shrink: 0; }
.playlist-item-drag:active { cursor: grabbing; }
.playlist-item-thumb { width: 60px; height: 40px; border-radius: 6px; overflow: hidden; background: #0f172a; flex-shrink: 0; }
.playlist-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-thumb { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #3b82f6; font-size: 1.4rem; }
.playlist-item-info { flex: 1; min-width: 0; }
.playlist-item-name { font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-item-meta { margin-top: 4px; }
.duration-input { max-width: 110px; }
.playlist-item-actions { flex-shrink: 0; }

/* ===== MEDIA GRID ===== */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px; }
.media-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; overflow: hidden; }
.media-thumb { height: 120px; background: #0f172a; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-video-thumb { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #3b82f6; font-size: 2rem; gap: 6px; }
.media-info { padding: 10px 12px; }
.media-name { font-size: 0.8rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-screen { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* ===== POSITION GRID ===== */
.position-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 300px; }
.position-option { background: var(--hover-bg); border: 2px solid var(--border-color); border-radius: 8px; padding: 10px 14px; font-size: 0.85rem; cursor: pointer; text-align: center; transition: all 0.15s; }
.position-option:hover { border-color: #3b82f6; }
.position-option.active { background: rgba(59,130,246,0.1); border-color: #3b82f6; color: #3b82f6; font-weight: 600; }

/* ===== QUICK ACTION CARDS ===== */
.quick-action-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px 10px; text-decoration: none; color: var(--text-muted); transition: all 0.2s; }
.quick-action-card:hover { border-color: #3b82f6; color: #3b82f6; background: rgba(59,130,246,0.05); transform: translateY(-2px); text-decoration: none; }
.quick-action-card span { font-size: 0.85rem; font-weight: 500; }

/* ===== INFO BOX ===== */
.info-box { background: var(--hover-bg); border-radius: 8px; padding: 12px; }
.info-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.info-val { font-size: 0.95rem; font-weight: 600; }

/* ===== LOGO PREVIEW ===== */
.logo-preview-screen { background: #1a1a2e; border-radius: 8px; aspect-ratio: 16/9; position: relative; overflow: hidden; }
.logo-preview-content { position: absolute; }

/* ===== TICKER PREVIEW ===== */
.ticker-preview { overflow: hidden; border-radius: 4px; display: flex; align-items: center; padding: 0 12px; white-space: nowrap; }

/* ===== WIDGET PREVIEW ===== */
.widget-preview-area { background: #1a1a2e; border-radius: 8px; aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; }

/* ===== AVATAR ===== */
.avatar-circle { width: 72px; height: 72px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 700; }

/* ===== ALERTS ===== */
.alert { border-radius: 10px; }

/* ===== TOAST ===== */
.toast { border-radius: 10px; }

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1049; display: none; }
.sidebar-overlay.show { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
}
@media (max-width: 575.98px) {
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); }
}
