/* ===== Global Styles & Variables ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;
  --secondary: #7c3aed;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --dark: #1e293b;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white: #ffffff;
  --sidebar-width: 260px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  --gradient-primary: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --gradient-success: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  --gradient-danger: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

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

body {
  font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 50%);
  animation: rotate 20s linear infinite;
}

@keyframes rotate {
  to { transform: rotate(360deg); }
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 40px;
  max-width: 420px;
  width: 100%;
  position: relative;
  z-index: 1;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo .logo-icon {
  width: 70px;
  height: 70px;
  background: var(--gradient-primary);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px;
  font-size: 36px;
  color: white;
  box-shadow: 0 8px 16px rgba(37,99,235,0.3);
}

.login-logo h1 {
  font-size: 22px;
  color: var(--gray-800);
  font-weight: 700;
}

.login-logo p {
  color: var(--gray-500);
  font-size: 13px;
  margin-top: 4px;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: all 0.2s;
  background: var(--white);
  color: var(--gray-800);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-control::placeholder {
  color: var(--gray-400);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 6px rgba(37,99,235,0.2);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(37,99,235,0.3);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
}

.btn-warning {
  background: var(--gradient-warning);
  color: white;
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
}

.btn-light {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-light:hover {
  background: var(--gray-200);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--gray-200);
  color: var(--gray-700);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-block {
  width: 100%;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  color: var(--gray-300);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform 0.3s;
  z-index: 100;
}

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

.sidebar-header .logo-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 15px;
  color: white;
  font-weight: 700;
}

.sidebar-header p {
  font-size: 11px;
  color: var(--gray-500);
}

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-user .user-info h4 {
  font-size: 13px;
  color: white;
  font-weight: 600;
}

.sidebar-user .user-info p {
  font-size: 11px;
  color: var(--gray-500);
}

.sidebar-nav {
  padding: 12px 0;
}

.nav-section-title {
  padding: 12px 20px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-600);
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

.nav-item.active {
  background: rgba(37,99,235,0.15);
  color: white;
  border-left-color: var(--primary);
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  background: white;
  padding: 14px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 18px;
  color: var(--gray-800);
  font-weight: 700;
}

.topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-area {
  padding: 24px;
}

/* ===== Cards ===== */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}

.card-header .card-actions {
  display: flex;
  gap: 8px;
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s;
}

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

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  flex-shrink: 0;
}

.stat-card .stat-icon.blue { background: var(--gradient-primary); }
.stat-card .stat-icon.green { background: var(--gradient-success); }
.stat-card .stat-icon.orange { background: var(--gradient-warning); }
.stat-card .stat-icon.red { background: var(--gradient-danger); }
.stat-card .stat-icon.purple { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.stat-card .stat-icon.cyan { background: linear-gradient(135deg, #0891b2, #06b6d4); }

.stat-card .stat-info h3 {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
}

.stat-card .stat-info p {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ===== Tables ===== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

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

table thead {
  background: var(--gray-50);
}

table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  color: var(--gray-700);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

table tbody tr:hover {
  background: var(--gray-50);
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-primary { background: #dbeafe; color: var(--primary); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px;
  line-height: 1;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ===== Grid ===== */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }

/* ===== Scanner Page ===== */
.scanner-container {
  max-width: 500px;
  margin: 0 auto;
}

.scanner-box {
  background: var(--gray-900);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.scanner-frame {
  width: 280px;
  height: 280px;
  margin: 0 auto 20px;
  border: 3px dashed var(--gray-600);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--gray-800);
  overflow: hidden;
}

.scanner-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.scanner-frame .scan-icon {
  font-size: 64px;
  color: var(--gray-600);
}

.scanner-frame > canvas {
  display: none !important;
}

#scannerOverlay {
  z-index: 5;
}

#scanLine {
  z-index: 6;
}

.scanner-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
  animation: scan 2s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { top: 0; }
  50% { top: calc(100% - 3px); }
}

.scanner-input {
  width: 100%;
  padding: 14px;
  font-size: 18px;
  text-align: center;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  letter-spacing: 2px;
  font-family: monospace;
  margin-bottom: 12px;
}

.scan-result {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius-md);
  display: none;
}

.scan-result.show { display: block; animation: slideUp 0.3s; }
.scan-result.success { background: var(--success-light); border: 1px solid var(--success); }
.scan-result.error { background: var(--danger-light); border: 1px solid var(--danger); }

/* ===== Barcode Card ===== */
.id-card {
  width: 340px;
  background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
  border-radius: 16px;
  padding: 20px;
  color: white;
  box-shadow: var(--shadow-xl);
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.id-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 40%);
}

.id-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  position: relative;
}

.id-card-header .school-name {
  font-size: 14px;
  font-weight: 700;
}

.id-card-header .card-type {
  font-size: 10px;
  background: rgba(255,255,255,0.2);
  padding: 3px 8px;
  border-radius: 10px;
}

.id-card-body {
  display: flex;
  gap: 14px;
  align-items: center;
  position: relative;
}

.id-card-photo {
  width: 70px;
  height: 80px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}

.id-card-info h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.id-card-info p {
  font-size: 11px;
  opacity: 0.9;
  margin-bottom: 2px;
}

.id-card-barcode {
  margin-top: 14px;
  background: white;
  padding: 8px;
  border-radius: 8px;
  position: relative;
}

.id-card-barcode svg {
  display: block;
  width: 100%;
  height: auto;
}

.id-card-footer {
  margin-top: 12px;
  font-size: 9px;
  text-align: center;
  opacity: 0.8;
  position: relative;
}

/* ===== Notification Panel ===== */
.notification-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.notification-item:hover { background: var(--gray-50); }
.notification-item.unread { background: #eff6ff; }
.notification-item.unread:hover { background: #dbeafe; }

.notification-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.notification-content h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.notification-content p {
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.notification-content .notif-time {
  font-size: 11px;
  color: var(--gray-400);
}

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: var(--success-light); color: var(--success); border: 1px solid var(--success); }
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning); }
.alert-info { background: var(--info-light); color: var(--info); border: 1px solid var(--info); }

/* ===== Charts ===== */
.chart-container {
  position: relative;
  height: 250px;
}

/* ===== Progress ===== */
.progress-bar {
  height: 8px;
  background: var(--gray-100);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.cursor-pointer { cursor: pointer; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: white;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  animation: slideInRight 0.3s ease;
  border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .content-area {
    padding: 16px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .topbar h1 {
    font-size: 15px;
  }
  .mobile-menu-btn {
    display: flex !important;
  }
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-700);
  padding: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
