:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --page-bg: #f1f5f9;
  --card-bg: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--page-bg);
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
}

/* ===== TOP NAV BAR ===== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 24px;
  background: #0f172a; color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.topbar-left {
  display: flex; align-items: center; gap: 12px;
}
.back-link {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 8px; color: #94a3b8;
  text-decoration: none; font-size: 1rem;
  transition: background var(--transition), color var(--transition);
}
.back-link:hover { background: #1e293b; color: #fff; }
.topbar-logo {
  width: 32px; height: 32px;
  background: var(--primary); color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1rem;
  border-radius: 8px; display: grid; place-items: center;
}
.topbar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1rem; color: #fff;
  letter-spacing: -0.3px;
}
.topbar-divider {
  width: 1px; height: 24px; background: #334155;
}
.topbar-page-name {
  font-size: 0.88rem; color: #94a3b8; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.topbar-page-name i { color: var(--primary); }
.topbar-right { display: flex; align-items: center; }
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px; border-radius: 8px;
  border: none; background: none;
  color: #ef4444; font-size: 0.85rem;
  font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background var(--transition);
}
.btn-logout:hover { background: rgba(239,68,68,0.12); }

/* ===== AUTH GATE ===== */
.auth-gate {
  min-height: calc(100svh - 56px);
  display: grid; place-items: center; padding: 20px;
}
.auth-card {
  text-align: center; padding: 40px 32px;
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-width: 380px; width: 100%;
}
.auth-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem; font-weight: 700;
  color: var(--primary); margin-bottom: 8px;
}
.auth-desc { color: #64748b; font-size: 0.9rem; margin-bottom: 20px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; font-size: 0.9rem;
  font-weight: 700; font-family: inherit;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none;
  transition: background var(--transition), transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled {
  background: #94a3b8; cursor: not-allowed;
}
.btn-primary:disabled:hover { background: #94a3b8; }

/* ===== MAIN CONTENT ===== */
.meetings-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem; font-weight: 700; color: #0f172a; margin-bottom: 4px;
}
.page-desc { font-size: 0.9rem; color: #64748b; }

/* ===== SECTION CARDS ===== */
.section-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px 28px; margin-bottom: 20px;
}
.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem; font-weight: 700; color: #0f172a;
  margin-bottom: 18px; display: flex; align-items: center; gap: 8px;
}
.section-title i { color: var(--primary); }

/* ===== FORM ===== */
.form-stack {
  display: flex; flex-direction: column; gap: 16px;
}
.form-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 200px; }
.form-group label {
  display: block; font-size: 0.82rem; font-weight: 500;
  color: #64748b; margin-bottom: 6px;
}
.form-group input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid #e2e8f0; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-family: inherit; background: #f8fafc; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1); background: #fff;
}
.form-group input[readonly] {
  background: #eef2f7; color: #475569; cursor: default;
}
.form-group-btn { flex: 0 0 auto; min-width: auto; }
.btn-create {
  width: 100%; padding: 13px 22px; margin-top: 0;
  justify-content: center;
}
.form-message { margin-top: 12px; font-size: 0.85rem; font-weight: 500; min-height: 1.2em; }
.form-message.error { color: #dc2626; }
.form-message.success { color: #16a34a; }

/* ===== CUSTOM SEARCHABLE SELECT ===== */
.custom-select-wrapper {
  position: relative;
}

.select-search {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid #e2e8f0; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-family: inherit; background: #f8fafc; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.select-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1); background: #fff;
}
.select-search.has-value {
  background: var(--primary-light);
  border-color: var(--primary);
  font-weight: 500;
  color: #1e40af;
}

.select-dropdown {
  display: none;
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 260px; overflow-y: auto;
  z-index: 50;
}
.select-dropdown.open { display: block; }

.select-option {
  padding: 10px 14px; cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid #f1f5f9;
}
.select-option:last-child { border-bottom: none; }
.select-option:hover { background: var(--primary-light); }

.select-option .opt-name {
  font-size: 0.9rem; font-weight: 600; color: #0f172a;
  display: block;
}
.select-option .opt-email {
  font-size: 0.78rem; color: #64748b; margin-top: 1px;
  display: block;
}
.select-option .opt-role {
  font-size: 0.7rem; font-weight: 600; color: #fff;
  background: #475569; padding: 2px 8px;
  border-radius: 4px; display: inline-block; margin-top: 3px;
}
.select-option .opt-role.role-admin { background: #7c3aed; }
.select-option .opt-role.role-super-admin { background: #dc2626; }
.select-option .opt-role.role-teacher { background: #0891b2; }

.select-no-results {
  padding: 16px 14px; text-align: center;
  color: #94a3b8; font-size: 0.88rem;
}

/* ===== MEETINGS LIST ===== */
.meetings-list { display: flex; flex-direction: column; gap: 10px; }
.meeting-item {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
  padding: 14px 18px; background: #f8fafc;
  border: 1px solid #e2e8f0; border-radius: var(--radius-sm);
  transition: box-shadow var(--transition);
}
.meeting-item:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

.meeting-info { display: flex; flex-direction: column; gap: 2px; }
.meeting-display-name { font-weight: 600; font-size: 0.95rem; color: #0f172a; }
.meeting-room-name { font-size: 0.8rem; color: #64748b; font-family: 'Space Grotesk', monospace; }
.meeting-meta { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.meeting-date { font-size: 0.75rem; color: #94a3b8; }

.meeting-participants-live {
  font-size: 0.7rem; font-weight: 600; padding: 2px 8px;
  border-radius: 4px; display: inline-flex; align-items: center; gap: 4px;
  background: #f1f5f9; color: #94a3b8;
  transition: all 0.3s ease;
}
.meeting-participants-live.has-people {
  background: #dcfce7; color: #16a34a;
  animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0.3); }
  50% { box-shadow: 0 0 0 4px rgba(22,163,74,0); }
}
.jitsi-hidden-viewers {
  position: fixed; left: -9999px; top: -9999px;
  width: 1px; height: 1px; overflow: hidden;
  pointer-events: none; opacity: 0;
}


.meeting-teacher-badge {
  font-size: 0.7rem; font-weight: 600; color: #0891b2;
  background: #ecfeff; padding: 2px 8px; border-radius: 4px;
}

.meeting-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-sm {
  padding: 7px 14px; font-size: 0.8rem; font-weight: 600;
  font-family: inherit; border: none; border-radius: 8px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  transition: background var(--transition), transform 0.05s;
}
.btn-sm:active { transform: translateY(1px); }
.btn-join { background: var(--primary); color: #fff; }
.btn-join:hover { background: var(--primary-dark); }
.btn-delete { background: #fee2e2; color: #dc2626; }
.btn-delete:hover { background: #fecaca; }
.btn-copy { background: #e0f2fe; color: #0284c7; }
.btn-copy:hover { background: #bae6fd; }

.loading-text { text-align: center; color: #94a3b8; padding: 20px; }
.loading-text i { margin-right: 6px; }
.empty-state {
  text-align: center; color: #94a3b8; padding: 40px 20px; font-size: 0.95rem;
}
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: 12px; color: #cbd5e1; }

/* ===== ROOM COUNT INPUT ===== */
.room-count-row {
  display: flex; align-items: center; gap: 8px;
}
.room-count-row input[type="number"] {
  width: 80px; text-align: center;
  padding: 10px 8px; font-size: 1rem; font-weight: 700;
  border: 1.5px solid #e2e8f0; border-radius: var(--radius-sm);
  background: #f8fafc; font-family: inherit; outline: none;
  -moz-appearance: textfield;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.room-count-row input[type="number"]::-webkit-inner-spin-button,
.room-count-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}
.room-count-row input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1); background: #fff;
}
.count-btn {
  width: 40px; height: 40px;
  border: 1.5px solid #e2e8f0; border-radius: var(--radius-sm);
  background: #f8fafc; color: #475569;
  font-size: 0.9rem; cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.15s ease;
}
.count-btn:hover {
  border-color: var(--primary); color: var(--primary); background: #f0f5ff;
}
.count-btn:active { transform: scale(0.95); }

#roomCountGroup { transition: opacity 0.2s ease, max-height 0.3s ease; }
#roomCountGroup.hidden-group {
  opacity: 0; max-height: 0; overflow: hidden;
  margin: 0; padding: 0;
}

/* ===== MEETING TYPE SELECTOR ===== */
.type-selector {
  display: flex; gap: 10px;
}
.type-btn {
  flex: 1; padding: 11px 16px;
  font-size: 0.88rem; font-weight: 600; font-family: inherit;
  border: 1.5px solid #e2e8f0; border-radius: var(--radius-sm);
  background: #f8fafc; color: #64748b;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 8px;
  transition: all 0.2s ease;
}
.type-btn:hover {
  border-color: var(--primary); color: var(--primary);
  background: #f0f5ff;
}
.type-btn.active {
  border-color: var(--primary); background: var(--primary);
  color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}

.meeting-type-badge {
  font-size: 0.7rem; font-weight: 600; padding: 2px 8px;
  border-radius: 4px; display: inline-flex; align-items: center; gap: 4px;
}
.meeting-type-badge.type-breakout {
  background: #fef3c7; color: #92400e;
}
.meeting-type-badge.type-tiep-hv {
  background: #ede9fe; color: #5b21b6;
}

/* ===== PARTICIPANT LIST UNDER MEETINGS ===== */
.meeting-participants-list {
  display: none;
  width: 100%;
  padding: 10px 0 0;
  margin-top: 10px;
  border-top: 1px dashed #e2e8f0;
}
.plist-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: #16a34a;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.plist-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  margin: 2px 4px 2px 0;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #15803d;
}
.plist-chip i {
  font-size: 0.4rem;
  color: #22c55e;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}


/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .meetings-main { padding: 20px 16px 60px; }
  .topbar { padding: 0 16px; }
  .topbar-title, .topbar-divider { display: none; }
  .btn-logout span { display: none; }
  .form-stack { gap: 14px; }
  .meeting-item { flex-direction: column; align-items: flex-start; gap: 10px; }
}


/* ===== HAND RAISE IN PARTICIPANT LIST ===== */
.plist-chip.hand-raised {
  background: #fef9c3;
  border-color: #facc15;
  color: #854d0e;
  animation: hand-chip-pulse 1s ease infinite;
}
.plist-chip.hand-raised i {
  color: #eab308;
}
@keyframes hand-chip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(234, 179, 8, 0); }
}
/* ===== BULK SELECT ===== */
.meeting-checkbox {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.meeting-item.selected {
  background: #eff6ff;
  border-color: var(--primary);
}

/* ===== ACCESS DENIED ===== */
.access-denied {
  min-height: calc(100svh - 56px);
  display: grid; place-items: center; padding: 20px;
}
.access-denied-card {
  text-align: center; padding: 40px 32px;
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-width: 380px; width: 100%;
}
.access-denied-card i {
  font-size: 2.5rem; color: #ef4444; margin-bottom: 16px;
}
.access-denied-card h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem; font-weight: 700; color: #0f172a; margin-bottom: 8px;
}
.access-denied-card p {
  color: #64748b; font-size: 0.9rem; margin-bottom: 20px;
}