/* ================= Tasarım değişkenleri ================= */
:root {
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --brand-soft: rgba(79, 70, 229, .10);
    --ok: #16a34a;
    --ok-soft: rgba(22, 163, 74, .12);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, .12);
    --bad: #dc2626;
    --bad-soft: rgba(220, 38, 38, .10);
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --border: #e5e7ef;
    --text: #1f2333;
    --muted: #6b7189;
    --sidebar: #12142b;
    --sidebar-text: #b5b9d6;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --mono: "JetBrains Mono", Consolas, monospace;
}

[data-bs-theme="dark"] {
    --brand-soft: rgba(129, 120, 255, .16);
    --bg: #0d0f1c;
    --surface: #161a2e;
    --surface-2: #1c2138;
    --border: #262c47;
    --text: #e6e8f5;
    --muted: #8e94b3;
    --sidebar: #0a0c18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}

html, body { height: 100%; }
body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
[data-bs-theme="dark"] a { color: #a5a0ff; }
.text-muted, .muted { color: var(--muted) !important; }
.font-mono { font-family: var(--mono); }

/* ================= Uygulama iskeleti ================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    z-index: 1040;
    transition: transform .25s ease;
}
.sidebar .brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.25rem 1.25rem 1rem;
    color: #fff; font-weight: 700; font-size: 1.1rem;
}
.brand-logo {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    display: grid; place-items: center; color: #fff;
    font-family: var(--mono); font-weight: 700; font-size: .95rem;
    box-shadow: 0 6px 18px rgba(79, 70, 229, .45);
}
.nav-section { padding: .9rem 1.25rem .35rem; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #6c7096; }
.side-link {
    display: flex; align-items: center; gap: .7rem;
    margin: 2px .75rem; padding: .6rem .75rem;
    border-radius: 10px; color: var(--sidebar-text) !important;
    font-weight: 500; transition: background .15s, color .15s;
}
.side-link i { font-size: 1.05rem; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff !important; }
.side-link.active { background: linear-gradient(135deg, rgba(79, 70, 229, .9), rgba(124, 58, 237, .9)); color: #fff !important; box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }
.sidebar-footer { margin-top: auto; padding: 1rem; border-top: 1px solid rgba(255, 255, 255, .06); }
.user-chip { display: flex; align-items: center; gap: .65rem; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; flex-shrink: 0;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff; font-weight: 700; font-size: .85rem;
}
.user-chip .name { color: #fff; font-weight: 600; font-size: .875rem; line-height: 1.2; }
.user-chip .role { font-size: .75rem; color: #8b8fb5; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 64px; display: flex; align-items: center; gap: 1rem;
    padding: 0 1.5rem; background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1030;
}
.topbar h1 { font-size: 1.1rem; font-weight: 700; margin: 0; }
.topbar .crumb { color: var(--muted); font-size: .8rem; }
.app-content { padding: 1.5rem; flex: 1; }
.app-content.flush { padding: 0; }

.icon-btn {
    width: 38px; height: 38px; border-radius: 10px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.menu-toggle { display: none; }

@media (max-width: 991px) {
    .sidebar { position: fixed; left: 0; transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .menu-toggle { display: inline-grid; }
    .app-content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}
.app-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 1035; }
.app-backdrop.show { display: block; }

/* ================= Kartlar ve bileşenler ================= */
.card-x {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-x .card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.card-x .card-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.card-body-x { padding: 1.25rem; }

.stat {
    padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem;
}
.stat .ico {
    width: 46px; height: 46px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0;
}
.stat .val { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .8rem; font-weight: 500; }
.ico-brand { background: var(--brand-soft); color: var(--brand); }
.ico-ok { background: var(--ok-soft); color: var(--ok); }
.ico-warn { background: var(--warn-soft); color: var(--warn); }
.ico-bad { background: var(--bad-soft); color: var(--bad); }

.pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .6rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill-brand { background: var(--brand-soft); color: var(--brand); }

.btn { border-radius: 10px; font-weight: 600; font-size: .875rem; padding: .5rem .95rem; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; border-radius: 8px; }
.btn-brand {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; border: 0; box-shadow: 0 4px 14px rgba(79, 70, 229, .35);
}
.btn-brand:hover, .btn-brand:focus { color: #fff; filter: brightness(1.08); }
.btn-success-x { background: var(--ok); color: #fff; border: 0; box-shadow: 0 4px 14px rgba(22, 163, 74, .3); }
.btn-success-x:hover { color: #fff; filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.form-control, .form-select {
    border-radius: 10px; border-color: var(--border);
    background-color: var(--surface); color: var(--text);
    padding: .55rem .8rem; font-size: .9rem;
}
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.form-label { font-weight: 600; font-size: .82rem; margin-bottom: .35rem; }

.search-box { position: relative; }
.search-box i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { padding-left: 2.3rem; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
    border: 0; background: transparent; color: var(--muted);
    padding: .35rem .8rem; border-radius: 8px; font-weight: 600; font-size: .8rem;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

.progress-x { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-x > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; transition: width .6s ease; }

.table-x { width: 100%; margin: 0; }
.table-x th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 700; background: var(--surface-2);
    padding: .7rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-x td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table-x tbody tr:hover { background: var(--surface-2); }
.table-x tbody tr:last-child td { border-bottom: 0; }

.empty {
    text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty i { font-size: 2.5rem; display: block; margin-bottom: .75rem; opacity: .6; }

/* ================= Soru kartları ================= */
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.q-card {
    display: flex; flex-direction: column; gap: .75rem;
    padding: 1.15rem; color: var(--text) !important;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.q-card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: 0 10px 30px rgba(79, 70, 229, .15); }
.q-card .q-num { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.q-card h3 { font-size: 1rem; font-weight: 700; margin: 0; }
.q-card .q-desc { color: var(--muted); font-size: .85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.q-card .q-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }

/* ================= Giriş ekranı ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
    background: radial-gradient(1200px 600px at 10% 10%, rgba(124, 58, 237, .55), transparent),
                radial-gradient(800px 500px at 90% 90%, rgba(79, 70, 229, .6), transparent), #0d0f24;
    color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-hero h2 { font-size: 2.2rem; font-weight: 800; line-height: 1.2; max-width: 460px; }
.auth-hero p { color: #c7c9e8; max-width: 440px; }
.hero-code {
    font-family: var(--mono); font-size: .85rem; background: rgba(0, 0, 0, .35);
    border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; padding: 1.1rem 1.25rem;
    max-width: 440px; color: #d6d8f5; backdrop-filter: blur(6px); white-space: pre;
}
.hero-code .k { color: #c792ea; } .hero-code .s { color: #c3e88d; } .hero-code .t { color: #82aaff; } .hero-code .c { color: #697098; }
.hero-feats { display: flex; flex-wrap: wrap; gap: .5rem; }
.hero-feats span { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); padding: .35rem .75rem; border-radius: 999px; font-size: .8rem; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 1.6rem; font-weight: 800; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ================= Çözüm ekranı (IDE) ================= */
.ide {
    display: grid; grid-template-columns: minmax(300px, 34%) 1fr;
    height: calc(100vh - 64px);
}
.ide-left { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.ide-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tabs-x { display: flex; gap: .25rem; padding: 0 .75rem; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; overflow-x: auto; }
.tabs-x button {
    border: 0; background: none; color: var(--muted);
    padding: .75rem .85rem; font-weight: 600; font-size: .83rem;
    border-bottom: 2px solid transparent; white-space: nowrap;
    display: inline-flex; align-items: center; gap: .4rem;
}
.tabs-x button.active { color: var(--brand); border-bottom-color: var(--brand); }
[data-bs-theme="dark"] .tabs-x button.active { color: #a5a0ff; border-bottom-color: #a5a0ff; }
.tab-pane-x { display: none; overflow: auto; flex: 1; min-height: 0; }
.tab-pane-x.active { display: block; }
.prose { padding: 1.25rem; line-height: 1.65; }
.prose h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: .75rem; }
.prose .desc { white-space: pre-wrap; }
.sample { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 1rem; }
.sample .sample-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .85rem; background: var(--surface-2); font-size: .78rem; font-weight: 700; color: var(--muted); }
.sample pre { margin: 0; padding: .75rem .85rem; font-family: var(--mono); font-size: .83rem; white-space: pre-wrap; }
.sample .cols { display: grid; grid-template-columns: 1fr 1fr; }
.sample .cols > div + div { border-left: 1px solid var(--border); }

.editor-bar {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
    padding: .5rem .75rem; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.editor-bar .file { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--mono); font-size: .8rem; color: var(--muted); padding: .3rem .6rem; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); }
.editor-bar .spacer { flex: 1; }
.editor-wrap { flex: 1; min-height: 160px; position: relative; }
#editor { position: absolute; inset: 0; }

.splitter { height: 6px; cursor: row-resize; background: var(--border); flex-shrink: 0; position: relative; }
.splitter::after { content: ""; position: absolute; left: 50%; top: 2px; width: 40px; height: 2px; margin-left: -20px; background: var(--muted); border-radius: 2px; opacity: .5; }
.splitter:hover, .splitter.drag { background: var(--brand); }

.console { height: 260px; display: flex; flex-direction: column; background: var(--surface); flex-shrink: 0; min-height: 90px; }
.console .tab-pane-x { padding: .75rem; }
.console-out {
    font-family: var(--mono); font-size: .85rem; white-space: pre-wrap; margin: 0;
    background: #0f1222; color: #d7dbf5; border-radius: 10px; padding: .85rem 1rem; min-height: 100%;
}
.console-out .err { color: #ff8a80; }
.console-out .sys { color: #7f86b3; }
.console-out .ok { color: #69f0ae; }
.console textarea { font-family: var(--mono); font-size: .85rem; height: 100%; min-height: 120px; resize: none; }
.status-bar {
    display: flex; align-items: center; gap: 1rem; padding: .3rem .85rem; font-size: .75rem;
    background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; flex-shrink: 0;
}
.status-bar .spacer { flex: 1; }

.test-item { border: 1px solid var(--border); border-radius: 12px; margin-bottom: .6rem; overflow: hidden; background: var(--surface); }
.test-item .t-head { display: flex; align-items: center; gap: .6rem; padding: .6rem .85rem; font-weight: 600; font-size: .85rem; }
.test-item .t-body { padding: 0 .85rem .85rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.test-item .t-body pre { margin: 0; font-family: var(--mono); font-size: .78rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem; white-space: pre-wrap; max-height: 160px; overflow: auto; }
.test-item .t-body small { font-weight: 700; color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.score-banner { display: flex; align-items: center; gap: 1rem; padding: 1rem; border-radius: 12px; margin-bottom: .75rem; }
.score-banner .big { font-size: 1.6rem; font-weight: 800; }

@media (max-width: 991px) {
    .ide { grid-template-columns: 1fr; height: auto; }
    .ide-left { border-right: 0; border-bottom: 1px solid var(--border); max-height: 45vh; }
    .ide-right { height: calc(100vh - 64px); }
    .test-item .t-body { grid-template-columns: 1fr; }
}

/* ================= Öğretmen ================= */
.tc-row { border: 1px solid var(--border); border-radius: 12px; padding: .85rem; background: var(--surface-2); margin-bottom: .75rem; }
.tc-row textarea { font-family: var(--mono); font-size: .83rem; }
.tc-row .tc-num { font-weight: 700; font-size: .8rem; color: var(--muted); }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix th:first-child { background: var(--surface-2); }
.cell { display: inline-grid; place-items: center; min-width: 46px; padding: .25rem .4rem; border-radius: 8px; font-weight: 700; font-size: .78rem; }
.code-view { font-family: var(--mono); font-size: .83rem; background: #0f1222; color: #d7dbf5; border-radius: 10px; padding: 1rem; max-height: 60vh; overflow: auto; white-space: pre; }

/* ================= Toast ================= */
.toast-stack { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; }
.toast-x {
    display: flex; align-items: center; gap: .65rem; min-width: 260px; max-width: 380px;
    padding: .8rem 1rem; border-radius: 12px; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    animation: toastIn .25s ease; font-weight: 500;
}
.toast-x i { font-size: 1.2rem; }
.toast-x.ok i { color: var(--ok); } .toast-x.bad i { color: var(--bad); } .toast-x.info i { color: var(--brand); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

kbd { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: .1rem .4rem; font-size: .75rem; font-family: var(--mono); }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-header, .modal-footer { border-color: var(--border); }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
