/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --primary-text: #ffffff;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
    --nav-h: 56px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
    position: sticky; top: 0; z-index: 100;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: var(--shadow);
}

.nav-brand {
    display: flex; align-items: center; gap: 0.5rem;
    font-weight: 700; font-size: 1rem; color: var(--primary);
}

.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
    padding: 0.4rem 0.75rem; border-radius: var(--radius);
    color: var(--text-muted); font-weight: 500; font-size: 0.875rem;
    transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: #fef3c7; color: var(--primary-hover); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* ── Flash ────────────────────────────────────────────────────────────────── */
.flash-container { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.flash {
    padding: 0.75rem 1rem; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.back-link { color: var(--text-muted); font-size: 0.8rem; display: block; margin-bottom: 0.25rem; }
.back-link:hover { color: var(--primary); }

/* ── Card ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
}
.card-header h2 { font-size: 0.95rem; font-weight: 600; }
.card-header h3 { font-size: 0.875rem; font-weight: 600; }
.empty-card { padding: 2.5rem; text-align: center; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    padding: 0.5rem 1rem; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: all .15s; white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline  { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover  { background: var(--bg); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover   { background: var(--danger-hover); }
.btn-success  { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.65rem 1.25rem; text-align: left; }
.table th { font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
            letter-spacing: .04em; color: var(--text-muted); background: var(--bg);
            border-bottom: 1px solid var(--border); }
.table td { border-bottom: 1px solid var(--border-light); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbfc; }
.text-right { text-align: right !important; }
.nowrap { white-space: nowrap; }

/* ── Badge ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 0.15rem 0.5rem;
    border-radius: 9999px; font-size: 0.7rem; font-weight: 600;
    background: #f1f5f9; color: var(--text-muted);
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray  { background: #f1f5f9; color: var(--text-muted); }

/* ── Form ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 500;
                    margin-bottom: 0.35rem; color: var(--text-muted); }
.form-compact { padding: 1.25rem; }
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }
.divider { border: none; border-top: 1px solid var(--border-light); margin: 1.25rem 0; }

.input {
    display: block; width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.875rem; color: var(--text); background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.input-sm { padding: 0.3rem 0.5rem; font-size: 0.8rem; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.45); align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-md); width: 100%; max-width: 440px;
    padding: 1.5rem; margin: 1rem;
}
.modal-wide {
    max-width: 860px; max-height: 92vh;
    display: flex; flex-direction: column; padding: 1.25rem;
}
.poglej-vsebina {
    flex: 1; overflow: auto; min-height: 400px;
    display: flex; align-items: center; justify-content: center;
}
.poglej-iframe {
    width: 100%; height: 75vh; border: none; border-radius: 4px;
}
.poglej-slika {
    max-width: 100%; max-height: 75vh;
    object-fit: contain; border-radius: 4px;
    box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 1.25rem;
    cursor: pointer; color: var(--text-muted); padding: 0.1rem 0.4rem;
    border-radius: 4px; line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ── Dropdown ─────────────────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: calc(100% + 4px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    min-width: 200px; z-index: 50; overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-menu a {
    display: block; padding: 0.75rem 1rem;
    font-size: 0.875rem; color: var(--text);
    transition: background .1s;
}
.dropdown-menu a:hover { background: var(--bg); }

/* ── Stats ────────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
              gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem; text-align: center;
    box-shadow: var(--shadow);
}
.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label  { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-top: 0.25rem; }

/* ── Dashboard grid ───────────────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ── Stranka grid ─────────────────────────────────────────────────────────── */
.stranka-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 768px) { .stranka-grid { grid-template-columns: 1fr; } }

/* ── Izpolni grid ─────────────────────────────────────────────────────────── */
.izpolni-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 768px) { .izpolni-grid { grid-template-columns: 1fr; } }

/* ── Doc list ─────────────────────────────────────────────────────────────── */
.doc-list { list-style: none; }
.doc-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border-light);
}
.doc-item:last-child { border-bottom: none; }
.doc-info { display: flex; align-items: center; gap: 0.75rem; }
.doc-icon { font-size: 1.25rem; }

/* ── Mapper ───────────────────────────────────────────────────────────────── */
.stran-nav { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

.mapper-layout {
    display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; align-items: start;
}
@media (max-width: 900px) { .mapper-layout { grid-template-columns: 1fr; } }

.mapper-left { position: sticky; top: calc(var(--nav-h) + 1rem); }

.mapper-container {
    position: relative; display: inline-block;
    border: 2px solid var(--border); border-radius: var(--radius);
    cursor: crosshair; overflow: hidden; width: 100%;
    box-shadow: var(--shadow-md);
}
.mapper-container img { display: block; width: 100%; height: auto; user-select: none; }

#markers-layer { position: absolute; inset: 0; pointer-events: none; }

.marker {
    position: absolute; transform: translate(-50%, -50%);
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,.3);
    pointer-events: auto; cursor: pointer;
    border: 2px solid #fff;
}
.marker-pending { background: #6366f1; animation: pulse .8s infinite; }
.marker-dragging { background: #16a34a; transform: translate(-50%, -50%) scale(1.3);
                   box-shadow: 0 4px 12px rgba(0,0,0,.4); z-index: 10; }
@keyframes pulse {
    0%,100% { transform: translate(-50%,-50%) scale(1); }
    50% { transform: translate(-50%,-50%) scale(1.2); }
}

.polja-seznam { overflow-y: auto; max-height: 400px; }
.polje-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.65rem 1.25rem; border-bottom: 1px solid var(--border-light);
}
.polje-item:last-child { border-bottom: none; }
.polje-info { display: flex; align-items: center; gap: 0.65rem; }
.marker-badge {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.novo-polje-panel {
    border-top: 1px solid var(--border);
    padding: 1.25rem;
    background: #fffbeb;
}

/* ── Info block ───────────────────────────────────────────────────────────── */
.info-block { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; }
.info-row { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.875rem; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.empty-state { color: var(--text-muted); font-size: 0.875rem; padding: 1.25rem; text-align: center; }
.empty-state a { color: var(--primary); text-decoration: underline; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.fw-medium { font-weight: 500; }
.link-primary { color: var(--primary-hover); font-weight: 500; }
.link-primary:hover { text-decoration: underline; }
.list-simple { list-style: none; padding: 0 1.25rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.help-list { padding: 1.25rem 1.25rem 1.25rem 2.25rem; display: flex; flex-direction: column; gap: 0.6rem;
             font-size: 0.875rem; color: var(--text-muted); }
.help-list strong { color: var(--text); }
.help-list code { background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 4px;
                  font-size: 0.8rem; color: var(--primary-hover); }

/* ── Drag & drop ──────────────────────────────────────────────────────────── */
.sortable-ghost td { opacity: 0.4; background: #e0f2fe !important; }
.sortable-chosen { box-shadow: 0 4px 12px rgba(0,0,0,.15); }

/* ── Vir badge ────────────────────────────────────────────────────────────── */
.vir-badge {
    display: inline-block; padding: 0.15rem 0.5rem;
    border-radius: 9999px; font-size: 0.7rem; font-weight: 500;
    border: 1px solid rgba(0,0,0,.08); max-width: 160px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Legenda ──────────────────────────────────────────────────────────────── */
.legenda {
    display: flex; flex-wrap: wrap; gap: 0.4rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-light);
}
.legenda-item {
    padding: 0.2rem 0.65rem; border-radius: 9999px;
    font-size: 0.72rem; font-weight: 500;
    border: 1px solid rgba(0,0,0,.08);
}

/* ── Legenda barv strank ─────────────────────────────────────────────────── */
.stranke-legenda {
    display: flex; flex-wrap: wrap; gap: 0.5rem;
    margin-bottom: 1rem;
}
.stranke-legenda-item {
    padding: 0.3rem 0.85rem; border-radius: 9999px;
    font-size: 0.78rem; font-weight: 500;
    border: 1px solid rgba(0,0,0,.08);
}

/* ── Color picker za stranke ─────────────────────────────────────────────── */
.stranka-color-dot {
    display: inline-block; width: 18px; height: 18px;
    border-radius: 50%; cursor: pointer;
    vertical-align: middle;
    transition: transform .15s;
}
.stranka-color-dot:hover { transform: scale(1.25); }

.stranka-color-picker {
    display: none; position: absolute;
    left: 0; top: 100%; z-index: 50;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 0.4rem; gap: 0.3rem;
    flex-direction: column; min-width: 160px;
}
.stranka-color-picker.open { display: flex; }
.stranka-color-picker span {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.3rem 0.5rem; border-radius: 5px;
    cursor: pointer; font-size: 0.8rem; font-weight: 500;
    transition: opacity .15s;
}
.stranka-color-picker span::before {
    content: ''; display: inline-block;
    width: 14px; height: 14px; border-radius: 50%;
    background: inherit; flex-shrink: 0;
}
.stranka-color-picker span:hover { opacity: 0.8; }

/* ── Color picker ─────────────────────────────────────────────────────────── */
.td-drag-color { width: 52px; padding: 0 0.4rem; white-space: nowrap; }
.td-drag-color .drag-handle { cursor: grab; color: #cbd5e1; font-size: 1rem; vertical-align: middle; }
.td-drag-color .drag-handle:active { cursor: grabbing; }

.color-dot {
    display: inline-block; width: 14px; height: 14px;
    border-radius: 50%; border: 1.5px solid rgba(0,0,0,.2);
    cursor: pointer; vertical-align: middle; margin-left: 4px;
    transition: transform .15s;
}
.color-dot:hover { transform: scale(1.3); }

.color-picker {
    display: none; position: absolute; z-index: 100;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 0.4rem 0.5rem; gap: 0.35rem;
    flex-direction: row; align-items: center;
}
.color-picker.open { display: flex; }

.cp-opt {
    width: 20px; height: 20px; border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,.15); cursor: pointer;
    transition: transform .15s, box-shadow .15s; flex-shrink: 0;
}
.cp-opt:hover { transform: scale(1.25); box-shadow: 0 2px 6px rgba(0,0,0,.2); }

/* ── Tabela podatkov – scroll + sticky akcije ─────────────────────────────── */
.table-podatki-wrap { overflow-x: auto; }
.table-podatki .th-akcije,
.table-podatki .td-akcije {
    position: sticky;
    right: 0;
    z-index: 2;
    white-space: nowrap;
    text-align: right;
    box-shadow: -3px 0 6px rgba(0,0,0,.06);
}
.table-podatki .th-akcije {
    background: var(--bg);
}
.table-podatki .td-akcije {
    background: inherit;
}
/* Vsaka obarvana vrstica mora imeti explicitno barvo ozadja na sticky celici */
.table-podatki tbody tr .td-akcije::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    z-index: -1;
}

/* ── Vrstni red input ─────────────────────────────────────────────────────── */
.td-vrstni-red { width: 52px; padding: 0.4rem 0.3rem; }
.vrstni-red-input {
    width: 46px; text-align: center; padding: 0.25rem 0.3rem;
    font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
    -moz-appearance: textfield;
}
.vrstni-red-input::-webkit-outer-spin-button,
.vrstni-red-input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ── Urejanje ključa ──────────────────────────────────────────────────────── */
.td-kljuc { min-width: 160px; }
.kljuc-prikaz {
    cursor: pointer; border-bottom: 1px dashed transparent;
    transition: border-color .15s;
}
.kljuc-prikaz:hover { border-bottom-color: var(--primary); color: var(--primary-hover) !important; }
.kljuc-input { width: 100%; min-width: 140px; }

/* ── Ekstra ključi ────────────────────────────────────────────────────────── */
.row-ekstra td { opacity: 0.45; }
.row-ekstra:hover td { opacity: 0.75; transition: opacity .15s; }
.ekstra-separator td {
    padding: 0.4rem 1.25rem;
    background: var(--bg);
    border-top: 2px dashed var(--border);
    border-bottom: 1px solid var(--border);
    text-align: center;
}

/* ── Opombe ───────────────────────────────────────────────────────────────── */
.opomba-sekcija {
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--border-light);
    background: #fffbeb;
}
.opomba-label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 0.5rem;
}
.opomba-textarea {
    width: 100%; min-height: 100px; max-height: 300px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.875rem; font-family: inherit; color: var(--text);
    background: var(--surface); resize: vertical; outline: none;
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.6;
}
.opomba-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}
.opomba-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 0.5rem;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
