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

:root {
  --primary: #0F2E5E;
  --primary-dark: #07193b;
  --secondary: #C9A250;
  --secondary-dark: #a8853b;
  --bg: #F4F7FB;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

/* Sidebar */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 270px;
  background: var(--primary);
  color: #e2e8f0;
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(0,0,0,0.06);
}

.brand {
  padding: 0 20px 20px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.brand small {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 400;
}

.nav { list-style: none; margin: 0; padding: 0; }

.nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.7);
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 14px;
}
.nav li a:hover, .nav li a.active { 
  background: rgba(255,255,255,0.1); 
  color: var(--secondary); 
  border-left: 4px solid var(--secondary);
}
.nav li a.active {
  background: rgba(255,255,255,0.15); 
}
.nav .icon { width: 22px; text-align: center; opacity: 0.9; }

.sidebar .user-box {
  padding: 16px 20px;
  border-top: 1px solid #1e293b;
  margin-top: 16px;
  font-size: 13px;
}
.sidebar .user-box .role {
  color: #38bdf8;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

/* Main */
.main { flex: 1; padding: 24px 32px; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 22px; margin: 0; }

/* Cards */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border: none;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}
.card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; }
.card .value { font-size: 30px; font-weight: 700; }
.card .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }

.stat-blue .value { color: var(--primary); }
.stat-green .value { color: var(--success); }
.stat-red .value { color: var(--danger); }
.stat-amber .value { color: var(--warning); }
.stat-purple .value { color: #7c3aed; }

.nav-divider {
  padding: 14px 20px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.table-compact th, .table-compact td { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
.table-compact td.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-1 { margin-top: 8px; }
.gap { gap: 10px; }

/* Table */
.table-wrap { overflow-x: auto; box-shadow: 0 4px 20px rgba(0,0,0,0.03); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 16px; overflow: hidden; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #F8FAFC; color: var(--primary); font-weight: 600; white-space: nowrap; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #F4F7FB; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-keldi { background: #dcfce7; color: #166534; }
.badge-kelmadi { background: #fee2e2; color: #991b1b; }
.badge-kechikdi { background: #fef3c7; color: #92400e; }
.badge-maktab { background: #e0f2fe; color: #075985; }
.badge-tuman { background: #dcfce7; color: #166534; }
.badge-viloyat { background: #fef3c7; color: #92400e; }
.badge-respublika { background: #fce7f3; color: #9d174d; }
.badge-xalqaro { background: #ede9fe; color: #5b21b6; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(15, 46, 94, 0.2);
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(15, 46, 94, 0.3); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); box-shadow: none; }
.btn-outline:hover { background: var(--bg); transform: none; box-shadow: none; }
.btn-danger { background: var(--danger); box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2); }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }
.btn-danger-outline:hover { background: #fef2f2; transform: none; box-shadow: none; }
.btn-secondary { background: var(--secondary); color: #fff; box-shadow: 0 2px 8px rgba(201, 162, 80, 0.2); }
.btn-secondary:hover { background: var(--secondary-dark); }

/* Forms */
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.form-control:focus { outline: 2px solid var(--primary); border-color: transparent; }
label { font-size: 13px; font-weight: 600; display: block; margin-bottom: 5px; }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

.form-errors { color: var(--danger); font-size: 13px; margin-bottom: 12px; }
.form-errors ul { margin: 0; padding-left: 18px; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.messages .success { background: #dcfce7; color: #166534; }
.messages .error { background: #fee2e2; color: #991b1b; }

/* Utilities */
.mt-2 { margin-top: 16px; }
.mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Auth */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, #e0e7ff 100%);
}
.auth-card {
  background: #fff;
  border-radius: 20px;
  padding: 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.08);
  border: 1px solid rgba(255,255,255,0.6);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}
.auth-card h1 { margin: 0 0 8px; font-size: 26px; font-weight: 700; color: var(--primary); }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 14px; }

/* Attendance marking */
.att-row td select, .att-row td input { min-width: 160px; }
.att-row td:first-child { white-space: nowrap; font-weight: 500; }

/* Login page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a, #1e3a8a); }

/* Mobile Header */
.mobile-header {
  display: none;
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.mobile-header .brand { margin: 0; padding: 0; border: none; font-size: 18px; }
.hamburger { font-size: 26px; cursor: pointer; color: #fff; }

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  transition: opacity 0.3s;
}
.sidebar-overlay.active { display: block; opacity: 1; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .mobile-header { display: flex; }
  
  .sidebar { 
    position: fixed; 
    left: -100%; 
    top: 0;
    width: 280px; 
    height: 100vh; 
    z-index: 999;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.active { left: 0; }
  
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .main { padding: 16px; min-height: 100vh; }
}
