/* ═══════════════════════════════════════════════════════════
   EduTrack — Design System
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --primary:     #3b82f6;
  --primary-dk:  #2563eb;
  --primary-lt:  #eff6ff;
  --success:     #22c55e;
  --success-lt:  #f0fdf4;
  --warning:     #f59e0b;
  --warning-lt:  #fffbeb;
  --danger:      #ef4444;
  --danger-lt:   #fef2f2;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 1px 4px rgba(0,0,0,.07);
  --shadow-lg:   0 4px 24px rgba(0,0,0,.09);
  --transition:  .16s ease;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.app-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px 100px;
}

/* ── Top Bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
}

.topbar-logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.3px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

/* ── Back button ── */
.btn-back {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  padding: 6px 4px;
  border: none;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}
.btn-back svg { width: 18px; height: 18px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2 { font-size: 15px; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform var(--transition);
  text-align: center;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dk); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger  { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

.btn svg { width: 16px; height: 16px; }

/* ── Toggle chip group (Συνέπεια / Καθήκοντα / Συμμετοχή) ── */
.chip-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
}
.chip:active { transform: scale(.95); }

.chip.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.chip.active-warn {
  border-color: var(--warning);
  background: var(--warning);
  color: white;
}
.chip.active-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

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

/* ── Tabs ── */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Lists ── */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }

.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-size: 15px; font-weight: 500; }
.list-item-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.list-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
.badge-blue  { background: var(--primary-lt); color: var(--primary-dk); }
.badge-green { background: var(--success-lt); color: #15803d; }
.badge-warn  { background: var(--warning-lt); color: #b45309; }
.badge-red   { background: var(--danger-lt);  color: #b91c1c; }
.badge-gray  { background: var(--surface-2);  color: var(--text-muted); }

/* ── Class cards (dashboard) ── */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.class-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  display: block;
  color: inherit;
}
.class-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
}
.class-card-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.class-card-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.class-card-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

/* ── Student row in lesson entry ── */
.student-entry {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 10px;
}
.student-entry-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.entry-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
}
.entry-section { margin-bottom: 10px; }
.entry-section:last-child { margin-bottom: 0; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
}
.login-logo {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -.5px;
}
.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}
.login-error {
  background: var(--danger-lt);
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; padding-top: 60px; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--surface-2); }
.modal-body  { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── FAB (floating action button) ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59,130,246,.4);
  cursor: pointer;
  border: none;
  font-size: 24px;
  z-index: 90;
  transition: all var(--transition);
}
.fab:hover { background: var(--primary-dk); transform: scale(1.05); }
.fab:active { transform: scale(.97); }

/* ── Section heading ── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
}
.section-head h2 { font-size: 16px; font-weight: 700; }

/* ── Empty state ── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 14px; margin-top: 6px; }

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.stat-num  { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-lbl  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Grade badge ── */
.grade-pill {
  display: inline-block;
  min-width: 48px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text);
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-lt); color: #15803d; }
.alert-danger  { background: var(--danger-lt);  color: #b91c1c; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Exam form specifics ── */
.scale-toggle { display: flex; gap: 0; }
.scale-toggle .chip { border-radius: 0; }
.scale-toggle .chip:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.scale-toggle .chip:last-child  { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }

/* ── Grade input in exam table ── */
.grade-input {
  width: 70px;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
}
.grade-input:focus { outline: none; border-color: var(--primary); }

/* ── Lesson date badge ── */
.lesson-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Print styles ── */
@media print {
  body { background: white; font-size: 13px; }
  .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .topbar { display: none; }
}

/* ── Utility ── */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ── Scrollable table wrapper ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; border-bottom: 1.5px solid var(--border); background: var(--surface-2); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ── Admin user list ── */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-lt);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

/* ── Responsive tweaks ── */
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  .class-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .modal-overlay.open { padding-top: 20px; }
  .modal { max-height: 90vh; overflow-y: auto; }
  .login-card { padding: 32px 24px; }
}

@media (max-width: 360px) {
  .chip { padding: 5px 9px; font-size: 12px; }
}
