/* ════════════════════════════════════════════════════════
   Aptipro — Light Theme Design System
   Clean, modern, professional look for students and admins.
   Fully responsive: laptop + mobile.
   ════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────────────── */
:root {
  /* Color Palette — Clean Light Theme */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.8);
  --bg-input: #ffffff;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-primary-light: rgba(59, 130, 246, 0.1);
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #0ea5e9;

  --border-color: #e2e8f0;
  --border-radius-sm: 6px;
  --border-radius: 10px;
  --border-radius-lg: 14px;
  --border-radius-xl: 20px;

  --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 -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --sidebar-width: 260px;
  --header-height: 70px;
  --transition-base: 0.2s ease;

  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

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

a:hover {
  color: var(--accent-primary-hover);
}

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

.fade-in {
  animation: fadeIn 0.4s ease-out;
}

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: transform var(--transition-base);
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin var(--transition-base);
}

/* Auth Page overrides — No sidebar margin */
.auth-page .main-content {
  margin-left: 0;
}

.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.content-body {
  padding: 32px;
  flex: 1;
}

/* ── Components ────────────────────────────────────── */

/* Logo Area */
.brand {
  padding: 40px 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all var(--transition-base);
}

/* Nav */
.sidebar-nav {
  padding: 12px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  margin-bottom: 4px;
}

.nav-link:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-primary-light);
  color: var(--accent-primary);
}

/* User Profile in Header */
.user-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.notification-bell {
  position: relative;
  font-size: 20px;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 50%;
  transition: background var(--transition-base);
}

.notification-bell:hover {
  background: var(--bg-primary);
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--accent-danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

.profile-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

.profile-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-primary-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid var(--accent-primary-light);
  flex-shrink: 0;
}

/* User Meta & Dropdown */
.user-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background var(--transition-base);
  position: relative;
}

.user-profile-trigger:hover {
  background: var(--bg-primary);
}

.user-info-text {
  text-align: right;
  line-height: 1.2;
}

.user-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-role {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 180px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: none;
  z-index: 200;
  animation: fadeIn 0.2s ease-out;
}

.user-dropdown.active {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: all var(--transition-base);
}

.dropdown-item:hover {
  background: var(--bg-primary);
  color: var(--accent-primary);
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.grid-3-2 {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 32px;
}

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

.full-width {
  grid-column: span 2;
}

.stat-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 20px;
  border-radius: var(--border-radius);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

/* ── Tables ────────────────────────────────────────── */
.table-container {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  color: var(--text-secondary);
}

.data-table tr:hover {
  background: #fbfcfe;
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-base);
  border: none;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-primary);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--accent-danger);
  color: #fff;
}

.btn-success {
  background: var(--accent-success);
  color: #fff;
}

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

.label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.input, .form-input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  border: 1.5px solid var(--border-color);
  background: var(--bg-input);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.input:hover, .form-input:hover {
  border-color: var(--text-muted);
}

.input:focus, .form-input:focus, select:focus, textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--accent-primary-light);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ── Auth ──────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-primary), #ffffff);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-page .content-body {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  margin: 20px;
  animation: fadeIn 0.5s ease-out;
}

/* Exam Options Styling */
.option-item {
  display: flex !important;
  align-items: center;
  padding: 18px 24px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  margin-bottom: 4px;
}

.option-item:hover {
  border-color: var(--accent-primary) !important;
  transform: translateX(4px);
  background: #fdfdfd !important;
}

.option-item input[type="radio"]:checked + span {
  font-weight: 700;
  color: var(--accent-primary);
}

.option-item:has(input:checked) {
  border-color: var(--accent-primary) !important;
  background: var(--accent-primary-light) !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.option-item input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-right: 16px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* ── Responsive ────────────────────────────────────── */
.mobile-toggle {
  display: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-primary);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 95;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-lg);
  }

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

  .main-content {
    margin-left: 0;
  }

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
  }

  .header {
    padding: 0 16px;
  }

  .header h1 {
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
  }

  .content-body {
    padding: 16px;
  }

  /* Grid Layouts Mobile Override */
  .grid-2, .grid-3-2, .form-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .full-width {
    grid-column: span 1 !important;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-box {
    padding: 16px;
  }

  .stat-value {
    font-size: 20px;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card {
    padding: 16px;
  }

  /* Exam Interface Mobile Fixes */
  .exam-header {
    margin: 8px !important;
    padding: 10px !important;
  }

  .exam-header h2 {
    font-size: 15px !important;
  }

  .exam-header #q-timer-container {
    font-size: 18px !important;
  }

  div[style*="position:fixed; bottom:0"] {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
    padding: 12px 16px !important;
  }

  div[style*="position:fixed; bottom:0"] button {
    width: 100%;
  }

  #progress-text {
    text-align: center;
    width: 100%;
    margin-bottom: 4px;
    font-size: 13px !important;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .user-meta .profile-circle, 
  .user-meta .profile-placeholder {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .user-meta div[style*="text-align: right"] {
    display: none;
  }

  .auth-card {
    padding: 24px 20px;
    margin: 16px;
    box-shadow: var(--shadow-md);
  }

  .auth-page .content-body {
    padding: 20px 0;
    align-items: flex-start;
  }
}

/* ── Badges ────────────────────────────────────────── */
.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* ── Grid of Categories ────────────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.category-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--accent-primary);
  opacity: 0;
  transition: opacity 0.3s;
}

.category-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-color: var(--accent-primary-light);
}

.category-card:hover::before {
  opacity: 1;
}

.category-icon {
  font-size: 40px;
  margin-bottom: 24px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.category-card h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.category-card p {
  line-height: 1.6;
  flex: 1; /* Pushes the footer to the bottom */
}

/* Exam Interface Specifics */
.exam-header {
  margin: 0 0 24px 0;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  padding: 16px 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.question-card {
  background: var(--bg-card);
  border-radius: var(--border-radius-xl);
  padding: 40px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-top: 24px;
}

.difficulty-badge {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.difficulty-badge.easy { background: #d1fae5; color: #065f46; }
.difficulty-badge.medium { background: #fef3c7; color: #92400e; }
.difficulty-badge.hard { background: #fee2e2; color: #991b1b; }

/* Fixed Footer Fix */
.exam-footer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: left var(--transition-base);
}

@media (max-width: 1024px) {
  .exam-footer {
    left: 0;
  }
  .notif-dropdown {
    width: calc(100vw - 40px);
    right: -50px;
  }
}

/* Header Actions & Notifications */
.header-actions {
  display: flex;
  align-items: center;
  gap: 24px;
}

.notification-container {
  position: relative;
  cursor: pointer;
  z-index: 101;
}

.notification-bell {
  font-size: 22px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: 50%;
  color: var(--text-primary);
  transition: all 0.2s;
  border: 1px solid var(--border-color);
}

.notification-bell:hover {
  background: var(--hover-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.notification-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.notif-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: -10px;
  width: 340px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.12);
  z-index: 1000;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.notif-dropdown.show {
  display: flex;
  animation: slideInDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.notif-header {
  padding: 16px 20px;
  border-bottom: 2px solid var(--bg-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

.notif-header h3 {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
}

.notif-header span {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--accent-primary-light);
  padding: 2px 8px;
  border-radius: 20px;
}

.notif-list {
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-secondary);
}

.notif-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-primary);
  transition: all 0.2s;
  cursor: pointer;
  display: block;
  text-decoration: none;
}

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

.notif-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.notif-msg {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.notif-footer {
  padding: 14px;
  text-align: center;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

.view-all {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary);
  text-decoration: none;
  transition: opacity 0.2s;
}

.view-all:hover {
  opacity: 0.8;
}

.notif-empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-muted);
}

.notif-empty div {
  font-size: 32px;
  margin-bottom: 12px;
}

@keyframes slideInDown {
  from { transform: translateY(-15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
  .notif-dropdown {
    position: fixed;
    top: 70px;
    left: 20px;
    right: 20px;
    width: auto;
  }
}

/* ── Action Buttons ─────────────────────────────────── */
.btn-action {
  width: 32px;
  height: 32px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  background: #fff;
}

.btn-view:hover {
  background: var(--accent-info) !important;
  border-color: var(--accent-info) !important;
  color: #fff !important;
}

.btn-edit:hover {
  background: var(--accent-warning) !important;
  border-color: var(--accent-warning) !important;
  color: #fff !important;
}

.btn-delete:hover {
  background: var(--accent-danger) !important;
  border-color: var(--accent-danger) !important;
  color: #fff !important;
}
