/* ============================================================
   FSC Dashboard — Main Stylesheet
   Light Gray & White Theme
   ============================================================ */

:root {
  --primary:        #3b5bdb;
  --primary-light:  #eef2ff;
  --primary-dark:   #2f4ac0;
  --secondary:      #6c757d;
  --success:        #2ecc71;
  --success-light:  #eafaf1;
  --warning:        #f39c12;
  --warning-light:  #fef9e7;
  --danger:         #e74c3c;
  --danger-light:   #fdedec;
  --info:           #3498db;
  --info-light:     #ebf5fb;

  --bg-page:        #f4f6f9;
  --bg-card:        #ffffff;
  --bg-sidebar:     #1e2a3a;
  --bg-sidebar-hover: #2c3e50;
  --bg-topbar:      #ffffff;

  --text-primary:   #2c3e50;
  --text-secondary: #6c757d;
  --text-muted:     #adb5bd;
  --text-light:     #ffffff;

  --border:         #e9ecef;
  --border-strong:  #ced4da;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.12);

  --sidebar-w:      240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h:       60px;
  --radius:         10px;
  --radius-sm:      6px;
  --radius-lg:      14px;
  --transition:     0.2s ease;
}

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

html, body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

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

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}
.logo-icon { font-size: 20px; flex-shrink: 0; }
.logo-text {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  transition: opacity var(--transition);
}
.sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; }

.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: #fff; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 2px;
}

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

.nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { font-size: 13px; font-weight: 500; transition: opacity var(--transition); }
.sidebar.collapsed .nav-label { opacity: 0; pointer-events: none; }

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.user-details { overflow: hidden; }
.user-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,0.5); font-size: 11px; }
.sidebar.collapsed .user-details { opacity: 0; }

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 13px;
  transition: all var(--transition);
}
.btn-logout:hover { background: rgba(231,76,60,0.2); color: #e74c3c; }
.sidebar.collapsed .btn-logout span { display: none; }

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

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-date {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }

/* ── STAT CARDS ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

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

.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.red    { background: var(--danger-light); }
.stat-icon.info   { background: var(--info-light); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

/* ── FILTERS ── */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.filter-control {
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 160px;
  transition: border-color var(--transition);
}
.filter-control:focus { outline: none; border-color: var(--primary); }

.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-page); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── TABLES ── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-page);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-page); }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: var(--success-light); color: #1a8e51; }
.badge-danger  { background: var(--danger-light);  color: #c0392b; }
.badge-warning { background: var(--warning-light); color: #b7770d; }
.badge-info    { background: var(--info-light);    color: #1a6fa8; }
.badge-gray    { background: var(--border);        color: var(--text-secondary); }

/* ── PROGRESS BARS ── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  min-width: 100px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ── RANK MEDAL ── */
.rank-medal { font-size: 18px; }

/* ── CHART CONTAINERS ── */
.chart-container {
  position: relative;
  width: 100%;
}
.chart-container canvas { max-width: 100%; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); }
.empty-state p { font-size: 13px; margin-top: 4px; }

/* ── LOADING ── */
.loading-spinner {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ── */
#toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 260px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--primary); color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── SECTION TITLE ── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── FORM ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,91,219,0.12); }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e2a3a 0%, #2c3e50 100%);
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon { font-size: 40px; display: block; margin-bottom: 10px; }
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--text-primary); }
.login-logo p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px; }
.alert-danger { background: var(--danger-light); color: #c0392b; border: 1px solid #f1948a; }

/* ── IMPORT AREA ── */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-page);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.drop-zone-icon { font-size: 40px; margin-bottom: 12px; }
.drop-zone h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.drop-zone p { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

/* ── TABS ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--text-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 94%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 15px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar .logo-text, .sidebar .nav-label, .sidebar .user-details { display: none; }
  .main-content { margin-left: var(--sidebar-w-collapsed); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .page-content { padding: 16px; }
}

/* ── UTILITY ── */
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
