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

:root {
  --c-bg:        #0f0f13;
  --c-surface:   #1a1a24;
  --c-surface2:  #24243a;
  --c-border:    #2e2e45;
  --c-text:      #e2e2f0;
  --c-muted:     #7878a0;
  --c-accent:    #6366f1;
  --c-accent-h:  #4f51d8;
  --c-green:     #22c55e;
  --c-yellow:    #f59e0b;
  --c-red:       #ef4444;
  --c-blue:      #3b82f6;
  --c-purple:    #a855f7;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
}

html { height: 100%; font-size: 16px; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100%;
  line-height: 1.6;
}

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

/* ── Utility ──────────────────────────────────────────────────── */
.hidden  { display: none !important; }
.mt-1    { margin-top:  .5rem; }
.mt-2    { margin-top:  1rem; }
.mt-3    { margin-top:  1.5rem; }
.flex    { display: flex; }
.items-center { align-items: center; }
.gap-1   { gap: .5rem; }
.gap-2   { gap: 1rem; }
.w-full  { width: 100%; }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .75rem; }
.muted   { color: var(--c-muted); }
.bold    { font-weight: 600; }

/* ── Layout ───────────────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.page-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  padding: 2rem 0 4rem;
}

/* ── Nav ──────────────────────────────────────────────────────── */
nav {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--c-text);
  letter-spacing: -.02em;
}

.nav-logo span { color: var(--c-accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-links a { color: var(--c-muted); font-size: .9rem; }
.nav-links a:hover { color: var(--c-text); text-decoration: none; }

.nav-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--c-border);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

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

.btn-success   { background: var(--c-green);    color: #000; }
.btn-success:hover  { background: #16a34a; }

.btn-warning   { background: var(--c-yellow);   color: #000; }
.btn-warning:hover  { background: #d97706; }

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

.btn-ghost     { background: var(--c-surface2); color: var(--c-text); }
.btn-ghost:hover    { background: var(--c-border); }

.btn-sm { padding: .35rem .8rem; font-size: .82rem; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.office-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.office-card:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.office-tag {
  display: inline-block;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .2rem .55rem;
  border-radius: 99px;
  margin-bottom: .6rem;
}

.office-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: .25rem;
}

.office-desc {
  font-size: .85rem;
  color: var(--c-muted);
  margin-bottom: .75rem;
}

.open-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 600;
}
.open-badge::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.open-badge.open   { color: var(--c-green); }
.open-badge.closed { color: var(--c-muted); }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: .35rem;
  color: var(--c-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text);
  padding: .6rem .85rem;
  font-size: .93rem;
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--c-accent);
}
select option { background: var(--c-surface); }
textarea { resize: vertical; min-height: 80px; }

.radio-group { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .25rem; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--c-text);
  cursor: pointer;
  font-size: .9rem;
  margin-bottom: 0;
}

.form-hint { font-size: .78rem; color: var(--c-muted); margin-top: .25rem; }

.error-box {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: #fca5a5;
  border-radius: var(--radius);
  padding: .7rem 1rem;
  font-size: .88rem;
  margin-bottom: 1rem;
}

.success-box {
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.35);
  color: #86efac;
  border-radius: var(--radius);
  padding: .7rem 1rem;
  font-size: .88rem;
  margin-bottom: 1rem;
}

/* ── Auth pages ───────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: 100%;
  max-width: 440px;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
}

/* ── Page title ───────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .85rem;
}

/* ── Office page layout ───────────────────────────────────────── */
.office-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 720px) {
  .office-layout { grid-template-columns: 1fr; }
}

/* ── Queue list ───────────────────────────────────────────────── */
.queue-list { display: flex; flex-direction: column; gap: .6rem; }

.queue-entry {
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  transition: border-color .2s;
}
.queue-entry.is-me  { border-color: var(--c-accent); }
.queue-entry.called { border-color: var(--c-yellow); }
.queue-entry.in_meeting { border-color: var(--c-green); }

.entry-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.entry-info { flex: 1; min-width: 0; }
.entry-name { font-weight: 600; font-size: .92rem; }
.entry-meta { font-size: .78rem; color: var(--c-muted); }

.entry-comment {
  background: var(--c-surface);
  border-left: 3px solid var(--c-accent);
  padding: .3rem .6rem;
  font-size: .8rem;
  color: var(--c-muted);
  border-radius: 0 4px 4px 0;
  margin-top: .3rem;
  font-style: italic;
}

.entry-actions { display: flex; gap: .4rem; flex-shrink: 0; flex-wrap: wrap; }

/* ── Status badge ────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .18rem .55rem;
  border-radius: 99px;
}
.status-badge.waiting     { background: rgba(99,102,241,.18); color: #818cf8; }
.status-badge.called      { background: rgba(245,158,11,.18); color: #fbbf24; }
.status-badge.in_meeting  { background: rgba(34,197,94,.18);  color: #4ade80; }
.status-badge.temporary_out { background: rgba(168,85,247,.18); color: #c084fc; }
.status-badge.done        { background: rgba(120,120,160,.15); color: var(--c-muted); }

/* ── "Called" banner for student ─────────────────────────────── */
.called-banner {
  background: linear-gradient(135deg, rgba(245,158,11,.15), rgba(239,68,68,.1));
  border: 1px solid rgba(245,158,11,.4);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
}

.called-banner h2 { font-size: 1.3rem; margin-bottom: .5rem; }

.meeting-link-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--c-green);
  color: #000;
  font-weight: 700;
  padding: .7rem 1.4rem;
  border-radius: var(--radius);
  font-size: 1rem;
  margin: 1rem 0 .5rem;
  transition: background .15s;
}
.meeting-link-btn:hover { background: #16a34a; color: #000; text-decoration: none; }

.access-code {
  font-size: .85rem;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .4rem .8rem;
  display: inline-block;
  font-family: monospace;
  letter-spacing: .1em;
  margin-top: .3rem;
}

/* ── Sidebar info panel ──────────────────────────────────────── */
.info-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.info-panel .card { padding: 1.1rem 1.25rem; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .35rem 0;
  border-bottom: 1px solid var(--c-border);
  font-size: .88rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .val { font-weight: 600; }

/* ── Position indicator ──────────────────────────────────────── */
.position-circle {
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 3px solid var(--c-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto .75rem;
}
.position-circle .num  { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--c-accent); }
.position-circle .label { font-size: .65rem; color: var(--c-muted); text-transform: uppercase; }

/* ── Owner toggle strip ──────────────────────────────────────── */
.owner-bar {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.owner-bar-info .title { font-weight: 700; }
.owner-bar-info .sub   { font-size: .83rem; color: var(--c-muted); }

/* ── Toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .7rem 1.4rem;
  font-size: .9rem;
  z-index: 999;
  transition: transform .25s;
  pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.ok   { border-color: var(--c-green);  color: #4ade80; }
#toast.err  { border-color: var(--c-red);    color: #fca5a5; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--c-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: .5rem; }

/* ── Share box ───────────────────────────────────────────────── */
.share-box {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.share-box input {
  font-size: .82rem;
  font-family: monospace;
  background: var(--c-bg);
}

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