@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&family=JetBrains+Mono:wght@300;400;500;600&display=swap');

/* ===== COPHILD DESIGN SYSTEM ===== */
:root {
  /* Cophild Brand */
  --co-950: #0D0400;
  --co-900: #1C0800;   /* Primary dark brown */
  --co-800: #2D1200;
  --co-700: #4A1E05;
  --co-600: #6B3315;
  --co-500: #8B5030;
  --co-400: #A87050;
  --co-300: #C89878;
  --co-200: #E0C0A0;
  --co-100: #F5E8DC;
  --co-50:  #FDF8F4;

  /* Gold Accent */
  --gold-700: #8B6800;
  --gold-600: #A8800A;
  --gold-500: #C8941A;   /* Primary gold */
  --gold-400: #E0AA28;
  --gold-300: #F0C040;
  --gold-100: #FDF5DC;

  /* Maroon Accent (logo) */
  --maroon: #8B1A1A;
  --maroon-light: #C02828;

  /* Neutrals */
  --white:    #FFFFFF;
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Semantic */
  --success:  #065F46; --success-bg: #ECFDF5; --success-border: #A7F3D0;
  --error:    #991B1B; --error-bg:   #FEF2F2; --error-border:   #FECACA;
  --warning:  #92400E; --warning-bg: #FFFBEB; --warning-border: #FDE68A;
  --info:     #1E40AF; --info-bg:    #EFF6FF; --info-border:    #BFDBFE;

  /* Editor */
  --editor-bg: #1E1E1E;
  --editor-gutter: #252526;
  --editor-line: #264F78;
  --editor-text: #D4D4D4;
  --editor-border: #3C3C3C;
  --editor-kw: #569CD6;
  --editor-fn: #DCDCAA;
  --editor-str: #CE9178;
  --editor-num: #B5CEA8;
  --editor-cm: #6A9955;

  /* Layout */
  --sidebar-w: 256px;
  --topbar-h:  64px;

  /* Fonts */
  --font-heading: 'Outfit', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1),  0 4px 6px rgba(0,0,0,.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,.1), 0 10px 10px rgba(0,0,0,.04);

  /* Borders */
  --r-sm:   6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-full: 9999px;

  --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; font-family: var(--font-body); }
input, textarea, select { font-family: var(--font-body); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--co-300); border-radius: 3px; }

/* ===== LOGO ===== */
.cophild-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
}
.logo-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--maroon), var(--co-700));
  display: grid; place-items: center;
  font-family: var(--font-heading); font-weight: 800; font-size: 20px;
  color: var(--white); flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(139,26,26,.4);
}
.logo-text { line-height: 1.1; }
.logo-name {
  font-family: var(--font-heading); font-weight: 800; font-size: 18px;
  color: var(--white);
}
.logo-name span { color: var(--gold-400); }
.logo-sub {
  font-size: 10px; color: rgba(255,255,255,0.6);
  letter-spacing: 0.06em; text-transform: uppercase;
}
/* Dark variant logo */
.logo-dark .logo-name { color: var(--co-900); }
.logo-dark .logo-sub  { color: var(--gray-500); }

/* ===== APP SHELL ===== */
.app-shell { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--co-900);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  overflow-y: auto; z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-nav { flex: 1; padding: 16px 12px; }
.nav-section { margin-bottom: 24px; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,.3);
  padding: 0 10px; margin-bottom: 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: rgba(255,255,255,.65); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: var(--transition); margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-link.active {
  background: var(--gold-500); color: var(--co-900);
}
.nav-link.active .nav-icon { opacity: 1; }
.nav-icon { font-size: 17px; width: 20px; text-align: center; opacity: 0.75; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--maroon); color: var(--white);
  padding: 2px 7px; border-radius: var(--r-full);
}
.sidebar-footer {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--r-md);
  cursor: pointer; transition: var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,.08); }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-500), var(--co-500));
  display: grid; place-items: center;
  font-family: var(--font-heading); font-weight: 700; font-size: 15px;
  color: var(--co-900); flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--white); }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.4); }

/* ===== MAIN AREA ===== */
.main-area {
  flex: 1; margin-left: var(--sidebar-w); min-width: 0;
  min-height: 100vh; display: flex; flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h); background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-xs);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-family: var(--font-heading); font-size: 18px; font-weight: 700; color: var(--co-900); }
.topbar-breadcrumb { font-size: 13px; color: var(--gray-500); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-500), var(--co-600));
  display: grid; place-items: center;
  font-family: var(--font-heading); font-weight: 700; font-size: 14px;
  color: var(--co-900); cursor: pointer; border: 2px solid var(--gold-500);
}
.topbar-user-name { font-size: 14px; font-weight: 600; color: var(--co-900); }
.topbar-user-role { font-size: 11px; color: var(--gray-500); }

/* ===== PAGE CONTENT ===== */
.page-content { flex: 1; padding: 28px; }
.page-header { margin-bottom: 28px; }
.page-title {
  font-family: var(--font-heading); font-size: 24px; font-weight: 800;
  color: var(--co-900); margin-bottom: 4px;
}
.page-subtitle { font-size: 14px; color: var(--gray-500); }

/* ===== CARDS ===== */
.card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-padded { padding: 24px; }
.card-header {
  padding: 16px 24px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-family: var(--font-heading); font-size: 16px; font-weight: 700; color: var(--co-900); }
.card-body { padding: 24px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.gold::before  { background: var(--gold-500); }
.stat-card.brown::before { background: var(--co-600); }
.stat-card.green::before { background: #059669; }
.stat-card.red::before   { background: var(--maroon); }
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center; font-size: 20px; margin-bottom: 14px;
}
.stat-icon.gold   { background: var(--gold-100); }
.stat-icon.brown  { background: var(--co-100); }
.stat-icon.green  { background: #ECFDF5; }
.stat-icon.red    { background: var(--error-bg); }
.stat-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 6px; }
.stat-value { font-family: var(--font-heading); font-size: 32px; font-weight: 800; color: var(--co-900); line-height: 1; }
.stat-change { font-size: 12px; color: var(--success); margin-top: 6px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 600; transition: var(--transition);
  border: none; cursor: pointer; line-height: 1;
}
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 16px; }

.btn-primary {
  background: var(--gold-500); color: var(--co-900);
  box-shadow: 0 2px 8px rgba(200,148,26,.35);
}
.btn-primary:hover { background: var(--gold-400); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(200,148,26,.4); }

.btn-dark { background: var(--co-900); color: var(--white); }
.btn-dark:hover { background: var(--co-800); }

.btn-outline {
  background: transparent; color: var(--co-900);
  border: 1.5px solid var(--gray-300);
}
.btn-outline:hover { border-color: var(--co-500); color: var(--co-700); }

.btn-outline-gold {
  background: transparent; color: var(--gold-600);
  border: 1.5px solid var(--gold-500);
}
.btn-outline-gold:hover { background: var(--gold-100); }

.btn-danger { background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border); }
.btn-danger:hover { background: #FEE2E2; }

.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.btn-success:hover { background: #D1FAE5; }

.btn-ghost { background: var(--gray-100); color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-200); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.badge-easy   { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.badge-medium { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.badge-hard   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.badge-gold   { background: var(--gold-100); color: var(--gold-700); border: 1px solid var(--gold-300); }
.badge-brown  { background: var(--co-100); color: var(--co-700); border: 1px solid var(--co-200); }
.badge-active { background: #ECFDF5; color: #065F46; }
.badge-inactive { background: var(--gray-100); color: var(--gray-600); }
.badge-coding  { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.badge-quiz    { background: #F5F3FF; color: #6D28D9; border: 1px solid #DDD6FE; }
.badge-poll    { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.badge-text    { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--gray-700); margin-bottom: 6px;
}
.form-label span { color: var(--error); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--gray-300); border-radius: var(--r-md);
  font-size: 14px; font-family: var(--font-body); color: var(--gray-900);
  background: var(--white); transition: var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(200,148,26,.15);
}
.form-input::placeholder { color: var(--gray-400); }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px;
}
.form-hint { font-size: 12px; color: var(--gray-500); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--error); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 12px 16px; text-align: left; font-size: 12px;
  font-weight: 700; color: var(--gray-500); text-transform: uppercase;
  letter-spacing: 0.06em; border-bottom: 2px solid var(--gray-200);
  white-space: nowrap; background: var(--gray-50);
}
.data-table td {
  padding: 14px 16px; font-size: 14px; color: var(--gray-800);
  border-bottom: 1px solid var(--gray-100); vertical-align: middle;
}
.data-table tr:hover td { background: var(--co-50); }
.data-table tr:last-child td { border-bottom: none; }

/* ===== CHALLENGE CARDS ===== */
.challenge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.challenge-card {
  background: var(--white); border: 1.5px solid var(--gray-200);
  border-radius: var(--r-lg); padding: 20px; cursor: pointer;
  transition: var(--transition); display: flex; flex-direction: column; gap: 14px;
}
.challenge-card:hover { border-color: var(--gold-400); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.challenge-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.challenge-type-icon {
  width: 38px; height: 38px; border-radius: var(--r-md);
  display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
.challenge-card-title { font-family: var(--font-heading); font-size: 15px; font-weight: 700; color: var(--co-900); margin-bottom: 4px; line-height: 1.4; }
.challenge-card-desc { font-size: 13px; color: var(--gray-500); line-height: 1.55; flex: 1; }
.challenge-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--gray-100); font-size: 12px; color: var(--gray-500);
}

/* ===== CODE EDITOR ===== */
.editor-container {
  background: var(--editor-bg); border-radius: var(--r-lg);
  overflow: hidden; border: 1px solid var(--editor-border);
  display: flex; flex-direction: column;
}
.editor-toolbar {
  background: var(--editor-gutter); border-bottom: 1px solid var(--editor-border);
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.editor-toolbar-left, .editor-toolbar-right { display: flex; align-items: center; gap: 8px; }
.editor-lang-btn {
  font-family: var(--font-mono); font-size: 12px;
  padding: 4px 12px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.6);
  border: 1px solid rgba(255,255,255,.1); cursor: pointer; transition: var(--transition);
}
.editor-lang-btn.active { background: var(--gold-500); color: var(--co-900); border-color: var(--gold-500); }
.editor-lang-select {
  background: rgba(255,255,255,.08); color: var(--editor-text);
  border: 1px solid rgba(255,255,255,.15); border-radius: var(--r-sm);
  padding: 5px 28px 5px 10px; font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; outline: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.editor-body { display: flex; flex: 1; overflow: hidden; }
.line-numbers {
  padding: 16px 0; background: var(--editor-gutter);
  border-right: 1px solid var(--editor-border);
  min-width: 48px; text-align: right;
  font-family: var(--font-mono); font-size: 13px;
  color: rgba(255,255,255,.25); line-height: 1.7; user-select: none;
}
.line-num { display: block; padding-right: 12px; }
.code-textarea {
  flex: 1; background: var(--editor-bg); color: var(--editor-text);
  border: none; outline: none; resize: none; padding: 16px;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7;
  tab-size: 2; caret-color: var(--gold-400); overflow-y: auto;
}
.editor-statusbar {
  background: var(--co-900); padding: 4px 16px;
  display: flex; align-items: center; gap: 20px;
  font-family: var(--font-mono); font-size: 11px; color: rgba(255,255,255,.5);
}
.status-ok { color: #4EC9B0; }
.editor-footer {
  background: var(--editor-gutter); border-top: 1px solid var(--editor-border);
  padding: 10px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.output-panel {
  background: #0E0E0E; border-top: 1px solid var(--editor-border);
  font-family: var(--font-mono); font-size: 13px; color: var(--editor-text);
  padding: 14px 16px; max-height: 260px; overflow-y: auto; line-height: 1.6;
}
.output-label { font-size: 11px; color: rgba(255,255,255,.3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.output-success { color: #4EC9B0; }
.output-error   { color: #F44747; }
.output-warning { color: var(--gold-400); }

/* HTML/CSS Editor Specific */
.html-preview {
  width: 100%; border: none; background: var(--white); flex: 1;
  min-height: 300px;
}
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.editor-pane-label {
  font-family: var(--font-mono); font-size: 11px; color: rgba(255,255,255,.4);
  text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 16px;
  background: rgba(255,255,255,.04); border-bottom: 1px solid var(--editor-border);
  display: flex; align-items: center; gap: 6px;
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; place-items: center; z-index: 999; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: grid; }
.modal {
  background: var(--white); border-radius: var(--r-xl);
  width: 90%; max-width: 520px; box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 720px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-family: var(--font-heading); font-size: 18px; font-weight: 800; color: var(--co-900); }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gray-100); display: grid; place-items: center;
  font-size: 18px; cursor: pointer; color: var(--gray-600);
  border: none; transition: var(--transition); line-height: 1;
}
.modal-close:hover { background: var(--gray-200); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== PIN DISPLAY ===== */
.pin-display {
  font-family: var(--font-mono); font-size: 36px; font-weight: 800;
  color: var(--co-900); letter-spacing: 0.25em; text-align: center;
  background: var(--gold-100); border: 2px dashed var(--gold-400);
  border-radius: var(--r-lg); padding: 20px; margin: 16px 0;
}
.pin-input-group {
  display: flex; align-items: center; gap: 0;
}
.pin-input-group input {
  border-right: none; border-radius: var(--r-md) 0 0 var(--r-md);
}
.pin-input-group button {
  padding: 10px 16px; border: 1.5px solid var(--gray-300);
  border-left: none; border-radius: 0 var(--r-md) var(--r-md) 0;
  background: var(--gray-100); color: var(--gray-600);
  font-size: 13px; transition: var(--transition); cursor: pointer;
}
.pin-input-group button:hover { background: var(--gray-200); }

/* ===== QUIZ OPTIONS ===== */
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.quiz-opt {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border: 1.5px solid var(--gray-200);
  border-radius: var(--r-md); cursor: pointer; transition: var(--transition); font-size: 14px;
}
.quiz-opt:hover { border-color: var(--gold-400); background: var(--gold-100); }
.quiz-opt.selected { border-color: var(--gold-500); background: var(--gold-100); }
.quiz-opt.correct { border-color: #059669; background: #ECFDF5; color: #065F46; }
.quiz-opt.wrong   { border-color: #DC2626; background: #FEF2F2; color: #991B1B; }
.opt-letter {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--gray-100); border: 1.5px solid var(--gray-300);
  transition: var(--transition);
}
.quiz-opt.selected .opt-letter { background: var(--gold-500); color: var(--co-900); border-color: var(--gold-500); }

/* ===== POLL OPTIONS ===== */
.poll-opt {
  border: 1.5px solid var(--gray-200); border-radius: var(--r-md);
  overflow: hidden; cursor: pointer; transition: var(--transition); margin-bottom: 10px;
}
.poll-opt:hover { border-color: var(--gold-400); }
.poll-bar-outer { padding: 14px 16px; position: relative; }
.poll-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: var(--gold-100); pointer-events: none;
  transition: width 0.8s ease;
}
.poll-label { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; }
.poll-pct { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--gold-600); }

/* ===== LEADERBOARD ===== */
.lb-podium {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 0; max-width: 500px; margin: 0 auto 32px; align-items: flex-end;
}
.podium-place {
  text-align: center; padding: 16px 12px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.podium-1st { background: linear-gradient(180deg, var(--gold-100), rgba(248,245,234,.5)); border: 1px solid var(--gold-300); padding-top: 24px; order: 2; }
.podium-2nd { background: var(--gray-50); border: 1px solid var(--gray-200); order: 1; }
.podium-3rd { background: var(--co-50); border: 1px solid var(--co-100); order: 3; }
.podium-avatar {
  width: 52px; height: 52px; border-radius: 50%; margin: 0 auto 8px;
  display: grid; place-items: center; font-size: 20px; font-weight: 800; color: var(--co-900);
}
.podium-name { font-family: var(--font-heading); font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.podium-score { font-family: var(--font-mono); font-size: 12px; color: var(--gold-600); font-weight: 700; }

/* ===== PROGRESS BARS ===== */
.progress-wrap { margin-bottom: 12px; }
.progress-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--gray-700); margin-bottom: 6px; }
.progress-bar { height: 8px; background: var(--gray-100); border-radius: var(--r-full); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--r-full); transition: width 1s ease; }
.fill-gold  { background: linear-gradient(90deg, var(--gold-500), var(--gold-400)); }
.fill-green { background: linear-gradient(90deg, #059669, #34D399); }
.fill-red   { background: linear-gradient(90deg, #DC2626, #F87171); }

/* ===== HEATMAP ===== */
.heatmap { display: grid; grid-template-columns: repeat(26, 1fr); gap: 3px; }
.hm-cell { aspect-ratio: 1; border-radius: 2px; background: var(--gray-100); cursor: pointer; transition: var(--transition); }
.hm-cell[data-v="1"] { background: var(--co-200); }
.hm-cell[data-v="2"] { background: var(--co-400); }
.hm-cell[data-v="3"] { background: var(--co-600); }
.hm-cell[data-v="4"] { background: var(--co-800); }
.hm-cell:hover { transform: scale(1.3); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--co-900); color: var(--white);
  border-radius: var(--r-lg); padding: 14px 20px;
  display: flex; align-items: center; gap: 12px; min-width: 280px;
  box-shadow: var(--shadow-xl); border-left: 4px solid var(--gold-500);
  transform: translateY(80px); opacity: 0;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1); font-size: 14px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left-color: #059669; }
.toast.error   { border-left-color: #DC2626; }
.toast.info    { border-left-color: #3B82F6; }
.toast-icon { font-size: 18px; }
.toast-msg { flex: 1; font-weight: 500; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 52px; margin-bottom: 16px; }
.empty-title { font-family: var(--font-heading); font-size: 18px; font-weight: 700; color: var(--co-900); margin-bottom: 8px; }
.empty-text  { font-size: 14px; color: var(--gray-500); }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px; border-radius: var(--r-md); font-size: 14px;
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid var(--error-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border); }

/* ===== TAG INPUT ===== */
.tag-container {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px; border: 1.5px solid var(--gray-300); border-radius: var(--r-md);
  min-height: 44px; background: var(--white); cursor: text; transition: var(--transition);
}
.tag-container:focus-within { border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(200,148,26,.15); }
.tag-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--gold-100); border: 1px solid var(--gold-300);
  color: var(--gold-700); padding: 3px 8px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600;
}
.tag-remove { cursor: pointer; color: var(--gold-600); font-size: 14px; line-height: 1; }
.tag-remove:hover { color: var(--error); }
.tag-input { border: none; outline: none; font-size: 13px; min-width: 80px; flex: 1; background: transparent; }

/* ===== DIVIDER ===== */
.divider { height: 1px; background: var(--gray-200); margin: 20px 0; }
.divider-label {
  display: flex; align-items: center; gap: 12px; color: var(--gray-500); font-size: 13px; margin: 20px 0;
}
.divider-label::before, .divider-label::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

/* ===== SEARCH ===== */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 38px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 15px; pointer-events: none;
}

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; gap: 4px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--gray-500);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; transition: var(--transition); border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: none; border-left: none; border-right: none; border-top: none;
}
.tab-btn:hover { color: var(--co-700); background: var(--co-50); }
.tab-btn.active { color: var(--co-900); border-bottom-color: var(--gold-500); }

/* ===== TOPBAR HAMBURGER ===== */
.hamburger {
  display: none; flex-direction: column; gap: 4px; cursor: pointer;
  padding: 6px; background: none; border: none;
}
.hamburger span { width: 20px; height: 2px; background: var(--co-900); border-radius: 2px; transition: var(--transition); }
/* ══════════════════════════════════════════
   SIDEBAR OVERLAY (mobile)
══════════════════════════════════════════ */
.sidebar-overlay{
  display:none;position:fixed;inset:0;
  background:rgba(0,0,0,.5);z-index:99;
}
.sidebar-overlay.open{display:block;}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar{transform:translateX(-100%);}
  .sidebar.open{transform:translateX(0);}
  .main-area { margin-left: 0; }
  .hamburger { display: flex; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .editor-split { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .challenge-grid { grid-template-columns: 1fr; }
  .logo-img { width: 40px; }
  /* .topbar-user-name{ font-size: xx-small; }
  .topbar-user-role{ font-size: xx-small; } */
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .modal { width: 95%; }
  .logo-img { width: 35px; }
}

/* ===== MISC ===== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--gray-500); }
.text-gold { color: var(--gold-600); }
.text-dark { color: var(--co-900); }
.font-mono { font-family: var(--font-mono); }
.font-heading { font-family: var(--font-heading); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.hidden { display: none !important; }
.overflow-hidden { overflow: hidden; }
.capitalize { text-transform: capitalize; }
.pointer { cursor: pointer; }
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #eee;
  border-top: 4px solid #333;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg)
  }

  100% {
    transform: rotate(360deg)
  }
}

.error-loading-text{
  text-align: center;
  color: darkred;
  font-size: larger;
  text-shadow: 1px 1px 6px #0000007d;
  letter-spacing: 1px;
}

.contact-form input, .contact-form textarea { outline-color: #c8941a33;}

.pagination {
  display: flex;
  justify-content: center; /* Changed from space-around to keep items stable */
  gap: 20px;
  align-items: center;
  margin: 25px 0;
  color: #5f9ea0de;
  font-family: sans-serif;
  font-size: xx-small;
}

.pagination-btn {
  background: var(--gold-600);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: opacity 0.3s ease, transform 0.2s;
  color : white; font-size : xx-small
}

.pagination-btn:hover { transform: scale(1.1); }

/* The Arrow Icon using pseudo-elements */
.pagination-btn span {
  position: absolute;
  top: 50%;
  left: 50%;
  border: solid white;
  border-width: 0 2px 2px 0;
  padding: 3px;
  /* transform: translate(-50%, -50%) rotate(135deg); Right arrow */
}
.pagination-btn.next span{
  transform: translate(-50%, -50%) rotate(316deg);
}
.pagination-btn.prev span {
  /* transform: translate(-25%, -50%) rotate(-45deg);  */
  transform: translate(-50%, -50%) rotate(135deg);
}

/* Handling the disappearance */
.pagination-btn.hidden {
  opacity: 0;
  pointer-events: none; /* Prevents clicking when invisible */
  transition: opacity 0.3s ease;
}


/* Image logo variant */
.cophild-logo.logo-image {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fffbea;
  /* width: 60%; */
  /* margin-left: 20%; */
  height: 2rem;
  border-radius: 2px;
  box-shadow: 1px 1px 6px lightgrey;
}
.logo-img {
  max-width: 100%; height: auto;
  width: 60px; object-fit: contain;
}

a.logo-image .logo-img{
  width : 100px;
}

/* Force the sidebar to be visible on desktop, 
   overriding any inline styles set by mobile JavaScript */
@media (min-width: 769px) {
  aside#sidebar {
    transform: translateX(0) !important;
  }
}
