/* ── Pregled screen layout ───────────────────────────────────── */
#screen-pregled { display: none; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
#screen-pregled.active { display: flex; }

.pregled-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }

/* Main scroll area */
.pregled-main { flex: 1; overflow-y: auto; padding: 16px 20px; background: var(--clr-bg); min-width: 0; }

/* Sticky sidebar */
.pregled-sidebar {
  width: 272px; flex-shrink: 0;
  border-left: 1px solid var(--clr-border);
  background: #fff; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 14px 14px 80px;
}

/* Header */
.pregled-header {
  background: #fff; border-bottom: 1px solid var(--clr-border);
  padding: 12px 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pregled-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pregled-title { font-size: var(--fs-xl); font-weight: 700; color: var(--clr-primary); white-space: nowrap; }
.pregled-bridge-sel { padding: 5px 10px; border: 1px solid var(--clr-border); border-radius: var(--r-md); font-size: var(--fs-md); color: var(--clr-primary); background: var(--clr-bg-hover); min-width: 220px; max-width: 320px; }
.pregled-bridge-sel:focus { border-color: var(--clr-accent); outline: none; }
.pregled-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Meta card */
.pregled-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr) 2fr; gap: 10px 14px; }

/* Geodetska card */
.geodetska-card { display: none; }
.geodetska-card.visible { display: block; }
.geod-option-group { display: flex; flex-direction: column; gap: 6px; }
.geod-radio-label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); cursor: pointer; }
.geod-alert-banner {
  display: none; margin-top: 8px;
  background: #ffebee; border: 1px solid #ef9a9a; color: #c62828;
  border-radius: var(--r-md); padding: 8px 12px; font-size: var(--fs-sm); font-weight: 500;
}
.geod-alert-banner.visible { display: flex; align-items: center; gap: 8px; }

/* Element group accordions */
.elem-group { border: 1px solid var(--clr-border); border-radius: var(--r-lg); margin-bottom: 10px; overflow: hidden; }
.elem-group-head {
  background: var(--clr-bg-hover); padding: 9px 14px;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; border-bottom: 1px solid var(--clr-border);
}
.elem-group-head:hover { background: #edf2f7; }
.elem-group-title { font-size: var(--fs-base); font-weight: 700; color: var(--clr-primary); letter-spacing: 0.04em; }
.elem-group-meta  { font-size: var(--fs-xs); color: var(--clr-muted); }
.elem-group-arrow { font-size: 11px; color: var(--clr-muted); transition: transform 0.2s; }
.elem-group.collapsed .elem-group-arrow { transform: rotate(-90deg); }
.elem-group-body { overflow: hidden; }
.elem-group.collapsed .elem-group-body { display: none; }

/* Element table */
.elem-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.elem-table th {
  text-align: left; padding: 5px 7px;
  background: #f8f9fb; color: var(--clr-muted);
  font-weight: 500; font-size: 10px; text-transform: uppercase;
  border-bottom: 1px solid var(--clr-border); white-space: nowrap;
}
.elem-table td { padding: 6px 7px; border-bottom: 1px solid var(--clr-border-light); vertical-align: middle; }
.elem-table tr:last-child td { border-bottom: none; }
.elem-table tr.disabled td { opacity: 0.45; }
.elem-table tr.disabled .elem-select { background: #f0f2f5; }

.elem-name-cell { font-weight: 500; color: var(--clr-primary); white-space: nowrap; }
.oze-tag { font-size: 9px; background: var(--clr-bg-hover); color: var(--clr-muted); border: 1px solid var(--clr-border); border-radius: 4px; padding: 1px 4px; margin-right: 5px; font-weight: 600; }

.status-radio-group { display: flex; flex-direction: column; gap: 2px; }
.status-radio-label { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); cursor: pointer; white-space: nowrap; }

.elem-select {
  border: 1px solid var(--clr-border); border-radius: var(--r-sm);
  padding: 3px 6px; font-size: var(--fs-xs); color: var(--clr-text);
  background: var(--clr-bg-hover); width: 100%; min-width: 60px;
}
.elem-select:focus { border-color: var(--clr-accent); outline: none; }
.elem-select:disabled { background: #f0f2f5; color: #aaa; }

.elem-komentar {
  width: 100%; min-width: 120px; border: 1px solid var(--clr-border); border-radius: var(--r-sm);
  padding: 3px 6px; font-size: var(--fs-xs); resize: vertical; min-height: 28px;
  background: var(--clr-bg-hover); font-family: inherit;
}
.elem-komentar:focus { border-color: var(--clr-accent); outline: none; background: #fff; }
.elem-komentar:disabled { background: #f0f2f5; color: #aaa; }

.ose-cell {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700;
  padding: 2px 6px; border-radius: var(--r-sm); min-width: 28px;
}
.ose-high { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.ose-mid  { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.ose-low  { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.ose-na   { color: var(--clr-muted); font-size: var(--fs-xs); }
.ose-err  { color: #e64a19; font-size: var(--fs-xs); }

/* ISM cap alert */
.ism-cap-alert {
  display: none; margin-top: 6px;
  background: #fff8e1; border: 1px solid #ffe082; color: #f57f17;
  border-radius: var(--r-md); padding: 6px 10px;
  font-size: var(--fs-xs); font-weight: 500;
  align-items: center; gap: 6px;
}
.ism-cap-alert.visible { display: flex; }

/* Mjere section */
.mjere-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.mjere-table th {
  text-align: left; padding: 5px 8px;
  background: var(--clr-bg-hover); color: var(--clr-muted);
  font-weight: 500; font-size: var(--fs-xs);
  border-bottom: 1px solid var(--clr-border);
}
.mjere-table td { padding: 5px 6px; border-bottom: 1px solid var(--clr-border-light); vertical-align: middle; }
.mjere-table tr:last-child td { border-bottom: none; }

.mjera-opis-inp {
  width: 100%; border: 1px solid var(--clr-border); border-radius: var(--r-sm);
  padding: 4px 7px; font-size: var(--fs-sm); resize: none; min-height: 28px;
  background: var(--clr-bg-hover); font-family: inherit;
}
.mjera-opis-inp:focus { border-color: var(--clr-accent); outline: none; background: #fff; }
.mjera-num-inp {
  width: 72px; border: 1px solid var(--clr-border); border-radius: var(--r-sm);
  padding: 4px 6px; font-size: var(--fs-sm); text-align: right;
  background: var(--clr-bg-hover);
}
.mjera-num-inp:focus { border-color: var(--clr-accent); outline: none; background: #fff; }
.mjera-jed-sel {
  width: 60px; border: 1px solid var(--clr-border); border-radius: var(--r-sm);
  padding: 4px 4px; font-size: var(--fs-sm); background: var(--clr-bg-hover);
  cursor: pointer;
}
.mjera-jed-sel:focus { border-color: var(--clr-accent); outline: none; background: #fff; }
.mjera-ukupno { font-weight: 600; color: var(--clr-primary); text-align: right; white-space: nowrap; }
.mjere-total-row td { font-weight: 700; background: var(--clr-bg-hover); }

/* Sidebar results */
.sidebar-section { margin-bottom: 14px; }
.sidebar-section-title { font-size: 9px; font-weight: 700; color: var(--clr-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px; }
.sidebar-big-num { font-size: 32px; font-weight: 700; margin: 2px 0; }
.sidebar-num-label { font-size: var(--fs-xs); color: var(--clr-muted); margin-top: 2px; }
.sidebar-divider { height: 1px; background: var(--clr-border); margin: 12px 0; }
.sidebar-fzm-row { display: flex; gap: 8px; justify-content: space-between; font-size: var(--fs-xs); color: var(--clr-muted); margin-bottom: 6px; }
.sidebar-fzm-val { font-weight: 600; color: var(--clr-primary); }

.kp-stat-row { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--clr-muted); margin-top: 4px; }
.kp-big { font-size: 20px; font-weight: 700; color: var(--clr-primary); }

/* Submit bar (bottom of sidebar, sticky) */
.sidebar-submit-area {
  position: sticky; bottom: 0;
  background: #fff; border-top: 1px solid var(--clr-border);
  padding: 10px 0 0; margin-top: auto;
}

/* Bridge info bar in header */
.bridge-info-bar { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--clr-muted); }
.bridge-info-name { font-weight: 600; color: var(--clr-primary); font-size: var(--fs-base); }
.bridge-info-code { font-family: monospace; font-size: var(--fs-xs); background: var(--clr-bg-hover); padding: 2px 7px; border-radius: 4px; }
.bridge-info-sep { color: var(--clr-border); }

/* Error banner in pregled */
.pregled-error {
  background: var(--clr-error-bg); color: var(--clr-error);
  border: 1px solid var(--clr-error-border); border-radius: var(--r-md);
  padding: 8px 12px; font-size: var(--fs-sm); margin-bottom: 10px; display: none;
}
.pregled-error.visible { display: block; }

/* Napomena field */
.napomena-inp {
  width: 100%; border: 1px solid var(--clr-border); border-radius: var(--r-md);
  padding: 7px 10px; font-size: var(--fs-md); resize: vertical; min-height: 40px;
  background: var(--clr-bg-hover); font-family: inherit; color: var(--clr-text);
}
.napomena-inp:focus { border-color: var(--clr-accent); outline: none; background: #fff; }

.periodika-info { font-size: var(--fs-xs); color: var(--clr-muted); margin-top: 4px; font-style: italic; }

/* ── Foto cell ───────────────────────────────────────────────── */
.foto-cell { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 80px; }
.foto-thumbs { display: flex; flex-wrap: wrap; gap: 3px; }
.foto-thumb {
  width: 36px; height: 36px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--clr-border);
  cursor: pointer; transition: opacity 0.15s;
}
.foto-thumb:hover { opacity: 0.8; }
.foto-thumb-wrap { position: relative; display: inline-block; }
.foto-thumb-del {
  position: absolute; top: -4px; right: -4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #c62828; color: #fff;
  font-size: 9px; line-height: 14px; text-align: center;
  cursor: pointer; border: none; padding: 0;
  display: none;
}
.foto-thumb-wrap:hover .foto-thumb-del { display: block; }

.btn-foto-add {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; color: #1565c0; background: #e3f2fd;
  border: 1px solid #90caf9; border-radius: 4px;
  padding: 2px 6px; cursor: pointer; white-space: nowrap;
}
.btn-foto-add:hover { background: #bbdefb; }
.btn-foto-add:disabled { opacity: 0.4; cursor: not-allowed; }
.foto-count-badge {
  font-size: 9px; color: var(--clr-muted);
  background: var(--clr-bg-hover); border-radius: 3px;
  padding: 1px 4px;
}

/* ── Lightbox ────────────────────────────────────────────────── */
#foto-lightbox {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.88);
  align-items: center; justify-content: center; flex-direction: column;
}
#foto-lightbox.open { display: flex; }
.lightbox-img { max-width: 90vw; max-height: 82vh; object-fit: contain; border-radius: 4px; }
.lightbox-caption {
  margin-top: 10px; font-size: var(--fs-sm); color: rgba(255,255,255,0.6);
  font-family: monospace;
}
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.12); border: none; color: #fff;
  font-size: 24px; padding: 8px 14px; cursor: pointer; border-radius: 4px;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.22); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-close {
  position: absolute; top: 14px; right: 18px;
  background: none; border: none; color: rgba(255,255,255,0.7);
  font-size: 28px; cursor: pointer; line-height: 1;
}
.lightbox-close:hover { color: #fff; }
.lightbox-counter {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  font-size: var(--fs-sm); color: rgba(255,255,255,0.5);
}
