:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --border: #d9e0e8;
    --text: #1d2733;
    --muted: #5d6b7a;
    --primary: #2457c5;
    --primary-text: #ffffff;
    --primary-soft: #e3ebfb;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --success: #1f7a3f;
    --success-soft: #e6f4ea;
    --warning: #8a5a00;
    --warning-soft: #fff4dc;
    --status-available: #1f7a3f;
    --status-pending: #a76300;
    --status-booked: #b42318;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #12161c;
        --surface: #1a2029;
        --surface-2: #232b36;
        --border: #313b48;
        --text: #e6ebf1;
        --muted: #9aa7b6;
        --primary: #6f9bff;
        --primary-text: #0d1320;
        --primary-soft: #1f2d4a;
        --danger: #ff8a7a;
        --danger-soft: #3a1f1c;
        --success: #6fd394;
        --success-soft: #173323;
        --warning: #f3c063;
        --warning-soft: #3a2e12;
        --status-available: #6fd394;
        --status-pending: #f3c063;
        --status-booked: #ff8a7a;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h2:not(:first-child) { margin-top: 1.5rem; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; margin: 0; }

/* ---- Zaglavlje ---- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: .6rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1.5rem;
}

.brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    font-size: 1.05rem;
}
.brand span { color: var(--primary); }

.site-context {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.site-label { color: var(--muted); font-size: .9rem; }
.site-switch { display: flex; gap: .4rem; }
.site-switch select { max-width: 280px; }

.topbar-right {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.topbar-right form { margin: 0; }
.user { font-weight: 600; }
.flag { width: 20px; height: 15px; border-radius: 2px; box-shadow: 0 0 0 1px var(--border); flex: none; object-fit: cover; }

.lang-menu { position: relative; }
.lang-menu summary {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: .9rem;
    list-style: none;
    user-select: none;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: "▾"; color: var(--muted); font-size: .8rem; }
.lang-menu ul {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 4px);
    z-index: 20;
    min-width: 190px;
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    padding: .3rem;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(16, 24, 40, .15);
}
.lang-menu a {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .4rem .55rem;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.lang-menu a:hover, .lang-menu a:focus-visible { background: var(--surface-2); }
.lang-menu a[aria-current="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.nav {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    gap: .25rem;
    overflow-x: auto;
}
.nav-link {
    padding: .55rem .8rem;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.nav-sep { width: 1px; background: var(--border); margin: .5rem .5rem; }

/* ---- Sadržaj ---- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 1rem 3rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.panel.narrow { max-width: 720px; }

.master-detail {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 3fr;
    gap: 1rem;
    align-items: start;
}
.detail { min-width: 0; }

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 2.5rem 1rem;
}

.item-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}
.item-list a {
    display: block;
    padding: .5rem .6rem;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}
.item-list a:hover { background: var(--surface-2); }
.item-list a.active { background: var(--primary-soft); color: var(--primary); }
.item-list small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Forme ---- */
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field > span { font-size: .8rem; color: var(--muted); font-weight: 600; }

input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .45rem .6rem;
    width: 100%;
    min-width: 0;
}
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: .3rem; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.stack { display: flex; flex-direction: column; gap: .8rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.add-form { display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid var(--border); padding-top: 1rem; }

.row-form {
    display: flex;
    gap: .75rem;
    align-items: flex-end;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}
.row-form .field { flex: 1 1 160px; }
.row-form .field.grow { flex: 3 1 280px; }
.row-form > .grow { flex: 1 1 auto; min-width: 0; }
.row-form-new { border-bottom: 0; background: var(--surface-2); padding: .75rem; border-radius: var(--radius); margin-top: .75rem; }

.user-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: .75rem;
    align-items: end;
    padding: .9rem 0;
    border-bottom: 1px solid var(--border);
}
.user-form.row-form-new { padding: .9rem; }
.check { display: flex; align-items: center; gap: .4rem; padding-bottom: .5rem; }
/* Opsezi agent ključa (issue #48). */
.scopes { border: 0; padding: 0; margin: 0; }
.scopes legend { font-weight: 600; margin-bottom: .4rem; }
.scopes .check { align-items: flex-start; }

.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.btn {
    font: inherit;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 6px;
    padding: .45rem .9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }

.badge {
    font-size: .8rem;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 999px;
    padding: .15rem .6rem;
}

/* ---- Poruke ---- */
.alert {
    border-radius: var(--radius);
    padding: .7rem .9rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }

/* ---- Jezik sadržaja (issue #21) ---- */
.content-language {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}
.content-language.is-translation { border-color: var(--warning); background: var(--warning-soft); }
.content-language-form { display: flex; gap: .5rem; align-items: flex-end; }
.content-language-form select { min-width: 14rem; }
.content-language-note { flex: 1 1 320px; color: var(--warning); }
.content-language-note p { margin: 0; }
.content-language-note p + p { margin-top: .25rem; }
.default-value { display: block; font-size: .8rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.default-value::before { content: attr(data-label) ": "; font-weight: 600; }
.readonly-code { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; padding: .45rem 0; }
.untranslated { color: var(--warning); font-size: .8rem; font-weight: 600; }
.language-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.language-row:last-of-type { border-bottom: 0; }
.language-row .language-name { flex: 1 1 200px; font-weight: 600; }
.language-row .language-stats { flex: 2 1 240px; color: var(--muted); font-size: .9rem; }

/* ---- Javna početna stranica (issue #28) ---- */
.landing-hero { text-align: center; padding: 3rem 1rem 2rem; max-width: 820px; margin: 0 auto; }
.landing-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.2; margin-bottom: 1rem; }
.landing-lead { font-size: 1.15rem; color: var(--muted); margin: 0 auto 1.5rem; }
.landing-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-bottom: .75rem; }
.btn-large { padding: .7rem 1.4rem; font-size: 1.05rem; }
.landing-section { margin: 2.5rem auto; max-width: 1100px; }
.landing-section > h2 { text-align: center; font-size: 1.4rem; margin-bottom: 1.25rem; }
.landing-section h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.landing-section p { margin: 0; }
.landing-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.landing-step-number {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem; border-radius: 50%; margin-bottom: .6rem;
    background: var(--primary); color: var(--primary-text); font-weight: 700;
}
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.landing-audience { max-width: 820px; text-align: center; }
.landing-audience p + p { margin-top: .75rem; }
.landing-final { text-align: center; }
.landing-final p { margin-bottom: 1.25rem; color: var(--muted); }

/* ---- Registracija (issue #28) ---- */
.register-card { max-width: 560px; }
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row > .field { flex: 1 1 180px; }
.language-choice { border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .75rem .75rem; margin: 0; }
.language-choice legend { font-size: .8rem; color: var(--muted); font-weight: 600; padding: 0 .25rem; }
.language-choice[aria-invalid="true"], [aria-invalid="true"] { border-color: var(--danger); }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .25rem .75rem; margin-top: .5rem; }
.checkbox { display: flex; gap: .4rem; align-items: center; font-size: .9rem; }
.honeypot { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- Login i poruke ---- */
.login-card, .message-card {
    max-width: 400px;
    margin: 3rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.75rem;
}
.message-card { max-width: 520px; }

/* ---- Galerije ---- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}
.photo-card {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem;
    background: var(--surface);
}
.photo-thumb {
    display: block;
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    border-radius: 6px;
    overflow: hidden;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-order { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.photo-order .btn:disabled { opacity: .35; cursor: default; }
.photo-position { font-size: .85rem; color: var(--muted); }
.photo-name { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.preview-strip { display: flex; gap: .5rem; flex-wrap: wrap; }
.preview-strip img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ---- Objekti / zauzetost ---- */
.reservation-list { display: flex; flex-direction: column; }
.past-dates { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.past-dates form { margin: 0; }
.reservation-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .4rem .5rem;
    border-bottom: 1px solid var(--border);
    border-inline-start: 4px solid var(--border);
}
.reservation-row select { width: auto; min-width: 190px; }
.reservation-row .btn-danger { margin-inline-start: auto; }
.reservation-row.status-available { border-inline-start-color: var(--status-available); }
.reservation-row.status-pending { border-inline-start-color: var(--status-pending); }
.reservation-row.status-booked { border-inline-start-color: var(--status-booked); }
.reservation-row.past { opacity: .6; }
.reservation-date { min-width: 150px; font-variant-numeric: tabular-nums; }
.weekday { display: inline-block; width: 2.6rem; color: var(--muted); text-transform: capitalize; }

.key-result { margin-top: 1.25rem; display: flex; flex-direction: column; gap: .6rem; }
.key-result textarea { word-break: break-all; }

/* ---- Povijest promjena (issue #47) ---- */
.history-filter { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; }
.history-filter .field { min-width: 10rem; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item { border-top: 1px solid var(--border); padding: .6rem 0; }
.history-head { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; }
.history-head time { color: var(--muted); font-size: .9rem; min-width: 9rem; }
.history-head form { margin-inline-start: auto; }
.history-author { color: var(--muted); }
.history-delete .badge { background: var(--danger-soft); color: var(--danger); }
.badge-agent { margin-inline-start: .25rem; }
.history-changes { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; margin: .5rem 0 0; }
.history-changes dt { color: var(--muted); }
.history-changes dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.history-changes del { color: var(--danger); }
.history-changes ins { text-decoration: none; font-weight: 600; }

/* ---- Mobitel / tablet ---- */
@media (max-width: 860px) {
    .master-detail { grid-template-columns: 1fr; }
    .topbar-right { margin-inline-start: 0; }
}

@media (max-width: 600px) {
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .row-form { flex-direction: column; align-items: stretch; }
    .row-form .field, .row-form .field.grow { flex: 1 1 auto; }
    .reservation-row { flex-wrap: wrap; }
    .reservation-row select { min-width: 0; flex: 1; }
    .site-switch select { max-width: 100%; }
}
