/* ==========================================================================
 *  Label app (Naljepnice) - additions on top of app.css (which stays UNCHANGED).
 *  Only the --wb-* tokens from app.css are used. Same role as the onboarding app's onboarding.css;
 *  the general rules below are taken from it unchanged.
 * ========================================================================== */

/* ---------- Dashboard chrome (booking tool admin.css, as in the onboarding app) ---------- */
.main { min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; padding: 1.5rem; }
.stat-card .card-body { display: flex; align-items: center; gap: 1rem; }
.stat-card i { font-size: 1.6rem; }
.filter-bar .form-control, .filter-bar .form-select { min-height: 40px; }
.detail-list dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--wb-text-muted); font-weight: 600; margin-top: .75rem; }
.detail-list dd { margin: .15rem 0 0; }
.table .actions { white-space: nowrap; }
.table .actions form { display: inline; }
.offcanvas.sidebar { width: var(--sidebar-w); }
@media (max-width: 767.98px) { .content { padding: 1rem; } }

/* app.css lets tables inside cards overflow (for menus inside tables, which this app does not use).
   Here wide tables scroll inside their card, so the page never scrolls sideways on a phone (390 px). */
.card > .table-responsive, .table-responsive { overflow-x: auto; overflow-y: visible; position: relative; }   /* relative: screen-reader-only labels stay inside */
.content { min-width: 0; }

/* ---------- Role badges and small chips ---------- */
.role-chip { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .15rem .45rem; margin: 0 .2rem .2rem 0; border: 1px solid var(--wb-border-strong); color: var(--wb-text-label); background: var(--wb-bg-subtle); }
.role-chip.role-admin { border-color: var(--wb-primary); color: var(--wb-primary); }

/* ---------- Code / command boxes (instead of inline styles) ---------- */
.code-box { background: var(--wb-bg-subtle); border: 1px solid var(--wb-border); white-space: pre-wrap; word-break: break-all; padding: .5rem .75rem; font-size: .82rem; margin: 0; }
.code-box.scroll { max-height: 420px; overflow: auto; }
.w-label { width: 40%; }
.w-80 { width: 80px; }
.w-110 { width: 110px; }
.mw-640 { max-width: 640px; }
.mw-520 { max-width: 520px; }
.dropdown-form { min-width: 260px; }

/* Large touch targets on phones and tablets */
@media (max-width: 991.98px) {
  .form-check-input { width: 1.35rem; height: 1.35rem; }
  .form-check-label { padding-left: .25rem; }
  .btn-sm { min-height: 40px; }
}

/* ---------- E-mail preview frame ---------- */
.email-frame { display: block; width: 100%; height: 640px; border: 1px solid var(--wb-border); background: #f1f5f9; }

/* ---------- Error log (booking tool) ---------- */
.err-summary { cursor: pointer; word-break: break-word; }
.err-summary::marker { color: var(--wb-text-subtle); }
.err-details { margin-top: .5rem; padding: .6rem .75rem; background: var(--wb-bg-subtle); border: 1px solid var(--wb-border); }
.err-details pre { background: var(--wb-bg); border: 1px solid var(--wb-border); font-size: .75rem; white-space: pre-wrap; max-height: 260px; overflow: auto; }

/* ---------- E-mail template editor ---------- */
.tpl-body { min-height: 300px; font-size: .85rem; line-height: 1.55; font-family: var(--bs-font-monospace); }
.tpl-chip { appearance: none; border: 1px solid var(--wb-border-strong); background: var(--wb-bg); color: var(--wb-text-label); font-family: var(--bs-font-monospace); font-size: .75rem; padding: .1rem .4rem; margin: .15rem .1rem 0 0; cursor: pointer; }
.tpl-chip:hover { border-color: var(--wb-primary); color: var(--wb-text); }

/* ---------- Check list (Server check) ---------- */
.check-ok { color: var(--wb-success-text); font-weight: 600; }
.check-bad { color: var(--wb-error-text); font-weight: 600; }
.check-warn { color: var(--wb-warning-text); font-weight: 600; }

/* ---------- Neutral error page (no inline styles, CSP) ---------- */
.error-page { font-family: var(--wb-font, -apple-system, "Segoe UI", Roboto, Arial, sans-serif); background: #f8fafc; color: #0f172a; margin: 0; padding: 15vh 20px; text-align: center; }
.error-page h1 { font-size: 1.4rem; }
.error-page p { color: #64748b; }

/* Row actions: compact icon buttons, never wrapped */
.table td.actions { width: 1%; }

.card-disabled { background: var(--wb-bg-subtle); }
.form-check-lg .form-check-input { width: 1.4rem; height: 1.4rem; margin-top: .1rem; }
.form-check-lg .form-check-label { padding-left: .4rem; font-size: 1rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--wb-bg-subtle); padding: .75rem 0; z-index: 5; }

/* ==========================================================================
 *  Labels
 * ========================================================================== */

.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--wb-text-muted); font-weight: 700; margin: 1.25rem 0 .6rem; }

/* ---------- Template cards with a picture of the label (dashboard, template list, generate) ---------- */
.tpl-group { margin-bottom: 1.25rem; }
.tpl-group-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--wb-text-label); font-weight: 700; margin-bottom: .5rem; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
@media (max-width: 575.98px) { .tpl-grid { grid-template-columns: 1fr 1fr; gap: .5rem; } .tpl-card .card-body { padding: .75rem; } }
@media (max-width: 359.98px) { .tpl-grid { grid-template-columns: 1fr; } }
.tpl-card { display: flex; flex-direction: column; min-width: 0; }
.tpl-card .card-body { flex: 1; display: flex; flex-direction: column; }
.tpl-card .card-body > .d-flex:last-child { margin-top: auto !important; padding-top: .5rem; }
.tpl-card.is-selected { border-color: var(--wb-primary); box-shadow: inset 0 0 0 1px var(--wb-primary); }
.tpl-card.is-archived { background: var(--wb-bg-subtle); }
.tpl-thumb { display: flex; align-items: center; justify-content: center; height: 150px; background: var(--wb-disabled-bg); border-bottom: 1px solid var(--wb-border); overflow: hidden; }
.tpl-thumb canvas { display: block; max-width: calc(100% - 16px); max-height: calc(100% - 16px); background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .18); opacity: 0; transition: opacity .2s; }
.tpl-thumb.is-drawn canvas { opacity: 1; }
.tpl-thumb.is-failed::after { content: "PDF"; color: var(--wb-text-subtle); font-weight: 700; letter-spacing: .1em; }
.tpl-thumb.is-failed canvas { display: none; }
.tpl-thumb-sm { height: 90px; }
.size-chip { display: inline-block; font-size: .72rem; font-weight: 600; color: var(--wb-text-label); border: 1px solid var(--wb-border-strong); padding: .05rem .35rem; background: var(--wb-bg); white-space: nowrap; }

/* ---------- Template editor ---------- */
.editor-toolbar { margin-bottom: .75rem; padding: .5rem .75rem; position: sticky; top: var(--topbar-h); z-index: 20; }
.editor-toolbar .btn.active, .editor-toolbar .btn[aria-pressed="true"] { background: var(--wb-primary); color: #fff; border-color: var(--wb-primary); }
.stage-wrap { position: relative; overflow: auto; background: var(--wb-disabled-bg); border: 1px solid var(--wb-border); padding: 16px; max-height: 78vh; min-height: 200px; }
.stage { position: relative; margin: 0 auto; background: #fff; box-shadow: 0 1px 4px rgba(15, 23, 42, .2); }
.stage-canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.stage-overlay { position: absolute; inset: 0; touch-action: none; outline: none; }
.stage-overlay:focus-visible { box-shadow: 0 0 0 2px var(--wb-primary); }
.stage-overlay.is-region-mode, .stage-overlay.is-region-mode * { cursor: crosshair; }
.stage-busy { position: absolute; right: 6px; top: 6px; background: rgba(255, 255, 255, .9); padding: 2px 6px; border: 1px solid var(--wb-border); z-index: 10; }
.el-box { position: absolute; transform-origin: 0 0; border: 1px dashed rgba(220, 30, 36, .7); cursor: move; z-index: 2; }
.el-box.is-selected { border: 1px solid var(--wb-red); background: rgba(220, 30, 36, .06); z-index: 4; }
.hide-frames .el-box:not(.is-selected) { border-color: transparent; }
.el-tag { position: absolute; left: -1px; bottom: 100%; font-size: 10px; line-height: 14px; padding: 0 4px; background: var(--wb-red); color: #fff; white-space: nowrap; pointer-events: none; display: none; }
.el-box.is-selected .el-tag { display: block; }
.el-handle, .rg-handle { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border: 2px solid #fff; cursor: nwse-resize; touch-action: none; }
.el-handle { background: var(--wb-red); }
.rg-handle { background: var(--wb-primary); }
.rg-box { position: absolute; border: 1px solid rgba(15, 23, 42, .55); background: repeating-linear-gradient(45deg, rgba(15, 23, 42, .16) 0 2px, rgba(15, 23, 42, 0) 2px 6px); cursor: move; z-index: 1; }
.rg-box.is-all { border-style: dashed; background: repeating-linear-gradient(-45deg, rgba(15, 23, 42, .24) 0 2px, rgba(15, 23, 42, 0) 2px 5px); }
.rg-box.is-selected { border: 2px solid var(--wb-primary); z-index: 3; }
.run-box { position: absolute; border: 1px dotted rgba(100, 116, 139, .95); cursor: pointer; z-index: 0; }
.run-box:hover, .run-box.is-selected { background: rgba(250, 204, 21, .3); border-style: solid; }
.rubber { position: absolute; border: 1px dashed var(--wb-primary); background: rgba(15, 23, 42, .08); pointer-events: none; z-index: 9; }
.editor .form-control-sm, .editor .form-select-sm { min-height: 34px; font-size: .85rem; }
.editor .form-control-color { max-width: 3rem; min-height: 34px; padding: .2rem; }
.editor-panel .tab-content { max-height: 78vh; overflow: auto; }
.editor-panel .nav-tabs .nav-link { padding: .45rem .6rem; font-size: .82rem; }
.el-list { max-height: 210px; overflow: auto; margin-bottom: .75rem; border: 1px solid var(--wb-border); }
.el-list button { display: flex; width: 100%; align-items: center; gap: .55rem; border: 0; border-bottom: 1px solid var(--wb-border); background: var(--wb-bg); padding: .4rem .6rem; text-align: left; font-size: .85rem; color: var(--wb-text); min-width: 0; }
.el-list button:last-child { border-bottom: 0; }
.el-list button:hover { background: var(--wb-bg-subtle); }
.el-list button.is-active { background: var(--wb-disabled-bg); box-shadow: inset 3px 0 0 var(--wb-red); }
.el-list .el-sub { color: var(--wb-text-muted); font-family: var(--bs-font-monospace); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.el-list > button > span { min-width: 0; }
.props fieldset { border-top: 1px solid var(--wb-border); padding-top: .6rem; margin-top: .4rem; }
.props .form-label, .var-row .form-label, .region-row .form-label { font-size: .72rem; margin-bottom: .15rem; }
.ph-chips { margin-top: .3rem; }
.run-info { border: 1px solid var(--wb-warning-border); background: var(--wb-warning-bg); padding: .6rem .75rem; margin-bottom: .75rem; }
.var-row, .region-row { border: 1px solid var(--wb-border); padding: .6rem; margin-bottom: .5rem; background: var(--wb-bg); }
.var-row.is-new { border-color: var(--wb-primary); }
.region-row.is-selected { border-color: var(--wb-primary); box-shadow: inset 3px 0 0 var(--wb-primary); }
.var-used { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.dirty-flag { font-size: .82rem; font-weight: 600; color: var(--wb-success-text); }
.dirty-flag.is-dirty { color: var(--wb-warning-text); }
.editor-status .alert { margin-bottom: .4rem; padding: .45rem .7rem; }
.editor-status ul { margin: .2rem 0 0; padding-left: 1.1rem; }
.save-note { min-width: 160px; }
/* millimetre fields in the narrow side panel: no spin buttons, so values like 25.853 stay readable (arrow keys still work) */
.editor-panel input[type=number] { padding-left: .4rem; padding-right: .3rem; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.editor-panel input[type=number]::-webkit-outer-spin-button,
.editor-panel input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
@media (max-width: 575.98px) { .editor-toolbar { position: static; } }

/* ---------- Making labels ---------- */
.row-card.is-active { border-color: var(--wb-primary); }
.row-card.has-errors { border-color: var(--wb-error-border); }
.row-card .card-header { padding: .55rem 1rem; }
.row-title { font-weight: 700; }
.gen-preview { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.gen-preview-box { display: flex; align-items: center; justify-content: center; min-height: 180px; background: var(--wb-disabled-bg); border: 1px solid var(--wb-border); padding: 8px; overflow: hidden; }
.gen-preview-box canvas { display: block; max-width: 100%; height: auto; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .18); }
.gen-preview-box:not(.is-drawn) canvas { visibility: hidden; }
@media (max-width: 1199.98px) { .gen-preview { position: static; } }
.map-table select { min-width: 180px; }
/* phones: each field becomes a small block (name, column, first value) instead of a wide table */
@media (max-width: 575.98px) {
    .map-table thead { display: none; }
    .map-table tr { display: block; padding: .45rem 0; border-bottom: 1px solid var(--wb-border); }
    .map-table td { display: block; border: 0; padding: .1rem 0; }
    .map-table select { min-width: 0; width: 100%; }
}
.review-wrap { max-height: 70vh; overflow: auto; }
.review-table th { position: sticky; top: 0; z-index: 1; }
.review-table td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.review-table tr.row-error > td { background: var(--wb-error-bg); }
.review-table td.cell-error { color: var(--wb-error-text); font-weight: 600; white-space: normal; }
.cell-error-text { font-size: .72rem; font-weight: 400; }
.note-box { background: var(--wb-bg); border: 1px solid var(--wb-border); border-left: 3px solid var(--wb-primary); padding: .6rem .8rem; color: var(--wb-text-label); }

/* ---------- Image library ---------- */
.img-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.tpl-thumb img { display: block; max-width: calc(100% - 16px); max-height: calc(100% - 16px); background: #fff; }
.img-edit summary { cursor: pointer; color: var(--wb-text-label); font-weight: 600; }
