/* ============================================
   V3 — Sport Dashboard / Data-first
   Spartaforever CMS — Production Styles
   ============================================ */

@import url("tokens.css");

:root {
  --bg-primary: #F0F2F5;
  --bg-secondary: #E8ECF0;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8FAFC;
  --bg-input: #FFFFFF;
  --bg-sidebar: #1A1F36;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --bg-header: #FFFFFF;

  --text-primary: #1A1F36;
  --text-secondary: #5A6478;
  --text-muted: #8B95A8;
  --text-accent: #C8102E;
  --text-on-dark: #E0E4EC;
  --text-on-dark-muted: #7B8399;

  --border-color: #D5DAE3;
  --border-focus: #C8102E;
  --border-subtle: #EEF0F4;

  --accent: #C8102E;
  --accent-hover: #A00E25;
  --accent-subtle: rgba(200, 16, 46, 0.1);
  --accent-gradient: linear-gradient(135deg, #C8102E 0%, #9B0D23 100%);
  --gold: #D4A843;
  --gold-subtle: rgba(212, 168, 67, 0.15);
  --navy: #1A1F36;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--leading-normal);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-hover); }
a:visited { color: var(--accent); }

/* ============ LOGIN ============ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image: linear-gradient(135deg, #1A1F36 0%, #2A1520 50%, #1A1F36 100%);
  padding: var(--space-md);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
}

.login-logo { text-align: center; margin-bottom: var(--space-xl); }
.login-logo .logo-text { font-size: var(--text-2xl); font-weight: var(--font-bold); color: var(--text-primary); }
.login-logo .logo-text span { color: var(--accent); }
.login-logo .logo-sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-xs); }
.login-logo .logo-badge {
  display: inline-block;
  background: var(--accent-gradient);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-full);
  margin-top: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.login-error {
  background: var(--error-light);
  color: var(--error);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-md);
  text-align: center;
}

/* ============ FORMS ============ */
.form-group { margin-bottom: var(--space-lg); }

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100%;
  padding: 0.7rem 0.875rem;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input::placeholder { color: var(--text-muted); }

textarea.form-input {
  min-height: 200px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.form-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-xs); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.form-grid .full { grid-column: 1 / -1; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(200, 16, 46, 0.4); }

.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 2px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--text-muted); }

.btn-ghost { background: transparent; color: var(--text-secondary); padding: 0.4rem 0.6rem; text-transform: none; }
.btn-ghost:hover { color: var(--text-primary); background: var(--border-subtle); }

.btn-sm { padding: 0.35rem 0.65rem; font-size: var(--text-xs); }
.btn-full { width: 100%; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-md); text-transform: none; }

/* ============ LAYOUT ============ */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sticky);
  transition: transform var(--transition-base);
}

.sidebar-header {
  padding: var(--space-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-logo { font-size: var(--text-lg); font-weight: var(--font-bold); color: #fff; text-decoration: none; }
.sidebar-logo span { color: var(--accent); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-md) 0; }
.nav-section { padding: 0 var(--space-md); margin-bottom: var(--space-md); }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: var(--font-bold);
  color: var(--text-on-dark-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0 var(--space-sm);
  margin-bottom: var(--space-xs);
}

.nav-item {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: 0.6rem var(--space-sm);
  border-radius: var(--radius-md);
  color: var(--text-on-dark);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }

.nav-item.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.3);
}

.nav-item .nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .nav-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  font-size: 0.65rem;
  font-weight: var(--font-bold);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-footer { padding: var(--space-md) var(--space-lg); border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-user { display: flex; align-items: center; gap: var(--space-sm); }

.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); font-weight: var(--font-bold);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: var(--text-sm); font-weight: var(--font-semibold); color: #fff; }
.user-role { font-size: var(--text-xs); color: var(--text-on-dark-muted); }

.sidebar-logout {
  display: inline-flex; align-items: center; gap: var(--space-xs);
  margin-top: var(--space-sm);
  font-size: var(--text-xs); color: var(--text-on-dark-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.sidebar-logout:hover { color: #fff; }
.sidebar-logout svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-header {
  position: sticky; top: 0;
  background: var(--bg-header);
  border-bottom: 2px solid var(--border-color);
  padding: 0 var(--space-xl);
  height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  z-index: var(--z-sticky);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.header-left { display: flex; align-items: center; gap: var(--space-md); }

.menu-toggle {
  display: none;
  width: 40px; height: 40px;
  background: none;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center; justify-content: center;
}
.menu-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

.breadcrumbs { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); color: var(--text-muted); }
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--text-primary); }
.breadcrumbs .separator { color: var(--text-muted); }
.breadcrumbs .current { color: var(--text-primary); font-weight: var(--font-bold); }

.header-right { display: flex; align-items: center; gap: var(--space-sm); }

/* ---- Page Content ---- */
.page-content { flex: 1; padding: var(--space-xl); max-width: var(--content-max-width); }
.page-title { font-size: var(--text-2xl); font-weight: var(--font-bold); margin-bottom: var(--space-xs); }
.page-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-bottom: var(--space-xl); }

/* ============ DASHBOARD ============ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); margin-bottom: var(--space-xl); }

.stat-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--accent-gradient);
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-sm); }
.stat-card .stat-icon { width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; }

.stat-icon.red { background: var(--accent-subtle); color: var(--accent); }
.stat-icon.green { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.12); color: var(--info); }
.stat-icon.yellow { background: var(--gold-subtle); color: var(--gold); }

.stat-icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.5; }

.stat-value { font-size: var(--text-3xl); font-weight: var(--font-bold); line-height: 1; }
.stat-label { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-xs); font-weight: var(--font-medium); }
.stat-change { font-size: var(--text-xs); margin-top: var(--space-xs); font-weight: var(--font-semibold); }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--error); }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); margin-bottom: var(--space-xl); }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-card-hover);
}

.card-title { font-size: var(--text-sm); font-weight: var(--font-bold); text-transform: uppercase; letter-spacing: 0.02em; }
.card-body { padding: var(--space-lg); }
.card-body.no-pad { padding: 0; }

/* ---- Online Editors ---- */
.online-list { list-style: none; }

.online-item {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
.online-item:last-child { border-bottom: none; }
.online-item:hover { background: var(--bg-card-hover); }

.online-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs); font-weight: var(--font-bold);
  position: relative; flex-shrink: 0;
}

.online-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-card);
}
.online-dot.online { background: var(--success); }
.online-dot.idle { background: var(--gold); }
.online-dot.away { background: var(--text-muted); }

.online-info { flex: 1; min-width: 0; }
.online-name { font-size: var(--text-sm); font-weight: var(--font-semibold); }
.online-activity { font-size: var(--text-xs); color: var(--text-muted); }

.online-meta { text-align: right; flex-shrink: 0; }
.online-time { font-size: var(--text-xs); color: var(--text-muted); }
.online-role { font-size: var(--text-xs); color: var(--accent); font-weight: var(--font-semibold); }

.online-stats-bar {
  display: flex; gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-card-hover);
}

.online-stat { text-align: center; flex: 1; }
.online-stat-value { font-size: var(--text-xl); font-weight: var(--font-bold); color: var(--accent); }
.online-stat-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-semibold); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---- Visitors on site ---- */
.visitors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-sm);
}

.visitor-stat {
  text-align: center;
  padding: var(--space-sm);
  background: var(--bg-card-hover);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
}

.visitor-stat-value { font-size: var(--text-xl); font-weight: var(--font-bold); color: var(--accent); line-height: 1; }
.visitor-stat-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-semibold); text-transform: uppercase; margin-top: 2px; }

.visitor-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}
.visitor-page:last-child { border-bottom: none; }
.visitor-page-url { color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--text-xs); }
.visitor-page-count { font-weight: var(--font-bold); color: var(--accent); font-size: var(--text-sm); }

/* ---- Quick Actions ---- */
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); }

.quick-action {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-card-hover);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm); font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.quick-action:hover { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent); }
.quick-action svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.5; }

/* ---- Horizontal Bar Chart ---- */
.vbar-row { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: 10px; }
.vbar-row:last-child { margin-bottom: 0; }
.vbar-label { width: 48px; flex-shrink: 0; font-size: var(--text-xs); font-weight: var(--font-bold); color: var(--text-secondary); text-align: right; text-transform: uppercase; }
.vbar-track { flex: 1; height: 28px; background: var(--bg-card-hover); border-radius: var(--radius-md); overflow: hidden; }
.vbar-fill { height: 100%; background: var(--accent-gradient); border-radius: var(--radius-md); min-width: 4px; transition: width 0.6s ease; }
.vbar-value { width: 40px; flex-shrink: 0; font-size: var(--text-sm); font-weight: var(--font-bold); color: var(--accent); text-align: right; }

/* ============ DATA TABLES ============ */
.data-table-wrapper {
  overflow-x: auto;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  padding: 0.75rem var(--space-md);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-card-hover);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem var(--space-md);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.article-title-cell { max-width: 300px; }
.article-title-link { font-weight: var(--font-semibold); color: var(--text-primary); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-title-link:hover { color: var(--accent); }
.article-category { font-size: var(--text-xs); color: var(--text-muted); }

.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-badge.published { background: rgba(16, 185, 129, 0.12); color: #059669; }
.status-badge.draft { background: #F1F5F9; color: var(--text-secondary); }
.status-badge.review { background: var(--gold-subtle); color: #B8860B; }
.status-dot { width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; }

/* ============ PAGINATION ============ */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md) 0; }
.pagination-info { font-size: var(--text-sm); color: var(--text-secondary); }
.pagination-buttons { display: flex; gap: var(--space-xs); }

.page-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent-gradient); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============ ARTICLE EDIT ============ */
.edit-layout { display: grid; grid-template-columns: 1fr 320px; gap: var(--space-xl); align-items: start; }
.edit-main .card { margin-bottom: var(--space-md); }

.form-section-title {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-card-hover);
}

.edit-sidebar .card { margin-bottom: var(--space-md); }

.publish-actions { display: flex; flex-direction: column; gap: var(--space-sm); }
.publish-status { display: flex; align-items: center; justify-content: space-between; padding: var(--space-sm) 0; }
.publish-status-label { font-size: var(--text-sm); color: var(--text-secondary); font-weight: var(--font-medium); }

.sticky-actions {
  position: sticky; bottom: 0;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  border-top: 2px solid var(--border-color);
  padding: var(--space-md) var(--space-xl);
  display: flex; align-items: center; justify-content: flex-end;
  gap: var(--space-sm);
  z-index: var(--z-sticky);
}

/* ============ FILTER CONTROLS ============ */
.list-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-md); margin-bottom: var(--space-md); flex-wrap: wrap;
}

.list-filters { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }

.filter-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%235A6478' stroke-width='2'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
.filter-select:focus { border-color: var(--accent); }

.search-input {
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  width: 240px;
}
.search-input:focus { border-color: var(--accent); }

/* ============ TOAST ============ */
.toast-container {
  position: fixed; top: var(--space-lg); right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-sm);
}

.toast {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  display: flex; align-items: center; gap: var(--space-sm);
  font-size: var(--text-sm); font-weight: var(--font-medium);
  min-width: 300px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.warning { border-left: 4px solid var(--gold); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: calc(var(--z-sticky) - 1); }
.overlay.active { display: block; }

/* ============ SYSTEM INFO ============ */
.system-info { font-size: var(--text-xs); color: var(--text-muted); }
.system-info dt { font-weight: var(--font-semibold); color: var(--text-secondary); }
.system-info dd { margin: 0 0 var(--space-xs) 0; }

/* ============ LEGACY COMPATIBILITY ============ */
/* Override inline bgcolor attributes from legacy PHP */
[bgcolor="#99ccff"],
[bgcolor="#cacaca"],
[bgcolor="#bebebe"] {
  background-color: var(--bg-card-hover) !important;
}

/* Legacy tables with border attribute */
table[border] {
  border-collapse: collapse;
  width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--border-color) !important;
  border-radius: var(--radius-md);
}

table[border] td,
table[border] th {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-subtle) !important;
  font-size: var(--text-sm);
}

table[border] th,
table[border] td[bgcolor] {
  background-color: var(--bg-card-hover) !important;
  font-weight: var(--font-semibold);
}

/* Legacy form elements */
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not(.btn):not(.form-input) {
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  font-weight: var(--font-medium);
  outline: none;
  transition: border-color var(--transition-fast);
}

input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not(.btn):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

select:not(.filter-select) {
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
}

select:not(.filter-select):focus {
  border-color: var(--accent);
}

textarea:not(.form-input) {
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  outline: none;
  width: 100%;
}

textarea:not(.form-input):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

input[type="submit"],
input[type="button"] {
  background: var(--accent-gradient) !important;
  color: #fff !important;
  border: none !important;
  border-radius: var(--radius-md) !important;
  padding: 0.6rem 1.25rem !important;
  font-weight: var(--font-bold) !important;
  font-family: var(--font-sans) !important;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: var(--text-sm) !important;
}

input[type="submit"]:hover,
input[type="button"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

/* Legacy headings inside page-content */
.page-content h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin: var(--space-lg) 0 var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border-color);
}

.page-content h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: var(--space-md) 0 var(--space-xs);
}

.page-content h4 {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  margin: var(--space-md) 0 var(--space-xs);
}

/* Legacy bold/strong text */
.page-content b,
.page-content strong {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* Legacy images */
.page-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

/* Legacy links in page content */
.page-content a:link,
.page-content a:visited {
  color: var(--accent);
  text-decoration: none;
}
.page-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Legacy spans with inline styles */
.page-content span[style*="font-weight: bold"],
.page-content span[style*="font-weight:bold"] {
  color: var(--text-primary);
}

/* Legacy <br> spacing */
.page-content br + br { display: none; }

/* Override old #page and #menu (no longer used) */
#menu { display: none !important; }
#page {
  position: static !important;
  width: auto !important;
  height: auto !important;
  left: auto !important;
  top: auto !important;
  padding: 0 !important;
  border: 0 !important;
  color: var(--text-primary) !important;
}

/* ============ DARK MODE ============ */
html.dark {
  --bg-primary: #0E1117;
  --bg-secondary: #161B26;
  --bg-card: #1C2333;
  --bg-card-hover: #232B3E;
  --bg-input: #161B26;
  --bg-header: rgba(14, 17, 23, 0.95);

  --text-primary: #E0E4EC;
  --text-secondary: #8B95A8;
  --text-muted: #5A6478;

  --border-color: #2A3346;
  --border-subtle: rgba(255, 255, 255, 0.05);

  --accent-subtle: rgba(200, 16, 46, 0.2);
  --gold-subtle: rgba(212, 168, 67, 0.2);
}

html.dark .login-wrapper { background-image: linear-gradient(135deg, #0E1117 0%, #2A1520 50%, #0E1117 100%); }
html.dark .login-card { box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6); }

html.dark .stat-card { border-color: var(--border-color); }
html.dark .card { border-color: var(--border-color); }
html.dark .card-header { background: var(--bg-secondary); border-color: var(--border-color); }

html.dark .top-header { background: var(--bg-header); backdrop-filter: blur(12px); border-color: var(--border-color); box-shadow: none; }

html.dark .data-table th { background: var(--bg-secondary); border-color: var(--border-color); }
html.dark .data-table-wrapper { border-color: var(--border-color); background: var(--bg-card); }

html.dark .filter-select { background-color: var(--bg-card); border-color: var(--border-color); color: var(--text-primary); }
html.dark .search-input { background: var(--bg-card); border-color: var(--border-color); color: var(--text-primary); }

html.dark .form-input { background: var(--bg-input); border-color: var(--border-color); color: var(--text-primary); }
html.dark .form-section-title { background: var(--bg-secondary); border-color: var(--border-color); }

html.dark .quick-action { background: var(--bg-secondary); border-color: var(--border-color); }
html.dark .quick-action:hover { background: var(--accent-subtle); border-color: var(--accent); }

html.dark .status-badge.published { background: rgba(16, 185, 129, 0.15); }
html.dark .status-badge.draft { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }
html.dark .status-badge.review { background: var(--gold-subtle); }

html.dark .btn-secondary { background: var(--bg-card); border-color: var(--border-color); color: var(--text-primary); }
html.dark .btn-secondary:hover { background: var(--bg-card-hover); }

html.dark .page-btn { background: var(--bg-card); border-color: var(--border-color); color: var(--text-secondary); }

html.dark .sticky-actions { background: var(--bg-header); backdrop-filter: blur(12px); border-color: var(--border-color); }

html.dark .toast { background: var(--bg-card); border-color: var(--border-color); }
html.dark .menu-toggle { border-color: var(--border-color); color: var(--text-secondary); }

html.dark .vbar-track { background: var(--bg-secondary); }
html.dark .visitor-stat { background: var(--bg-secondary); border-color: var(--border-color); }

/* Dark mode for legacy elements */
html.dark table[border] { background: var(--bg-card); border-color: var(--border-color) !important; }
html.dark table[border] td,
html.dark table[border] th { border-color: var(--border-color) !important; }
html.dark table[border] th,
html.dark table[border] td[bgcolor] { background-color: var(--bg-secondary) !important; }

html.dark [bgcolor="#99ccff"],
html.dark [bgcolor="#cacaca"],
html.dark [bgcolor="#bebebe"] {
  background-color: var(--bg-secondary) !important;
}

html.dark input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not(.btn):not(.form-input) {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
}

html.dark select:not(.filter-select) {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-primary);
}

html.dark textarea:not(.form-input) {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
}

html.dark input[type="submit"],
html.dark input[type="button"] {
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.2);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .edit-layout { grid-template-columns: 1fr; }
  .edit-sidebar { order: -1; }
}

@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .top-header { padding: 0 var(--space-md); }
  .page-content { padding: var(--space-md); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .list-toolbar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .sticky-actions { padding: var(--space-md); }
  .online-stats-bar { flex-wrap: wrap; }
}

@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
}
