/* ═══════════════════════════════════════════════════════
   STUDENT PORTAL — common.css
   Shared base styles: reset, variables, buttons, tables,
   forms, modals, toast, utilities.
   ═══════════════════════════════════════════════════════ */

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

:root {
  --accent: #4f46e5;
  --accent-dark: #3730a3;
  --accent-light: #6366f1;
  --accent-soft: #eef2ff;
  --green: #10b981;
  --amber: #f59e0b;
  --sky: #0ea5e9;
  --red: #ef4444;
  --red-soft: #fef2f2;

  /* Student-specific tint — a lighter indigo sidebar vs teacher's deep navy */
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-text: #94a3b8;
  --sidebar-active: #fff;
  --sidebar-w: 260px;

  --topnav-h: 64px;
  --topnav-bg: #ffffff;
  --topnav-border: #f1f5f9;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #94a3b8;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
}

html,
body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.5;
}

/* ── AUTH GUARD ── */
.auth-guard {
  position: fixed;
  inset: 0;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 9999;
  color: #94a3b8;
  font-size: 0.9rem;
}

.auth-guard-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(79, 70, 229, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.auth-guard.hidden {
  display: none;
}

/* ── APP SHELL ── */
.app-shell {
  display: flex;
  min-height: 100vh;
  opacity: 0;
  transition: opacity 0.35s;
}

.app-shell.visible {
  opacity: 1;
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  padding: 32px 36px;
  overflow-y: auto;
}

.section {
  display: none;
  animation: fadeUp 0.3s ease;
}

.section.active {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  margin-bottom: 28px;
}

.section-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.section-sub {
  font-size: 0.9rem;
  color: var(--text-sub);
}

/* ── TABLE TOOLBAR ── */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.search-input {
  padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--text-main);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 10px center;
  outline: none;
  min-width: 220px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.count-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── TABLE CARD ── */
.table-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 13px 18px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: #fafafa;
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 18px !important;
  font-size: 0.875rem;
}

.empty-state-sm {
  text-align: center;
  color: var(--text-muted);
  padding: 20px 0;
  font-size: 0.85rem;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 0.9rem;
  grid-column: 1 / -1;
}

/* ── PILLS ── */
.pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.pill-green {
  background: #dcfce7;
  color: #15803d;
}

.pill-amber {
  background: #fef9c3;
  color: #92400e;
}

.pill-red {
  background: var(--red-soft);
  color: var(--red);
}

.pill-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill-purple {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pill-gray {
  background: #f1f5f9;
  color: #64748b;
}

.pill-teal {
  background: #ccfbf1;
  color: #0f766e;
}

/* ── FORM CARD ── */
.form-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.form-card-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 22px;
}

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

.field-group {
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-main);
  margin-bottom: 7px;
}

.field-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-input::placeholder {
  color: #cbd5e1;
}

.field-input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.field-input[readonly] {
  background: #f8fafc;
  color: var(--text-sub);
  cursor: not-allowed;
}

.field-textarea {
  resize: vertical;
  min-height: 80px;
}

.error-msg {
  font-size: 0.78rem;
  color: var(--red);
  margin-top: 5px;
  min-height: 16px;
  display: block;
}

.success-msg {
  font-size: 0.82rem;
  color: var(--green);
  margin-bottom: 12px;
  font-weight: 500;
}

.success-msg.hidden {
  display: none;
}

.readonly-field {
  padding: 10px 14px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  font-size: 0.9rem;
  color: var(--text-sub);
  font-weight: 500;
}

/* ── File Drop Zone ── */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  background: #fafafa;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--accent-light);
  background: var(--accent-soft);
}

.file-drop-inner {
  pointer-events: none;
}

.file-drop-text {
  font-size: 0.875rem;
  color: var(--text-sub);
  margin-top: 10px;
}

.file-drop-link {
  color: var(--accent);
  font-weight: 600;
  pointer-events: all;
  cursor: pointer;
}

.file-drop-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.file-input-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-selected {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 8px;
  min-height: 18px;
}

/* ── Upload Progress ── */
.upload-progress-wrap {
  margin-top: 14px;
}

.upload-progress-wrap.hidden {
  display: none;
}

.upload-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green) 0%, var(--sky) 100%);
  border-radius: 10px;
  width: 0%;
  transition: width 0.3s;
}

.upload-progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 5px;
  display: block;
}

/* ── BUTTONS ── */
.btn-primary {
  padding: 11px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.btn-sm {
  padding: 8px 16px;
  font-size: 0.825rem;
}

.btn-success {
  padding: 9px 18px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-1px);
}

.btn-success:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-download {
  padding: 8px 16px;
  background: #eff6ff;
  color: var(--sky);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-download:hover {
  background: var(--sky);
  color: #fff;
  border-color: var(--sky);
}

.btn-download:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  padding: 11px 20px;
  background: #f1f5f9;
  color: var(--text-sub);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s;
}

.btn-ghost:hover {
  background: var(--border);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: 30px 30px 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s;
  opacity: 0;
}

.modal-overlay.open .modal-box {
  transform: none;
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover {
  background: var(--border);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9000;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.3s;
  max-width: 320px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-left: 4px solid var(--green);
}

.toast.error {
  border-left: 4px solid var(--red);
}

.toast.info {
  border-left: 4px solid var(--accent-light);
}

/* ── SIDEBAR COLLAPSED STATE ── */
.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-collapsed .main-wrap {
  margin-left: 0;
}

/* ── UTILITIES ── */
.hidden {
  display: none !important;
}
