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

:root {
  --blue:    #2563EB;
  --green:   #16A34A;
  --purple:  #7C3AED;
  --orange:  #EA580C;
  --red:     #DC2626;
  --gray-50: #F9FAFB;
  --gray-100:#F3F4F6;
  --gray-200:#E5E7EB;
  --gray-400:#9CA3AF;
  --gray-500:#6B7280;
  --gray-700:#374151;
  --gray-900:#111827;
  --white:   #FFFFFF;
  --radius:  10px;
  --shadow:  0 1px 4px rgba(0,0,0,.08);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blue);   color: #fff; }
.btn-success { background: var(--green);  color: #fff; }
.btn-danger  { background: var(--red);    color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-200); color: var(--gray-700); }
.btn-lg      { padding: 12px 24px; font-size: 14px; }
.btn-sm      { padding: 6px 10px; font-size: 12px; }
.w-full      { width: 100%; justify-content: center; }

/* ── Form ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-500); }

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="email"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  outline: none;
  transition: border-color .2s;
}
input:focus { border-color: var(--blue); }
input::placeholder { color: var(--gray-400); }
.pin-row { display: flex; gap: 8px; }
.pin-row input { flex: 1; }

/* ── Landing ──────────────────────────────────────── */
.landing-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--white);
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 36px; height: 36px;
  background: var(--blue);
  border-radius: 9px;
  display: grid; place-items: center;
  color: #fff; font-size: 16px;
  flex-shrink: 0;
}
.brand-icon.small { width: 30px; height: 30px; font-size: 13px; }
.brand-text h2 { font-size: 16px; font-weight: 700; line-height: 1.2; }
.brand-text span { font-size: 11px; color: var(--gray-400); }

.landing-nav-actions { display: flex; align-items: center; gap: 8px; }

.landing-hero {
  max-width: 640px;
  margin: 64px auto 48px;
  padding: 0 24px;
  text-align: center;
}
.landing-hero h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 16px;
  color: var(--gray-900);
}
.landing-hero p {
  font-size: 15px;
  color: var(--gray-500);
  line-height: 1.7;
  margin-bottom: 28px;
}
.hero-cta-group { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.features-section {
  max-width: 900px;
  margin: 0 auto 64px;
  padding: 0 24px;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.feature-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px;
}
.feature-card h3 { font-size: 14px; font-weight: 700; margin: 10px 0 6px; }
.feature-card p  { font-size: 12px; color: var(--gray-500); line-height: 1.6; }
.feature-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 15px; color: #fff;
}
.feature-icon.blue   { background: var(--blue); }
.feature-icon.green  { background: var(--green); }
.feature-icon.purple { background: var(--purple); }
.feature-icon.orange { background: var(--orange); }

/* ── Auth Overlay ─────────────────────────────────── */
.auth-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-overlay.active { display: flex; }

.auth-modal {
  background: var(--white);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.auth-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--gray-400);
}
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.auth-tab-btn {
  flex: 1; padding: 8px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--gray-200);
  background: none; cursor: pointer; color: var(--gray-500);
  transition: all .2s;
}
.auth-tab-btn.active {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
.auth-modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* ── App Layout ───────────────────────────────────── */
.hidden { display: none !important; }
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 8px;
}
.sidebar-role  { font-size: 11px; font-weight: 700; color: var(--blue); text-transform: uppercase; }
.sidebar-school{ font-size: 12px; color: var(--gray-500); }
.sidebar-user  { font-size: 12px; color: var(--gray-400); padding: 8px 16px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item i { width: 16px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
}

.logout-btn {
  margin: 12px 8px 0;
  justify-content: center;
  font-size: 12px;
}

/* ── Main Content ─────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--gray-50);
}

.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 20px; font-weight: 700; }

.tab-page { display: none; }
.tab-page.active { display: block; }

/* ── Stats ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 16px; color: #fff;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--blue); }
.stat-icon.green  { background: var(--green); }
.stat-icon.purple { background: var(--purple); }
.stat-icon.orange { background: var(--orange); }
.stat-num   { font-size: 22px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

.section-label { font-size: 11px; color: var(--gray-400); margin-bottom: 12px; }

/* ── Boards Grid ──────────────────────────────────── */
.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.board-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.board-card.active-session { border-color: #BBF7D0; background: #F0FDF4; }

.board-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.board-room-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }

.badge-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-status.active { background: #D1FAE5; color: var(--green); }
.badge-status.locked { background: var(--gray-100); color: var(--gray-500); }

.board-teacher-info { margin-bottom: 12px; }
.board-teacher-name, .board-subject {
  font-size: 13px; color: var(--gray-700);
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
}
.text-muted { color: var(--gray-400); font-size: 12px; }

.timer-box {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--gray-500);
}
.timer-count { font-weight: 800; font-size: 18px; color: var(--green); }

.board-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Table ────────────────────────────────────────── */
.tab-actions {
  display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
  align-items: center;
}
.search-input {
  padding: 9px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  width: 260px;
}
.search-input:focus { border-color: var(--blue); }

.table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--gray-200);
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.pin-badge {
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 6px;
  padding: 3px 8px;
  font-family: monospace;
  font-weight: 700;
  font-size: 13px;
}

/* ── Settings ─────────────────────────────────────── */
.settings-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 24px;
  max-width: 440px;
  box-shadow: var(--shadow);
}
.settings-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 18px; }

/* ── Modal ────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--gray-400);
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px;
}

/* ── Toast ────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--gray-900); color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes slideIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── Mobile ───────────────────────────────────────── */
@media (max-width: 640px) {
  .landing-header { padding: 12px 16px; }
  .landing-hero { margin: 32px auto 32px; }
  .landing-hero h1 { font-size: 24px; }
  .landing-nav-actions .btn { padding: 8px 10px; font-size: 12px; }

  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%; min-width: unset;
    border-right: none; border-bottom: 1px solid var(--gray-200);
    padding: 10px 0;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
  }
  .sidebar-brand, .sidebar-user, .logout-btn { display: none; }
  .sidebar-nav { flex-direction: row; padding: 0 8px; gap: 4px; }
  .nav-item { padding: 8px 10px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .nav-item i { display: none; }

  .main-content { padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .boards-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
}

/* ── Hamburger & Mobile Topbar ──────────────────────── */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 50;
  width: 100%;
}
.mobile-title { font-size: 15px; font-weight: 700; }

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background .15s;
}
.hamburger:hover { background: var(--gray-100); }
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--gray-700);
  border-radius: 2px;
  transition: all .25s;
  transform-origin: center;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Sidebar overlay ────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 80;
}
.sidebar-overlay.show { display: block; }

/* ── Sidebar header / footer ────────────────────────── */
.sidebar-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 8px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.sidebar-close {
  display: none;
  background: none; border: none;
  font-size: 18px; color: var(--gray-400); cursor: pointer;
  padding: 4px 6px; border-radius: 6px;
}
.sidebar-close:hover { background: var(--gray-100); color: var(--gray-700); }
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--gray-100);
  margin-top: auto;
}
.logout-btn { width: 100%; justify-content: center; font-size: 13px; }

/* ── Desktop logout in page header ─────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.desktop-logout { flex-shrink: 0; }

/* ── Mobile overrides ───────────────────────────────── */
@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .desktop-logout { display: none; }

  .app-layout { flex-direction: column; height: auto; min-height: 100vh; }

  .sidebar {
    position: fixed;
    top: 0; left: -260px;
    width: 260px;
    height: 100vh;
    z-index: 90;
    transition: left .28s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
    padding-top: 0;
    overflow-y: auto;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
  }
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
  }
  .sidebar-header { padding: 16px; }
  .sidebar-close { display: block; }

  .main-content { height: auto; overflow-y: visible; padding: 14px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .boards-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .landing-hero h1 { font-size: 24px; }
  .landing-header { padding: 12px 16px; }
  .hero-cta-group { flex-direction: column; align-items: center; }
  .hero-cta-group .btn { width: 100%; max-width: 280px; justify-content: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .features-grid { grid-template-columns: 1fr; }
  .auth-modal { padding: 20px 16px; }
  .landing-nav-actions .btn span { display: none; }
}
