/* ===========================
   College Utility App - KIMS
   Main Stylesheet
   =========================== */

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

:root {
  --primary: #1a237e;
  --primary-light: #3949ab;
  --primary-dark: #0d1642;
  --accent: #ff6f00;
  --accent-light: #ffa040;
  --success: #2e7d32;
  --danger: #c62828;
  --warning: #f57f17;
  --info: #0277bd;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #212121;
  --text-muted: #757575;
  --border: #e0e0e0;
  --sidebar-width: 260px;
  --header-height: 65px;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 3px; }

/* ========== AUTH PAGES ========== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  top: -150px; right: -150px;
}

.auth-wrapper::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  bottom: -100px; left: -100px;
}

.auth-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 44px;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
  position: relative; z-index: 2;
  animation: cardSlideUp 0.4s ease;
}

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

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  width: 70px; height: 70px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 12px;
  box-shadow: 0 4px 15px rgba(26,35,126,0.3);
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

.auth-logo p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
}

.auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow);
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fafafa;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(57,73,171,0.1);
  background: #fff;
}

/* Input with icon/toggle wrapper */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap .form-control {
  padding-left: 42px;
}

.input-wrap .input-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1;
}

.input-wrap .pwd-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.input-wrap .pwd-toggle:hover { color: var(--primary); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 15px;
  box-shadow: 0 4px 15px rgba(26,35,126,0.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26,35,126,0.4); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-sm { padding: 7px 14px; font-size: 12px; }

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

.alert-danger { background: #ffebee; color: var(--danger); border-left: 3px solid var(--danger); }
.alert-success { background: #e8f5e9; color: var(--success); border-left: 3px solid var(--success); }
.alert-info { background: #e3f2fd; color: var(--info); border-left: 3px solid var(--info); }

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

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand .brand-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 10px;
}

.sidebar-brand h2 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand p {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
}

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

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

.user-info h4 { font-size: 13px; font-weight: 600; color: #fff; }
.user-info span {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.1);
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: capitalize;
}

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,0.7);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; }
.nav-item .nav-icon { font-size: 17px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 10px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(198,40,40,0.3); color: #fff; }

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

/* ========== TOP HEADER ========== */
.top-header {
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0; z-index: 50;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.header-title h2 { font-size: 18px; font-weight: 600; color: var(--primary); }
.header-title p { font-size: 12px; color: var(--text-muted); }

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

.header-date {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 6px 12px;
  border-radius: 20px;
}

/* ========== PAGE CONTENT ========== */
.page-content { padding: 28px; flex: 1; }

/* ========== DASHBOARD CARDS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

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

.stat-info h3 { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-info p { font-size: 13px; color: var(--text-muted); }

/* ========== SECTION CARDS ========== */
.section-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
}

.section-body { padding: 24px; }

/* ========== NOTICES ========== */
.notice-list { display: flex; flex-direction: column; gap: 12px; }

.notice-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: all 0.2s;
  position: relative;
}

.notice-item:hover { border-color: var(--primary-light); box-shadow: 0 2px 8px rgba(26,35,126,0.08); }
.notice-item.important { border-left: 3px solid var(--accent); }

.notice-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.badge-general { background: #e3f2fd; color: var(--info); }
.badge-exam { background: #ffebee; color: var(--danger); }
.badge-event { background: #e8f5e9; color: var(--success); }
.badge-fee { background: #fff3e0; color: var(--warning); }
.badge-holiday { background: #f3e5f5; color: #7b1fa2; }

.notice-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.notice-content { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.notice-meta { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

/* ========== NOTES GRID ========== */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.note-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
}

.note-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }

.note-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 12px;
}

.note-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.note-sub { font-size: 12px; color: var(--text-muted); }
.note-footer { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; }

/* ========== TIMETABLE ========== */
.timetable-wrapper { overflow-x: auto; }

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

.timetable th {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 12px 16px;
  text-align: center;
  font-weight: 600;
}

.timetable td {
  padding: 12px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.timetable tr:nth-child(even) { background: #fafafa; }
.timetable tr:hover td { background: #e8eaf6; }

.period-cell { border-radius: 6px; }
.period-subject { font-weight: 600; font-size: 13px; }
.period-teacher { font-size: 11px; color: var(--text-muted); }
.period-room { font-size: 10px; color: var(--text-muted); }

/* ========== RESULTS ========== */
.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.result-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-badge {
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.result-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.result-table th { padding: 10px 16px; background: var(--bg); font-weight: 600; text-align: left; }
.result-table td { padding: 10px 16px; border-top: 1px solid var(--border); }
.result-table tr:hover td { background: #fafafa; }

.result-summary {
  padding: 16px 20px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.percent-badge {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.pass-badge { background: #e8f5e9; color: var(--success); padding: 4px 14px; border-radius: 20px; font-weight: 600; font-size: 13px; }
.fail-badge { background: #ffebee; color: var(--danger); padding: 4px 14px; border-radius: 20px; font-weight: 600; font-size: 13px; }

/* ========== ADMIN TABLE ========== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 12px 16px; background: var(--bg); font-weight: 600; text-align: left; color: var(--text-muted); }
.data-table td { padding: 12px 16px; border-top: 1px solid var(--border); }
.data-table tr:hover td { background: #fafafa; }

.status-approved { background: #e8f5e9; color: var(--success); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-pending { background: #fff3e0; color: var(--warning); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.role-badge { background: #e3f2fd; color: var(--info); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: capitalize; }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;   /* FIX: don't block clicks when invisible */
  transition: opacity 0.2s;
}

.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  transition: transform 0.2s;
}

.modal-overlay.show .modal-box { transform: scale(1); }

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

.modal-title { font-size: 16px; font-weight: 600; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 60px; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ========== LOADING ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== HIDDEN ========== */
.hidden { display: none !important; }
.page { display: none; }
.page.active { display: block; }

/* ========== DASHBOARD GRID ========== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-btn { display: flex !important; }
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
}

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

.toast {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--primary);
}

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

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

/* ========== FILTER BAR ========== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar .form-control { max-width: 200px; }

/* ========== WELCOME BANNER ========== */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.welcome-banner::after {
  content: '🎓';
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 80px;
  opacity: 0.2;
}

.welcome-banner h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.welcome-banner p { font-size: 14px; opacity: 0.85; }
