/* ═══════════ Reset & Base ═══════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d1117; --surface: #161b22; --border: #30363d;
  --text: #e6edf3; --text2: #8b949e; --accent: #58a6ff;
  --green: #3fb950; --red: #f85149; --yellow: #d29922; --purple: #bc8cff;
  --radius: 8px; --shadow: 0 4px 24px rgba(0,0,0,.4);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
code { background: var(--surface); padding: 2px 6px; border-radius: 4px; font-size: .9em; }

/* ═══════════ Navigation ═══════════ */
#navbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 1.3em; font-weight: 700; margin-right: 12px; }
.nav-btn {
  background: none; border: none; color: var(--text2); cursor: pointer;
  padding: 6px 14px; border-radius: var(--radius); font-size: .95em; transition: .2s;
}
.nav-btn:hover, .nav-btn.active { color: var(--text); background: rgba(88,166,255,.15); }
#user-badge { color: var(--green); font-size: .85em; }

/* ═══════════ Buttons ═══════════ */
.btn-sm { padding: 5px 12px; font-size: .85em; }
.btn-primary, .btn-secondary, .btn-accent, .btn-sm {
  border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
  background: var(--surface); color: var(--text); transition: .2s;
}
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.2); }
.btn-secondary:hover { background: var(--border); }
.btn-accent { background: var(--green); color: #000; border-color: var(--green); font-weight: 600; }
.btn-accent:hover { filter: brightness(1.2); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ═══════════ Views ═══════════ */
.view { display: none; flex: 1; }
.view.active { display: block; }
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ═══════════ Hero ═══════════ */
.hero { text-align: center; padding: 80px 24px 48px; }
.hero h1 { font-size: 3em; margin-bottom: 12px; }
.subtitle { font-size: 1.2em; color: var(--text2); margin-bottom: 48px; }
.hero-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 20px; max-width: 860px; margin: 0 auto 56px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 20px; text-align: center;
}
.feature-card span { font-size: 2.4em; display: block; margin-bottom: 12px; }
.feature-card h3 { margin-bottom: 6px; }
.feature-card p { color: var(--text2); font-size: .9em; }
.setup-section { max-width: 700px; margin: 0 auto; text-align: left; }
.setup-steps { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.step { display: flex; align-items: flex-start; gap: 16px; }
.step-num {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #000; display: flex; align-items: center;
  justify-content: center; font-weight: 700;
}

/* ═══════════ Modal ═══════════ */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 400px; max-width: 92vw; position: relative; box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 12px; right: 16px; background: none; border: none;
  color: var(--text2); font-size: 1.4em; cursor: pointer;
}
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: .9em; color: var(--text2); }
.login-form input, .login-form select {
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 1em;
}
.tab-btn {
  background: none; border: 1px solid var(--border); color: var(--text2);
  padding: 6px 16px; border-radius: var(--radius); cursor: pointer; margin-right: 4px;
}
.tab-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }
#login-tabs { display: flex; gap: 4px; }

/* ═══════════ Forms & Inputs ═══════════ */
label { display: flex; flex-direction: column; gap: 4px; font-size: .9em; color: var(--text2); margin-bottom: 12px; }
input, select, textarea {
  padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .95em; font-family: inherit;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); }
.code-editor {
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  background: #010409; tab-size: 4; resize: vertical;
}

/* ═══════════ Studio ═══════════ */
.studio-config, .studio-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.studio-preview { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.studio-preview pre { white-space: pre-wrap; word-break: break-all; color: var(--green); font-size: .9em; }

/* ═══════════ LMS ═══════════ */
.problem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; margin-top: 20px; }
.problem-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; cursor: pointer; transition: .2s;
}
.problem-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.problem-card h4 { margin-bottom: 6px; }
.problem-card .meta { font-size: .8em; color: var(--text2); }
.lms-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.lms-timer { font-size: 1.3em; font-family: monospace; color: var(--yellow); }
.lms-desc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; white-space: pre-wrap; }
.lms-editor-area { margin-bottom: 12px; }
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lms-io { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.lms-io pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 80px; white-space: pre-wrap; font-size: .9em; }
.lms-actions { display: flex; gap: 8px; margin-bottom: 16px; }
#lms-result { padding: 16px; border-radius: var(--radius); margin-bottom: 16px; }
#lms-result.correct { background: rgba(63,185,80,.15); border: 1px solid var(--green); }
#lms-result.wrong { background: rgba(248,81,73,.15); border: 1px solid var(--red); }

/* ═══════════ Admin ═══════════ */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-tab { display: none; }
.admin-tab.active { display: block; }
.admin-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9em; }
.data-table th, .data-table td {
  padding: 10px 12px; border: 1px solid var(--border); text-align: left;
}
.data-table th { background: var(--surface); color: var(--text2); }
.data-table tbody tr:hover { background: rgba(88,166,255,.08); }

/* ═══════════ Footer ═══════════ */
footer {
  text-align: center; padding: 24px; border-top: 1px solid var(--border);
  color: var(--text2); font-size: .85em; margin-top: auto;
}
footer strong { color: var(--accent); }

/* ═══════════ Utils ═══════════ */
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.gen-table { margin-top: 12px; }

@media (max-width: 640px) {
  .lms-io { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2em; }
}
