/* ===== Variables ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #0f172a;
  --bg-input: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --radius: 8px;
  --sidebar-width: 260px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
.hidden { display: none !important; }

/* ===== Login ===== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}
.login-box {
  background: var(--bg-card);
  padding: 48px 40px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 2rem; margin-bottom: 4px; }
.login-logo p { color: var(--text-muted); }

/* ===== Form ===== */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.error-msg { color: var(--danger); font-size: 0.875rem; margin-bottom: 12px; min-height: 20px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--bg-input); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }

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

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}
.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 1.25rem; }
.admin-role {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
}
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-muted);
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(99, 102, 241, 0.1); color: var(--text); }
.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  border-left-color: var(--primary);
}
.nav-icon { font-size: 1.2rem; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px 0; border-top: 1px solid var(--border); }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.top-bar h1 { font-size: 1.5rem; }
.top-bar-actions { display: flex; align-items: center; gap: 16px; }
.content { flex: 1; padding: 32px; }

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.875rem; }
.stat-card .stat-change { font-size: 0.8rem; margin-top: 4px; }
.stat-card .stat-change.positive { color: var(--success); }
.stat-card .stat-change.negative { color: var(--danger); }

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1.1rem; }
.card-body { padding: 24px; }

/* ===== Table ===== */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-input);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
}
td { font-size: 0.9rem; }
tr:hover { background: rgba(99, 102, 241, 0.05); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-active { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-inactive { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-pending { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge-info { background: rgba(59, 130, 246, 0.2); color: var(--info); }
.badge-pro { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}
.pagination-info { color: var(--text-muted); font-size: 0.875rem; }
.pagination-buttons { display: flex; gap: 8px; }
.pagination-buttons button {
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}
.pagination-buttons button:hover { background: var(--primary); }
.pagination-buttons button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Filters ===== */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filters input, .filters select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--bg-card);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius);
  color: white;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  min-width: 280px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Toggle Switch ===== */
.toggle {
  position: relative;
  width: 48px;
  height: 24px;
  display: inline-block;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-input);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(24px); }

/* ===== Force Update Banner ===== */
.force-update-banner {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  padding: 24px;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 24px;
}
.force-update-banner h3 { font-size: 1.25rem; margin-bottom: 8px; }
.force-update-banner p { opacity: 0.9; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
