:root {
    /* Kreda — školska tabla, kreda i papir */
    --color-board: #1F3D36;          /* tabla */
    --color-board-ink: #EEF3EF;      /* kreda na tabli */
    --color-tray: #8B6B45;           /* drvena polica table */
    --color-primary: #24614F;        /* zelena kreda — linkovi, glavna dugmad */
    --color-primary-dark: #1B4A3D;
    --color-accent: #F3C64B;         /* žuta kreda — akcenat */
    --color-accent-ink: #2A2410;
    --color-bg: #F2F4F0;
    --color-surface: #ffffff;
    --color-text: #1C2422;
    --color-text-muted: #5F6B66;
    --color-border: #DCE3DE;
    --color-success: #15803d;
    --color-error: #c2410c;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(31,61,54,0.06), 0 4px 14px -6px rgba(31,61,54,0.10);
    --font-display: "Bricolage Grotesque", -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-chalk: "Caveat Brush", "Comic Sans MS", cursive;
    font-size: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

/* --- Zaglavlje kao školska tabla sa drvenom policom --- */
.topbar {
    background: var(--color-board);
    border-bottom: 5px solid var(--color-tray);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 18px;
}

/* Logo: "kreda" kao glavni naziv, "kviz" ispisan kredom */
.brand { display: inline-flex; align-items: flex-end; gap: 2px; line-height: 1; text-decoration: none !important; }
.brand-kreda {
    font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; letter-spacing: -0.02em;
    color: var(--color-board-ink);
}
.brand-kviz {
    font-family: var(--font-chalk); font-size: 1.55rem; color: var(--color-accent);
    transform: rotate(-8deg) translateY(-9px); display: inline-block; margin-left: 3px;
    text-shadow: 0 0 1px rgba(243,198,75,0.6);
}
.brand:hover .brand-kviz { transform: rotate(-3deg) translateY(-9px); transition: transform .2s ease; }
@media (prefers-reduced-motion: reduce) { .brand:hover .brand-kviz { transition: none; } }

.topnav { display: flex; gap: 4px 16px; align-items: center; flex-wrap: wrap; font-size: 0.92rem; font-weight: 600; }
.topnav a { color: rgba(238,243,239,0.78); padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: #fff; text-decoration: none; border-bottom-color: rgba(243,198,75,0.6); }
.topnav a.active { color: #fff; border-bottom-color: var(--color-accent); }
.topnav a.nav-admin { color: var(--color-accent) !important; }
.logout-link { color: #F6A98A !important; }

.page-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px 60px;
    min-height: 60vh;
}

.footer { border-top: 1px solid var(--color-border); margin-top: 40px; }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 20px; color: var(--color-text-muted); font-size: 0.85rem; }
.footer-inner .brand-kreda { font-size: 1rem; color: var(--color-board); }
.footer-inner .brand-kviz { font-size: 1rem; color: var(--color-primary); transform: rotate(-6deg) translateY(-3px); }

/* Kartice */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.card + .card { margin-top: 18px; }

/* Naslov strane */
.page-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; letter-spacing: -0.015em; margin: 0 0 6px; }
.page-subtitle { color: var(--color-text-muted); margin: 0 0 24px; }

/* Forme */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.form-group .hint { color: var(--color-text-muted); font-size: 0.8rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(36,97,79,0.12);
}
textarea { resize: vertical; min-height: 90px; }

.btn {
    display: inline-block;
    padding: 11px 22px;
    border-radius: 9px;
    border: none;
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: 0.01em;
    font-size: 0.95rem;
    cursor: pointer;
    text-align: center;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-accent { background: var(--color-accent); color: var(--color-accent-ink); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.12); }
.btn-accent:hover { background: #EDB92E; text-decoration: none; }
.btn-outline { background: transparent; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn-outline:hover { background: rgba(36,97,79,0.06); text-decoration: none; }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.85rem; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 0.92rem; font-weight: 600; }
.alert-error { background: #fef2f2; color: var(--color-error); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }

/* Landing / početna strana — tabla sa natpisom */
.landing-hero {
    background: var(--color-board); color: var(--color-board-ink); border-radius: 16px;
    border-bottom: 8px solid var(--color-tray);
    padding: 44px 28px 40px; margin-bottom: 28px; text-align: center; position: relative; overflow: hidden;
}
.landing-hero::before { /* trag obrisane krede */
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse 60% 40% at 20% 30%, rgba(255,255,255,0.05), transparent 70%),
                radial-gradient(ellipse 50% 35% at 80% 75%, rgba(255,255,255,0.04), transparent 70%);
}
.landing-hero .brand { font-size: 1rem; justify-content: center; }
.landing-hero .brand-kreda { font-size: clamp(3rem, 9vw, 5rem); }
.landing-hero .brand-kviz { font-size: clamp(2.6rem, 7.5vw, 4.2rem); transform: rotate(-9deg) translateY(-0.55em); margin-left: 0.1em; }
.landing-hero p { color: rgba(238,243,239,0.82); font-size: 1.08rem; margin: 14px auto 0; max-width: 46ch; position: relative; }
.landing-cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; }
@media (max-width: 720px) {
    .landing-cols { grid-template-columns: 1fr; }
    .landing-hero { padding: 32px 18px 28px; }
}
.landing-col-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.badge-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.badge-student { background: var(--color-accent); }
.badge-teacher { background: var(--color-primary); }
.code-input { font-family: var(--font-display) !important; font-size: 1.6rem !important; font-weight: 800; letter-spacing: 0.25em !important; text-align: center; text-transform: uppercase; padding: 14px !important; }

/* Dashboard statistike */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-box { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-box .num { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; color: var(--color-primary); }
.stat-box .label { color: var(--color-text-muted); font-size: 0.82rem; margin-top: 4px; }

/* Tabele */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 0.92rem; }
th { color: var(--color-text-muted); font-weight: 700; font-size: 0.82rem; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }

.auth-wrap { max-width: 420px; margin: 30px auto; }
.form-footer-link { text-align: center; margin-top: 16px; font-size: 0.9rem; color: var(--color-text-muted); }

/* ===================== Python editor koda ===================== */
.gce { display: flex; background: #1e1f2b; border: 1px solid #2c2e3e; border-radius: 10px; overflow: hidden; position: relative; }
.gce:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(36,97,79,0.18); }
.gce-gutter, .gce-hl, .gce textarea.gce-input {
    font-family: "JetBrains Mono", "Fira Code", Consolas, "Cascadia Mono", Menlo, "Courier New", monospace;
    font-size: 14px; line-height: 21px; tab-size: 4; -moz-tab-size: 4; letter-spacing: 0;
    font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
.gce-gutter {
    margin: 0; padding: 12px 10px 12px 12px; min-width: 44px; text-align: right; color: #5c6178;
    background: #191a24; border-right: 1px solid #2c2e3e; user-select: none; overflow: hidden; flex-shrink: 0;
}
.gce-main { position: relative; flex: 1; min-width: 0; }
.gce-hl, .gce textarea.gce-input {
    position: absolute; inset: 0; margin: 0; padding: 12px 14px; border: 0; border-radius: 0;
    white-space: pre; overflow-wrap: normal; word-wrap: normal; box-sizing: border-box; width: 100%; height: 100%;
}
.gce-hl { color: #e4e6f0; overflow: hidden; pointer-events: none; }
.gce textarea.gce-input {
    color: transparent; -webkit-text-fill-color: transparent; caret-color: #fff; background: transparent;
    resize: none; min-height: 0; overflow-x: auto; overflow-y: hidden; outline: none; box-shadow: none;
}
.gce textarea.gce-input::selection { background: rgba(130,170,255,0.35); -webkit-text-fill-color: transparent; }
.gce textarea.gce-input[readonly] { caret-color: transparent; }
.gce-k { color: #c792ea; font-weight: 600; }
.gce-s { color: #c3e88d; }
.gce-c { color: #7f8aa3; }
.gce-n { color: #f78c6c; }
.gce-b { color: #82aaff; }
.gce-f { color: #ffcb6b; }
@media (max-width: 720px) {
    .gce-gutter, .gce-hl, .gce textarea.gce-input { font-size: 16px; line-height: 23px; } /* 16px sprečava zumiranje na iPhone-u */
    .gce-gutter { min-width: 34px; padding-left: 6px; padding-right: 6px; }
    .gce-hl, .gce textarea.gce-input { padding-left: 10px; padding-right: 10px; }
}
.code-readonly {
    background: #1e1f2b; color: #e4e6f0; border-radius: 8px; padding: 12px 14px; margin: 6px 0; overflow-x: auto;
    font-family: "JetBrains Mono", Consolas, Menlo, "Courier New", monospace; font-size: 13px; line-height: 1.55; white-space: pre;
}

/* Python panel (pokretanje, izlaz, testovi) */
.py-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.py-status { font-size: 0.82rem; color: var(--color-text-muted); }
.py-output {
    background: #0f1117; color: #d7dae3; border-radius: 8px; padding: 12px 14px; margin-top: 10px; min-height: 44px;
    font-family: Consolas, Menlo, "Courier New", monospace; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
    max-height: 320px; overflow-y: auto;
}
.py-output .err { color: #ff8a8a; }
.py-output .muted { color: #7f8aa3; }
.py-stdin { font-family: Consolas, Menlo, "Courier New", monospace !important; font-size: 14px !important; min-height: 60px !important; }
.py-examples { display: grid; gap: 8px; margin: 12px 0; }
.py-example { border: 1px solid var(--color-border); border-radius: 8px; padding: 10px 12px; background: #fafbff; font-size: 0.88rem; }
.py-example-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.py-example pre { margin: 4px 0 0; background: #f1f3f9; border-radius: 6px; padding: 6px 8px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.py-test-result { border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: 0.85rem; }
.py-test-result.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.py-test-result.fail { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.py-test-result pre { margin: 4px 0 0; white-space: pre-wrap; font-size: 12.5px; background: rgba(255,255,255,0.7); padding: 4px 6px; border-radius: 4px; }
.py-tests-table td, .py-tests-table th { vertical-align: top; }
.py-tests-table textarea { min-height: 54px; font-family: Consolas, Menlo, "Courier New", monospace; font-size: 13px; }
@media (max-width: 720px) { .py-example-grid { grid-template-columns: 1fr; } }

/* ===================== Slike uz pitanja ===================== */
.img-field { border: 1px dashed var(--color-border); border-radius: 10px; padding: 14px; background: #fcfcfe; }
.img-field.dragover { border-color: var(--color-primary); background: #EAF3EE; }
.img-field-preview { margin-top: 10px; display: none; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.img-field-preview img { max-width: 260px; max-height: 180px; border-radius: 8px; border: 1px solid var(--color-border); background: #fff; }
.img-field-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.img-field input[type=file] { font-size: 0.9rem; }
.question-image { display: block; max-width: 100%; max-height: 60vh; margin: 12px auto; border-radius: 10px; cursor: zoom-in; }
.img-zoom-overlay { position: fixed; inset: 0; background: rgba(10,10,18,0.92); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.img-zoom-overlay img { max-width: 100%; max-height: 100%; border-radius: 6px; background: #fff; }
.img-zoom-overlay .close-hint { position: absolute; top: 12px; right: 16px; color: #fff; font-weight: 700; font-size: 0.9rem; opacity: 0.8; }
.q-thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); vertical-align: middle; }

/* ===================== QR kod sesije ===================== */
.session-join-card { display: flex; gap: 20px; align-items: center; padding: 16px 20px; }
.qr-small { width: 132px; height: 132px; cursor: zoom-in; border-radius: 8px; border: 1px solid var(--color-border); padding: 4px; background: #fff; flex-shrink: 0; }
.qr-small svg, .qr-big svg { display: block; width: 100%; height: 100%; }
.qr-overlay { position: fixed; inset: 0; background: #fff; z-index: 1000; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; padding: 3vh 3vw; text-align: center; }
.qr-overlay.open { display: flex; }
.qr-big { width: min(70vh, 88vw); height: min(70vh, 88vw); }
.qr-overlay .qr-code-text { font-size: clamp(2rem, 7vh, 5rem); font-weight: 800; letter-spacing: 0.15em; color: var(--color-primary); line-height: 1; }
.qr-overlay .qr-url { color: var(--color-text-muted); font-size: clamp(0.9rem, 2.2vh, 1.3rem); word-break: break-all; }
.qr-overlay .qr-close { position: absolute; top: 16px; right: 16px; }
.qr-overlay .qr-count { font-weight: 700; color: var(--color-text); font-size: clamp(1rem, 2.4vh, 1.4rem); }
@media (max-width: 720px) { .session-join-card { flex-direction: column; text-align: center; } }

/* ===================== Kod i formule u tekstu pitanja ===================== */
.q-code {
    background: #1e1f2b; color: #e4e6f0; border-radius: 8px; padding: 10px 14px; margin: 10px 0; overflow-x: auto;
    font-family: "JetBrains Mono", Consolas, Menlo, "Courier New", monospace; font-size: 14px; line-height: 1.55; white-space: pre;
    font-weight: 400; text-align: left;
}
.q-inline-code { background: #f1f3f9; border: 1px solid #e4e7ec; border-radius: 4px; padding: 0 5px; font-family: Consolas, Menlo, "Courier New", monospace; font-size: 0.92em; }
.katex-display { margin: 0.6em 0; overflow-x: auto; overflow-y: hidden; }
.math-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.math-toolbar button { border: 1px solid var(--color-border); background: #fff; border-radius: 6px; padding: 4px 9px; font-size: 0.85rem; cursor: pointer; font-family: inherit; }
.math-toolbar button:hover { border-color: var(--color-primary); color: var(--color-primary); }
.math-preview { border: 1px dashed var(--color-border); border-radius: 8px; padding: 10px 12px; margin-top: 6px; background: #fcfcfe; font-size: 1rem; min-height: 40px; }
.math-preview:empty { display: none; }
