/* ================================================================== */
/* Student Companion Nipsa — Design System                             */
/* Matching Flutter's ColorScheme.fromSeed(seedColor: Colors.grey)    */
/* ================================================================== */
:root {
  /* 
   * Material 3 palette from Colors.grey (#9E9E9E) seed.
   * The primary tonal range is a muted blue-grey.
   */
  --bg-primary: #fafafa;
  --bg-secondary: #f0f1f3;
  --bg-card: #ffffff;
  --bg-input: #eceef1;
  --bg-nav: #ffffff;
  --text-primary: #1b1b1f;
  --text-secondary: #5e5e62;
  --text-muted: #91919a;
  --accent: #5d5f65;         /* M3 primary from grey seed */
  --accent-light: rgba(93,95,101,0.12);
  --border: #dfe0e4;
  --shadow: rgba(0,0,0,0.07);

  /* Semantic colors — matching Flutter app exactly */
  --blue: #2196F3;
  --indigo: #3F51B5;
  --teal: #009688;
  --deep-purple: #673AB7;
  --green: #4CAF50;
  --orange: #FF9800;
  --amber: #FFB300;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 50%;

  /* Transitions */
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Dark Mode ─────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-primary: #121215;
  --bg-secondary: #1c1c1f;
  --bg-card: #212125;
  --bg-input: #2a2a2e;
  --bg-nav: #1c1c1f;
  --text-primary: #e4e2e6;
  --text-secondary: #c6c5ca;
  --text-muted: #7a7a83;
  --accent: #c5c5cd;           /* M3 primary on dark from grey seed */
  --accent-light: rgba(197,197,205,0.15);
  --border: #303034;
  --shadow: rgba(0,0,0,0.4);
}

/* ─── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}
html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ─── App Container ─────────────────────────────────────────────────── */
#app {
  height: 100vh;
  overflow-y: auto;
  padding-bottom: 80px;
  scroll-behavior: smooth;
}

/* ─── Screen Base ───────────────────────────────────────────────────── */
.screen {
  min-height: calc(100vh - 80px);
  padding: var(--space-lg);
  max-width: 600px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}
.screen-full {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Typography ────────────────────────────────────────────────────── */
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; }
h4 { font-size: 16px; font-weight: 600; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }

/* ─── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .btn-primary { color: #1b1b1f; }
.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover { background: var(--accent-light); }
.btn-full { width: 100%; }
.btn-google {
  background: #fff;
  color: #333;
  border: 1.5px solid #dadce0;
  font-weight: 500;
}
.btn-google:hover { background: #f8f9fa; }
[data-theme="dark"] .btn-google { background: #2a2a2e; color: #e4e2e6; border-color: #444; }
[data-theme="dark"] .btn-google:hover { background: #333; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* Color accent buttons for matching Flutter */
.btn-teal { background: var(--teal); color: #fff; }
.btn-indigo { background: var(--indigo); color: #fff; }
.btn-deep-purple { background: var(--deep-purple); color: #fff; }

/* ─── Inputs ────────────────────────────────────────────────────────── */
.input-group { margin-bottom: var(--space-md); }
.input-group label {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}
.input-field:focus {
  border-color: var(--accent);
  background: var(--bg-primary);
}
.input-field::placeholder { color: var(--text-muted); }
select.input-field { appearance: none; cursor: pointer; }
textarea.input-field { resize: vertical; min-height: 80px; }

/* ─── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-lg);
  transition: var(--transition);
}
.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--shadow);
}
.card-interactive { cursor: pointer; }

/* ─── Info Card (Classes / Assignments summary) ─────────────────────── */
.info-card {
  display: flex; align-items: flex-start; gap: var(--space-md);
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: var(--transition);
}
.info-card:hover { transform: translateY(-1px); }
.info-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.info-card-body { flex: 1; }
.info-card-title {
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.info-card-text {
  font-size: 14px; line-height: 1.4;
  color: var(--text-secondary);
}

/* ─── Tool Card Grid ────────────────────────────────────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}
.tool-card {
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  display: flex; flex-direction: column;
  justify-content: flex-end;
  min-height: 140px;
  cursor: pointer;
  color: #fff;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.tool-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
}
.tool-card i { font-size: 28px; margin-bottom: auto; }
.tool-card h4 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.tool-card p { font-size: 12px; opacity: 0.8; }

/* ─── Setting Card ──────────────────────────────────────────────────── */
.setting-card {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.setting-card:hover { background: var(--bg-input); }
.setting-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.setting-body { flex: 1; }
.setting-body h4 { font-size: 14px; font-weight: 600; }
.setting-body p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Section Title ─────────────────────────────────────────────────── */
.section-title {
  margin-bottom: var(--space-md);
}
.section-title h3 {
  font-size: 18px; font-weight: 700;
}
.section-title .accent-bar {
  height: 3px; width: 40px;
  background: var(--accent);
  border-radius: 2px;
  margin-top: 5px;
}

/* ─── Feed Post Card ────────────────────────────────────────────────── */
.feed-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  cursor: pointer;
  transition: var(--transition);
}
.feed-card:hover { border-color: var(--text-muted); }
.feed-header {
  display: flex; align-items: center; gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.feed-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: rgba(63,81,181,0.12);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  color: var(--indigo);
}
.feed-meta { flex: 1; }
.feed-meta h4 { font-size: 14px; font-weight: 600; }
.feed-meta span { font-size: 11px; color: var(--text-muted); }
.feed-description { font-size: 14px; color: var(--text-secondary); margin-bottom: var(--space-sm); line-height: 1.4; }
.feed-file {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
}
.feed-actions {
  display: flex; align-items: center; gap: var(--space-lg);
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}
.feed-action-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; color: var(--text-muted);
  font-size: 13px; padding: 4px;
}
.feed-action-btn:hover { color: var(--accent); }
.feed-action-btn.liked { color: var(--danger); }

/* ─── Bottom Navigation ─────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  display: flex; justify-content: center;
  padding: 8px 16px 12px;
  z-index: 100;
  box-shadow: 0 -4px 20px var(--shadow);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 24px;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px; font-weight: 500;
  transition: var(--transition);
}
.nav-btn i { font-size: 18px; }
.nav-btn.active {
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .nav-btn.active { color: #1b1b1f; }

/* ─── Floating Action Button ────────────────────────────────────────── */
.fab {
  position: fixed; bottom: 88px; right: 24px;
  width: 56px; height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 90;
  transition: var(--transition);
}
[data-theme="dark"] .fab { color: #1b1b1f; }
.fab:hover { transform: scale(1.1); }

/* ─── Toast / Snackbar ──────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 24px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 16px var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ─── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
}
.modal h3 { margin-bottom: var(--space-md); }
.modal-actions {
  display: flex; gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

/* ─── App Bar ───────────────────────────────────────────────────────── */
.app-bar {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md) 0;
  margin-bottom: var(--space-md);
}
.app-bar-back {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 18px;
  transition: var(--transition);
}
.app-bar-back:hover { background: var(--border); }
.app-bar h2 { flex: 1; font-size: 18px; }

/* ─── Profile Avatar ────────────────────────────────────────────────── */
.avatar {
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full);
  font-weight: 700;
  background: rgba(63,81,181,0.12);
  color: var(--indigo);
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-md { width: 48px; height: 48px; font-size: 18px; }
.avatar-lg { width: 80px; height: 80px; font-size: 28px; }

/* ─── Empty State ───────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: var(--space-md); opacity: 0.3; }
.empty-state h4 { margin-bottom: var(--space-sm); color: var(--text-secondary); }
.empty-state p { font-size: 12px; }

/* ─── List Item ─────────────────────────────────────────────────────── */
.list-item {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  transition: var(--transition);
}
.list-item:hover { background: var(--bg-input); }
.list-item-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-body h4 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-body p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Splash Screen ─────────────────────────────────────────────────── */
.splash-logo {
  width: 80px; height: 80px;
  border-radius: var(--radius-xl);
  background: var(--indigo);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 800;
  margin-bottom: var(--space-lg);
  animation: pulse 2s infinite;
  box-shadow: 0 8px 24px rgba(63,81,181,0.3);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ─── Loading Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Quick Actions Row ─────────────────────────────────────────────── */
.quick-actions {
  display: flex; gap: var(--space-sm);
}
.quick-action {
  flex: 1;
  padding: 18px 8px;
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px; font-weight: 600;
}
.quick-action:hover { transform: translateY(-2px); }
.quick-action i { font-size: 24px; }

/* ─── Timetable ─────────────────────────────────────────────────────── */
.day-tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding-bottom: var(--space-sm);
}
.day-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
}
.day-tab.active {
  background: var(--accent);
  color: #fff;
}
[data-theme="dark"] .day-tab.active { color: #1b1b1f; }

/* ─── Checkbox ──────────────────────────────────────────────────────── */
.checkbox-btn {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--transition);
  background: transparent;
  color: transparent;
}
.checkbox-btn.checked {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* ─── Badge ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600;
}
.badge-danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-success { background: rgba(34,197,94,0.1); color: var(--success); }
.badge-info { background: rgba(59,130,246,0.1); color: var(--info); }

/* ─── Divider ───────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-lg) 0;
}
.divider-text {
  display: flex; align-items: center; gap: var(--space-md);
  color: var(--text-muted); font-size: 13px;
  margin: var(--space-lg) 0;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ─── Utilities ─────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.w-full { width: 100%; }

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  .screen { max-width: 640px; }
  .bottom-nav { max-width: 400px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ─── Grades Page Styles ────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: var(--space-sm);
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}
.tab-btn {
  flex: 1; padding: 10px;
  font-size: 13px; font-weight: 600;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  transition: var(--transition);
}
.tab-btn.active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: 0 4px 12px var(--shadow);
}

.cgpa-summary-card {
  background: var(--accent);
  color: #fff;
  padding: var(--space-xl);
  border-radius: var(--radius-xl);
  text-align: center;
  margin-bottom: var(--space-xl);
  box-shadow: 0 12px 32px var(--shadow);
}
[data-theme="dark"] .cgpa-summary-card { color: #1b1b1f; }
.cgpa-summary-card p { font-size: 12px; opacity: 0.8; font-weight: 600; letter-spacing: 0.5px; }
.cgpa-summary-card h1 { font-size: 42px; margin-top: 4px; }

.session-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
}
.session-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-md);
}
.session-header h3 { cursor: pointer; }

.semester-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}
.grades-table {
  width: 100%; border-collapse: collapse;
  margin-top: var(--space-md);
}
.grades-table th {
  text-align: left; font-size: 11px; text-transform: uppercase;
  color: var(--text-muted); padding-bottom: 8px;
}
.grades-table td { padding: 4px 2px; }

.range-item {
  display: flex; align-items: center; gap: var(--space-md);
  padding: 12px; background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}
.range-label {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.range-scores { flex: 1; font-weight: 600; }
.range-points { font-size: 13px; color: var(--text-secondary); }

.flex-gap { display: flex; gap: var(--space-md); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.btn-icon {
  background: none; border: none; padding: 4px;
  color: var(--text-muted); cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover { color: var(--accent); }
.btn-icon.text-danger:hover { color: var(--danger); }
.input-field-sm {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}
.input-field-sm:focus { border-color: var(--accent); }
