/* ============================================
   PORTAL CSS — STUDENT/PARENT/TEACHER/ADMIN
   ============================================ */

/* Portal Layout */
.portal-wrap {
  display: flex;
  min-height: 100vh;
  padding-top: 70px;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--primary-dark);
  color: #fff;
  position: fixed;
  top: 70px;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: var(--transition);
}

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

.sidebar-header img {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  margin-bottom: 10px;
}

.sidebar-header h4 { color: #fff; font-size: 0.95rem; }
.sidebar-header p { color: rgba(255,255,255,0.6); font-size: 0.8rem; }

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
  border-left-color: var(--accent);
}

.sidebar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  border-left-color: var(--accent);
}

.sidebar-nav a i { width: 20px; text-align: center; font-size: 1rem; }

/* Main Content */
.portal-main {
  flex: 1;
  margin-left: 260px;
  padding: 30px;
  background: var(--bg-light);
  min-height: calc(100vh - 70px);
}

/* Portal Top Bar */
.portal-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.portal-topbar h2 { font-size: 1.4rem; }

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

.notif-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-dark);
}

.notif-btn .notif-count {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dashboard Widgets */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.widget {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.widget-full { grid-column: 1 / -1; }
.widget-half { grid-column: span 2; }
.widget-three { grid-column: span 3; }

.widget h4 {
  font-size: 0.95rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.widget h4 i { color: var(--accent); }

/* Stat Widgets */
.stat-widget {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.stat-widget .icon.blue { background: #e3f2fd; color: var(--info); }
.stat-widget .icon.green { background: #e8f5e9; color: var(--success); }
.stat-widget .icon.orange { background: #fff3e0; color: var(--warning); }
.stat-widget .icon.red { background: #fce4ec; color: var(--danger); }
.stat-widget .icon.gold { background: rgba(232,160,32,0.12); color: var(--accent); }

.stat-widget .info h3 {
  font-size: 1.6rem;
  color: var(--text-dark);
  font-weight: 700;
}

.stat-widget .info p { color: var(--text-muted); font-size: 0.85rem; }

/* Welcome Banner */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 24px 30px;
  border-radius: var(--radius);
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.welcome-banner h3 { color: #fff; font-size: 1.3rem; margin-bottom: 4px; }
.welcome-banner p { opacity: 0.85; font-size: 0.92rem; }
.welcome-banner .welcome-right { text-align: right; }
.welcome-banner .welcome-right .big-stat { font-size: 2rem; font-weight: 700; color: var(--accent); }

/* Attendance Calendar */
.attendance-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day-header {
  text-align: center;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: default;
}

.cal-day.present { background: #c8e6c9; color: #1b5e20; }
.cal-day.absent { background: #ffcdd2; color: #b71c1c; }
.cal-day.late { background: #ffe0b2; color: #e65100; }
.cal-day.medical { background: #bbdefb; color: #0d47a1; }
.cal-day.holiday { background: #f5f5f5; color: #9e9e9e; }
.cal-day.empty { background: transparent; }

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

.chart-container canvas { max-height: 300px; }

/* Mini Table */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.mini-table th {
  background: var(--bg-light);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.82rem;
  border-bottom: 2px solid var(--border);
}

.mini-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.mini-table tbody tr:hover { background: var(--bg-light); }

/* Homework List */
.hw-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.hw-item:last-child { border-bottom: none; }

.hw-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hw-status.pending { background: var(--warning); }
.hw-status.submitted { background: var(--info); }
.hw-status.graded { background: var(--success); }
.hw-status.overdue { background: var(--danger); }

.hw-info h5 { font-size: 0.9rem; margin-bottom: 2px; }
.hw-info p { font-size: 0.78rem; color: var(--text-muted); }
.hw-due { margin-left: auto; font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }

/* Syllabus Chapter List */
.chapter-list { list-style: none; }

.chapter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.chapter-item:hover { background: var(--bg-light); }

.chapter-no {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.chapter-no.completed { background: #e8f5e9; color: var(--success); }
.chapter-no.in-progress { background: #e3f2fd; color: var(--info); }
.chapter-no.pending { background: #f5f5f5; color: #9e9e9e; }

.chapter-info { flex: 1; }
.chapter-info h5 { font-size: 0.9rem; margin-bottom: 2px; }
.chapter-info p { font-size: 0.78rem; color: var(--text-muted); }

/* Fee Payment */
.fee-summary-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.fee-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.fee-row:last-child { border-bottom: none; font-weight: 700; font-size: 1rem; }

.payment-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.payment-method {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.payment-method:hover, .payment-method.active {
  border-color: var(--primary);
  background: rgba(26,58,92,0.03);
}

.payment-method i { font-size: 2rem; color: var(--primary); margin-bottom: 10px; }
.payment-method h5 { font-size: 0.92rem; }

/* QR Code */
.qr-code {
  width: 200px;
  height: 200px;
  background: #f0f0f0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  border: 2px dashed var(--border);
}

/* Card Form */
.card-form { max-width: 400px; margin: 20px auto; }

.card-input-row { display: flex; gap: 12px; }
.card-input-row .form-group { flex: 1; }

/* Receipt */
.receipt {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 500px;
  margin: 0 auto;
}

.receipt-header { text-align: center; margin-bottom: 24px; border-bottom: 2px solid var(--primary); padding-bottom: 16px; }
.receipt-header h3 { color: var(--primary); }
.receipt-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 0.92rem; }
.receipt-total { border-top: 2px solid var(--primary); font-weight: 700; font-size: 1.05rem; padding-top: 12px; margin-top: 12px; }

/* Grade Card Print */
.grade-card {
  background: #fff;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
}

.grade-card-header {
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 20px;
  margin-bottom: 20px;
}

.grade-card-header .school-info { flex: 1; text-align: center; }
.grade-card-header .school-info h2 { font-size: 1.3rem; color: var(--primary); }
.grade-card-header .school-info p { font-size: 0.82rem; color: var(--text-muted); }

.student-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.student-info-grid .info-item { display: flex; gap: 8px; }
.student-info-grid .info-label { font-weight: 600; min-width: 120px; }

.grade-card .signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.grade-card .signatures div { text-align: center; }
.grade-card .signatures .sig-line { width: 150px; border-top: 1px solid var(--text-dark); margin-bottom: 4px; }

/* Sidebar Toggle (Mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 80px;
  left: 10px;
  z-index: 150;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 900px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.login-left {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 50px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.login-left .logo {
  width: 80px;
  height: 80px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--primary-dark);
  margin-bottom: 20px;
}

.login-left h2 { color: #fff; margin-bottom: 8px; font-size: 1.4rem; }
.login-left p { opacity: 0.8; font-size: 0.92rem; }

.login-right { padding: 50px 40px; }
.login-right h3 { margin-bottom: 24px; }

.role-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.role-tab {
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 50px;
  background: transparent;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  transition: var(--transition);
}

.role-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.demo-box {
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 20px;
  font-size: 0.82rem;
}

.demo-box h5 { font-size: 0.85rem; margin-bottom: 8px; cursor: pointer; }
.demo-box h5 i { transition: var(--transition); }
.demo-box .demo-content { display: none; }
.demo-box .demo-content.open { display: block; }
.demo-box code { background: #fff; padding: 2px 6px; border-radius: 3px; font-size: 0.8rem; }

.login-error {
  background: #fce4ec;
  color: var(--danger);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: none;
}

.password-toggle {
  position: relative;
}

.password-toggle .toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  font-size: 1rem;
}

/* Marks Entry Form */
.marks-entry-table input[type="number"] {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: center;
  font-size: 0.88rem;
}

.marks-entry-table .auto-grade {
  font-weight: 600;
  font-size: 0.85rem;
}

/* Performance Cards */
.perf-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.perf-card i { font-size: 1.3rem; }
.perf-card.strength i { color: var(--success); }
.perf-card.weakness i { color: var(--warning); }
.perf-card h5 { font-size: 0.9rem; margin-bottom: 2px; }
.perf-card p { font-size: 0.82rem; color: var(--text-muted); }

/* Timetable Grid */
.timetable-grid {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.timetable-grid table { width: 100%; border-collapse: collapse; }

.timetable-grid th {
  background: var(--primary);
  color: #fff;
  padding: 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

.timetable-grid td {
  padding: 10px;
  text-align: center;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}

.timetable-grid .time-col {
  background: var(--bg-light);
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}

.timetable-grid .break-cell {
  background: #fff3e0;
  color: var(--warning);
  font-weight: 600;
}

.timetable-grid .lunch-cell {
  background: #e8f5e9;
  color: var(--success);
  font-weight: 600;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th {
  background: var(--primary);
  color: #fff;
  padding: 12px 14px;
  text-align: left;
  font-size: 0.82rem;
}

.admin-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.admin-table tbody tr:hover { background: var(--bg-light); }

.admin-table .actions-cell { display: flex; gap: 6px; }

.admin-table .action-btn {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.admin-table .action-btn.view { background: #e3f2fd; color: var(--info); }
.admin-table .action-btn.edit { background: #fff3e0; color: var(--warning); }
.admin-table .action-btn.delete { background: #fce4ec; color: var(--danger); }

/* Responsive Portal */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .widget-three { grid-column: span 2; }
  .payment-methods { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-toggle { display: flex; }

  .portal-main { margin-left: 0; padding: 20px 16px; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .widget-half, .widget-three { grid-column: span 1; }

  .welcome-banner { flex-direction: column; text-align: center; }
  .welcome-banner .welcome-right { text-align: center; margin-top: 12px; }

  .payment-methods { grid-template-columns: 1fr; }

  .login-card { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .login-right { padding: 40px 24px; }

  .grade-card { padding: 20px; }
  .grade-card-header { flex-direction: column; text-align: center; }
  .student-info-grid { grid-template-columns: 1fr; }
}
