/* ============================================
   Admin Panel - Modern Responsive CSS
   Supports: Light / Dark Mode, Mobile / Desktop
   ============================================ */

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: #eef2ff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --info: #0891b2;
  --info-soft: #e0f2fe;

  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --card-bg: #ffffff;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #6366f1;
  --sidebar-hover: rgba(99,102,241,0.15);
  --topbar-bg: #ffffff;

  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);

  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --card-bg: #1e293b;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #6366f1;
  --topbar-bg: #1e293b;

  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
  --primary-soft: rgba(99,102,241,0.15);
  --success-soft: rgba(22,163,74,0.15);
  --danger-soft: rgba(220,38,38,0.15);
  --warning-soft: rgba(217,119,6,0.15);
  --info-soft: rgba(8,145,178,0.15);
}

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

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== AUTH PAGES ===== */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo svg { margin-bottom: 12px; }
.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.auth-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.theme-toggle-wrap { text-align: center; margin-top: 20px; }
.theme-btn {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  padding: 6px 16px; border-radius: 20px; cursor: pointer; font-size: 13px;
  transition: all var(--transition);
}
.theme-btn:hover { background: var(--bg-secondary); }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-width);
  height: 100vh; background: var(--sidebar-bg); display: flex;
  flex-direction: column; z-index: 100; transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; }
.sidebar-close { display: none; background: none; border: none; color: var(--sidebar-text); font-size: 18px; cursor: pointer; padding: 4px 8px; }

.nav-list { list-style: none; padding: 12px 8px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); color: var(--sidebar-text); font-size: 14px;
  font-weight: 500; cursor: pointer; transition: all var(--transition); margin-bottom: 2px;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-logout { color: #f87171 !important; }
.nav-logout:hover { background: rgba(248,113,113,0.15) !important; color: #f87171 !important; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,0.08); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99;
}

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

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.menu-btn { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 6px; border-radius: var(--radius-sm); }
.menu-btn:hover { background: var(--bg-secondary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-btn { background: none; border: 1px solid var(--border); padding: 7px; border-radius: 8px; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; transition: all var(--transition); }
.icon-btn:hover { background: var(--bg-secondary); color: var(--text); }
.admin-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.admin-name { font-size: 14px; font-weight: 500; color: var(--text); }

/* ===== PAGE BODY ===== */
.page-body { flex: 1; padding: 24px; max-width: 1400px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 22px; font-weight: 700; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow);
}
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== CARD ===== */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px; }
.card-header h3 { font-size: 15px; font-weight: 600; }

.row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-secondary); }
th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
td { padding: 12px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-secondary); }
.text-mono { font-family: monospace; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 6px; padding: 16px; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); color: var(--text); font-size: 13px; transition: all var(--transition); }
.page-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft); color: var(--info); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition); white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-secondary); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-full { width: 100%; justify-content: center; padding: 11px; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }
.action-btns { display: flex; gap: 4px; flex-wrap: wrap; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 14px; transition: border-color var(--transition);
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-group select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-footer { display: flex; gap: 10px; margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }

.input-eye { position: relative; }
.input-eye input { padding-right: 40px; }
.eye-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; }

.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-form input { padding: 7px 12px; }

/* ===== MODAL ===== */
.modal { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); }
.modal-box {
  background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px; position: relative; z-index: 1;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(0.95) translateY(-10px); } to { opacity:1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--card-bg); z-index: 1; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-header button { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 2px 8px; border-radius: 4px; }
.modal-header button:hover { background: var(--bg-secondary); }
.modal-box form, .modal-box > div:not(.modal-header):not(.modal-footer) { padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #86efac; }
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border: 1px solid #fca5a5; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid #fcd34d; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 20px;
  border-radius: var(--radius-sm); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 9999; transform: translateY(80px);
  transition: transform 0.3s ease, opacity 0.3s ease; opacity: 0; pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ===== SETTINGS ===== */
.settings-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; padding: 16px 20px; }
.quick-action-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 28px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-secondary); cursor: pointer; color: var(--text); font-size: 13px;
  transition: all var(--transition); font-family: inherit;
}
.quick-action-btn span:first-child { font-size: 24px; }
.quick-action-btn:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); text-decoration: none; }

/* ===== UTILITY ===== */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-mono { font-family: 'Courier New', monospace; }
hr { border: none; border-top: 1px solid var(--border); }

code {
  background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px;
  font-family: 'Courier New', monospace; font-size: 12px; color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .row-2col { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-btn { display: flex; }
  .admin-name { display: none; }
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .search-form { width: 100%; }
  .search-form input { flex: 1; min-width: 0; }
  th:nth-child(n+5) { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
  .modal-box { border-radius: 12px 12px 0 0; position: fixed; bottom: 0; left: 0; right: 0; max-height: 85vh; margin: 0; max-width: 100%; }
  .modal { align-items: flex-end; padding: 0; }
}
