/* =============================================================
   admin.css - Admin Panel Styles
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  --primary:       #1b5e20;
  --primary-mid:   #2e7d32;
  --primary-light: #43a047;
  --primary-pale:  #e8f5e9;
  --sidebar-bg:    #2a4a2e;
  --sidebar-text:  rgba(255,255,255,.82);
  --sidebar-hover: rgba(255,255,255,.09);
  --sidebar-active:#388e3c;
  --font:          'Sarabun', sans-serif;
  --text-dark:     #1a2e1a;
  --text-body:     #2d3a2d;
  --text-muted:    #607060;
  --border:        #c8dac8;
  --border-light:  #e2ede2;
  --bg-page:       #f4f7f4;
  --radius-sm:     6px;
  --radius-md:     10px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.07);
  --shadow-md:     0 4px 12px rgba(0,0,0,.09);
  --transition:    all .2s ease;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text-body);
  background: var(--bg-page);
  min-height: 100vh;
}

/* ---- Admin Layout ---- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #2a4a2e 0%, #1e3b22 60%, #183018 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  transition: var(--transition);
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sidebar-brand .brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 50%;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}

.sidebar-brand .brand-text h2 {
  color: #fff;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand .brand-text span {
  color: rgba(255,255,255,.55);
  font-size: .75rem;
}

.sidebar-nav {
  padding: .75rem 0;
  flex: 1;
}

.nav-section-label {
  padding: .9rem 1rem .3rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .9rem;
  transition: var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: rgba(46,125,50,.25);
  color: #fff;
  border-left-color: var(--primary-light);
  font-weight: 600;
}

.sidebar-link .link-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer .sidebar-link {
  border-radius: var(--radius-sm);
  border-left: none;
  color: rgba(255,100,100,.8);
}

.sidebar-footer .sidebar-link:hover { background: rgba(255,0,0,.1); color: #ff6b6b; }

/* ---- Main Content ---- */
.admin-main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  background: #ffffff;
  border-bottom: 1px solid #e8f0e8;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(46,125,50,.07);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  color: var(--text-muted);
}

.topbar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-mid);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
}

.admin-content {
  padding: 1.5rem;
  flex: 1;
}

/* ---- Stats Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.green  { background: #e8f5e9; }
.stat-icon.blue   { background: #e3f2fd; }
.stat-icon.purple { background: #f3e5f5; }
.stat-icon.orange { background: #fff3e0; }
.stat-icon.teal   { background: #e0f2f1; }

.stat-info .stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--primary-pale);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  flex: 1;
}

.card-body { padding: 1.25rem; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.data-table th {
  background: var(--primary-pale);
  color: var(--primary);
  font-weight: 700;
  padding: .65rem .85rem;
  text-align: left;
  border-bottom: 2px solid var(--primary-light);
  white-space: nowrap;
}

.data-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--primary-pale); }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .35rem;
  color: var(--text-dark);
}

.form-control {
  width: 100%;
  padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .92rem;
  color: var(--text-body);
  background: #fff;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(67,160,71,.15);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary-mid); color: #fff; border-color: var(--primary-mid); }
.btn-primary:hover { background: var(--primary); color: #fff; text-decoration: none; }

.btn-outline { background: transparent; color: var(--primary-mid); border-color: var(--primary-mid); }
.btn-outline:hover { background: var(--primary-pale); text-decoration: none; }

.btn-danger { background: #c62828; color: #fff; border-color: #c62828; }
.btn-danger:hover { background: #b71c1c; color: #fff; text-decoration: none; }

.btn-warning { background: #f57f17; color: #fff; border-color: #f57f17; }
.btn-warning:hover { background: #e65100; color: #fff; text-decoration: none; }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
}

.badge-green  { background: #e8f5e9; color: #1b5e20; }
.badge-gray   { background: #f5f5f5; color: #616161; }
.badge-red    { background: #ffebee; color: #b71c1c; }
.badge-blue   { background: #e3f2fd; color: #0d47a1; }
.badge-orange { background: #fff3e0; color: #e65100; }

/* ---- Alert ---- */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  font-size: .9rem;
  margin-bottom: 1rem;
}

.alert-success { background: #e8f5e9; border-color: #2e7d32; color: #1b5e20; }
.alert-error   { background: #ffebee; border-color: #c62828; color: #b71c1c; }
.alert-info    { background: #e3f2fd; border-color: #1565c0; color: #0d47a1; }
.alert-warning { background: #fff8e1; border-color: #f57f17; color: #e65100; }

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 30%, rgba(99,102,241,.25) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 70%, rgba(168,85,247,.20) 0%, transparent 50%),
    linear-gradient(135deg, #1e3a8a 0%, #1e40af 30%, #4f46e5 60%, #7c3aed 85%, #6d28d9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

/* Decorative circles */
.login-page::before,
.login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.login-page::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(99,102,241,.18) 0%, transparent 70%);
  top: -160px; left: -160px;
}
.login-page::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(168,85,247,.15) 0%, transparent 70%);
  bottom: -120px; right: -120px;
}

.login-card {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow:
    0 4px 24px rgba(46,125,50,.10),
    0 1px 4px rgba(0,0,0,.06),
    inset 0 1px 0 rgba(255,255,255,.8);
  border: 1px solid rgba(200,230,201,.6);
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 0 auto 1rem;
  display: block;
  border-radius: 50%;
}

.login-title {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.75rem;
  line-height: 1.4;
}

/* ---- Chart Container ---- */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

.chart-container-lg {
  position: relative;
  width: 100%;
  height: 360px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ---- Score Bars ---- */
.score-bar-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .65rem;
}

.score-bar-label {
  font-size: .82rem;
  color: var(--text-muted);
  width: 200px;
  flex-shrink: 0;
  line-height: 1.3;
}

.score-bar-track {
  flex: 1;
  height: 10px;
  background: var(--border-light);
  border-radius: 99px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .8s ease;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
}

.score-bar-value {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-dark);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
}

/* ---- Responsive ---- */
@media (max-width: 992px) {
  .admin-sidebar { width: 200px; }
  .admin-main { margin-left: 200px; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-content { padding: 1rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 2rem 1.25rem; }
}

/* =============================================================
   Admin Theme Support
   ============================================================= */

/* ---- Dark Mode for Admin ---- */
[data-theme="dark"] body {
  background: #0e1a0e;
  color: #c8e6c9;
}

[data-theme="dark"] .admin-sidebar {
  background: #091209;
  border-right: 1px solid #1e3320;
}

[data-theme="dark"] .admin-topbar {
  background: #121a12;
  border-bottom-color: #253d25;
}

[data-theme="dark"] .topbar-title { color: #c8e6c9; }

[data-theme="dark"] .card {
  background: #1a2a1a;
  border-color: #2e4a2e;
}

[data-theme="dark"] .card-header {
  background: #1e3320;
  border-bottom-color: #2e4a2e;
}

[data-theme="dark"] .card-header h3 { color: #81c784; }

[data-theme="dark"] .data-table th {
  background: #1e3320;
  color: #81c784;
  border-bottom-color: #43a047;
}

[data-theme="dark"] .data-table td {
  border-bottom-color: #253d25;
  color: #c8e6c9;
}

[data-theme="dark"] .data-table tbody tr:hover td {
  background: #1e3320;
}

[data-theme="dark"] .stat-card {
  background: #1a2a1a;
  border-color: #2e4a2e;
}

[data-theme="dark"] .stat-info .stat-value { color: #e8f5e9; }
[data-theme="dark"] .stat-info .stat-label { color: #81a882; }

[data-theme="dark"] .form-control {
  background: #1e3320;
  border-color: #2e4a2e;
  color: #c8e6c9;
}

[data-theme="dark"] .form-control:focus {
  border-color: #66bb6a;
  box-shadow: 0 0 0 3px rgba(102,187,106,.15);
}

[data-theme="dark"] .alert-success {
  background: #1e3320;
  border-color: #66bb6a;
  color: #a5d6a7;
}

[data-theme="dark"] .alert-error {
  background: #2d0a0a;
  border-color: #ef5350;
  color: #ef9a9a;
}

[data-theme="dark"] .alert-info {
  background: #0d2426;
  border-color: #4db6ac;
  color: #80cbc4;
}

[data-theme="dark"] .alert-warning {
  background: #2d1a00;
  border-color: #ffa726;
  color: #ffcc80;
}

[data-theme="dark"] .badge-green  { background: #1e3320; color: #81c784; }
[data-theme="dark"] .badge-blue   { background: #0d1f3c; color: #64b5f6; }
[data-theme="dark"] .badge-gray   { background: #253025; color: #a5d6a7; }
[data-theme="dark"] .badge-orange { background: #2d1a00; color: #ffcc80; }

[data-theme="dark"] .sidebar-link { color: rgba(200,230,201,.78); }
[data-theme="dark"] .sidebar-link.active {
  background: rgba(102,187,106,.20);
  border-left-color: #81c784;
  color: #c8e6c9;
}

[data-theme="dark"] .login-card {
  background: #1a2a1a;
}

[data-theme="dark"] .login-title { color: #81c784; }

/* ---- Vibrant Theme for Admin ---- */
[data-theme="vibrant"] .admin-sidebar   { background: #3e1200; }
[data-theme="vibrant"] .admin-topbar    { background: #fff; border-bottom-color: #ffccbc; }
[data-theme="vibrant"] .card-header     { background: #fbe9e7; border-bottom-color: #ff7043; }
[data-theme="vibrant"] .card-header h3  { color: #bf360c; }
[data-theme="vibrant"] .data-table th   { background: #fbe9e7; color: #bf360c; border-bottom-color: #ff7043; }
[data-theme="vibrant"] .stat-card       { border-color: #ffccbc; }
[data-theme="vibrant"] .btn-primary     { background: #e64a19; border-color: #e64a19; }
[data-theme="vibrant"] .btn-primary:hover { background: #bf360c; border-color: #bf360c; }
[data-theme="vibrant"] .badge-green     { background: #fbe9e7; color: #bf360c; }
[data-theme="vibrant"] .sidebar-link.active { background: rgba(230,74,25,.25); border-left-color: #ff7043; }
[data-theme="vibrant"] .login-title     { color: #bf360c; }

/* ---- Light Theme for Admin ---- */
[data-theme="light"] .admin-sidebar     { background: #0a2a6e; }
[data-theme="light"] .card-header       { background: #e3f2fd; border-bottom-color: #1976d2; }
[data-theme="light"] .card-header h3    { color: #0d47a1; }
[data-theme="light"] .data-table th     { background: #e3f2fd; color: #0d47a1; border-bottom-color: #1976d2; }
[data-theme="light"] .stat-card         { border-color: #bbdefb; }
[data-theme="light"] .btn-primary       { background: #1565c0; border-color: #1565c0; }
[data-theme="light"] .btn-primary:hover { background: #0d47a1; border-color: #0d47a1; }
[data-theme="light"] .badge-green       { background: #e3f2fd; color: #0d47a1; }
[data-theme="light"] .form-control:focus { border-color: #1976d2; box-shadow: 0 0 0 3px rgba(25,118,210,.15); }
[data-theme="light"] .sidebar-link.active { background: rgba(25,118,210,.25); border-left-color: #42a5f5; }
[data-theme="light"] .login-title       { color: #0d47a1; }
