/* ============================================================
   Builder CV — aplikační layout (styl „papír a inkoust")
   ============================================================ */

.builder-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* --------------------------------------------------- horní lišta */
.b-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 20px;
    height: 60px;
    background: var(--paper);
    border-bottom: var(--border-strong);
    flex-shrink: 0;
}

.b-logo img { height: 34px; width: auto; display: block; }

.b-pickers { display: flex; align-items: center; gap: 24px; }
.b-picker { display: flex; align-items: center; gap: 10px; }
.b-picker-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
}

.b-tpls { position: relative; }

.b-tpl-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: bold;
    padding: 5px 12px;
    background: var(--card);
    border: var(--border-strong);
    border-radius: var(--radius);
    color: var(--ink);
    transition: box-shadow 0.12s ease;
}
.b-tpl-btn:hover { box-shadow: var(--shadow-hard-sm); }

.b-ats {
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--accent);
    vertical-align: super;
}

/* vyskakovací galerie šablon */
.b-tpl-pop {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 70;
    width: 460px;
    max-width: calc(100vw - 24px);
    max-height: min(70vh, 560px);
    overflow-y: auto;
    background: var(--card);
    border: var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    padding: 16px 18px 18px;
}
.b-tpl-cat {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin: 14px 0 8px;
}
.b-tpl-cat:first-child { margin-top: 0; }
.b-tpl-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.b-tplcard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: var(--border);
    border-radius: var(--radius);
    padding: 8px 6px;
    transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.b-tplcard:hover {
    box-shadow: var(--shadow-hard-sm);
    transform: translate(-1px, -1px);
}
.b-tplcard.is-active {
    border: 2px solid var(--ink);
    background: var(--accent-soft);
}
.b-tplcard-name { font-size: 12.5px; font-weight: 700; color: var(--ink-deep); }
.b-tplcard-name em {
    font-style: normal;
    font-size: 9.5px;
    font-weight: 800;
    color: var(--accent);
    vertical-align: super;
}

/* Miniatury šablon — stylizované náhledy layoutu (44×62, A4 poměr) */
.tplmini {
    width: 44px;
    height: 62px;
    background-color: #ffffff;
    border: 1px solid rgba(27, 24, 64, 0.25);
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
    background-repeat: no-repeat;
}
.b-tpl-btn .tplmini { width: 20px; height: 28px; }

.tplmini--duo      { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#eceaf4, #eceaf4);
                     background-size: 100% 27%, 34% 73%; background-position: 0 0, 0 100%; }
.tplmini--mrizka   { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#e5e5e5, #e5e5e5);
                     background-size: 100% 6%, 30% 70%; background-position: 0 24%, 100% 100%; }
.tplmini--teczka   { background-image: radial-gradient(circle at 24% 14%, #28245c 15%, transparent 16%), linear-gradient(#eceaf4, #eceaf4);
                     background-size: 100% 100%, 38% 70%; background-position: 0 0, 0 100%; }
.tplmini--banner   { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#d9d9d9, #d9d9d9), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 100% 30%, 70% 4%, 55% 4%; background-position: 0 0, 15% 55%, 15% 72%; }
.tplmini--serif    { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#bbbbbb, #bbbbbb), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 40% 5%, 70% 2%, 60% 3%; background-position: 50% 16%, 50% 34%, 50% 55%; }
.tplmini--kancelar { background-image: linear-gradient(#333333, #333333), linear-gradient(#333333, #333333), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 100% 3%, 100% 1.5%, 74% 4%; background-position: 0 20%, 0 26%, 13% 50%; }
.tplmini--ramecek  { background-image: linear-gradient(#ffffff, #ffffff), linear-gradient(#28245c, #28245c);
                     background-size: 78% 82%, 88% 90%; background-position: 50% 50%, 50% 50%; }
.tplmini--pruh     { background-image: linear-gradient(#28245c, #28245c);
                     background-size: 34% 100%; background-position: 0 0; }
.tplmini--kontrast { background-image: linear-gradient(#161616, #161616), linear-gradient(#c94f2e, #c94f2e);
                     background-size: 100% 32%, 30% 5%; background-position: 0 0, 12% 52%; }
.tplmini--noviny   { background-image: linear-gradient(#1e1e1e, #1e1e1e), linear-gradient(#1e1e1e, #1e1e1e), linear-gradient(#1e1e1e, #1e1e1e), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 100% 2.5%, 100% 2.5%, 46% 5%, 70% 3%; background-position: 0 6%, 0 30%, 50% 16%, 50% 55%; }
.tplmini--stin     { background-image: linear-gradient(#c94f2e, #c94f2e), linear-gradient(#ffffff, #ffffff), linear-gradient(rgba(28,28,28,0.85), rgba(28,28,28,0.85)), linear-gradient(#ffffff, #ffffff);
                     background-size: 60% 22%, 58% 22%, 70% 30%, 68% 30%; background-position: 24% 12%, 18% 8%, 30% 78%, 22% 70%; }
.tplmini--cista    { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#d9d9d9, #d9d9d9), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 100% 5%, 66% 4%, 74% 4%; background-position: 0 22%, 12% 46%, 12% 62%; }
.tplmini--linka    { background-image: linear-gradient(#bbbbbb, #bbbbbb), linear-gradient(#28245c, #28245c), linear-gradient(#d9d9d9, #d9d9d9), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 100% 1.5%, 16% 30%, 60% 4%, 55% 4%; background-position: 0 24%, 10% 68%, 92% 48%, 92% 62%; }
.tplmini--vzduch   { background-image: linear-gradient(#999999, #999999), linear-gradient(#28245c, #28245c), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 46% 3%, 16% 2%, 44% 3%; background-position: 50% 18%, 50% 32%, 50% 58%; }
.tplmini--osa      { background-image: linear-gradient(#28245c, #28245c), radial-gradient(circle, #28245c 40%, transparent 45%), radial-gradient(circle, #28245c 40%, transparent 45%), linear-gradient(#d9d9d9, #d9d9d9), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 4% 55%, 16% 11%, 16% 11%, 55% 4%, 50% 4%; background-position: 18% 88%, 14% 42%, 14% 70%, 78% 44%, 74% 70%; }
.tplmini--oblazek  { background-image: linear-gradient(#eceaf4, #eceaf4), linear-gradient(#f1efe9, #f1efe9), linear-gradient(#f1efe9, #f1efe9);
                     background-size: 84% 24%, 30% 46%, 44% 46%; background-position: 50% 8%, 12% 88%, 88% 88%; border-radius: 4px; }
.tplmini--listina  { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#28245c, #28245c), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 100% 2%, 100% 1%, 66% 4%; background-position: 0 26%, 0 31%, 15% 55%; }
.tplmini--stroj    { background-image: repeating-linear-gradient(0deg, transparent 0 4px, #d9d9d9 4px 6px);
                     background-size: 70% 55%; background-position: 50% 75%; border-style: dashed; border-color: #28245c; }
.tplmini--stitek   { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#eceaf4, #eceaf4), linear-gradient(#eceaf4, #eceaf4), linear-gradient(#eceaf4, #eceaf4);
                     background-size: 34% 8%, 24% 7%, 24% 7%, 24% 7%; background-position: 14% 16%, 14% 44%, 48% 44%, 82% 44%;
                     border-radius: 2px; }
.tplmini--tuzka    { background-image: linear-gradient(#28245c, #28245c), linear-gradient(#333333, #333333), linear-gradient(#d9d9d9, #d9d9d9), linear-gradient(#d9d9d9, #d9d9d9);
                     background-size: 40% 2%, 30% 4%, 64% 3%, 58% 3%; background-position: 12% 30%, 12% 14%, 12% 52%, 12% 66%; }

.b-colors { display: flex; gap: 6px; }
.b-color {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    outline: 1.5px solid var(--ink-faint);
}
.b-color.is-active {
    outline: 2.5px solid var(--ink);
    outline-offset: 2px;
}

.b-top-actions { display: flex; align-items: center; gap: 14px; }
.b-saved {
    font-size: 13px;
    font-weight: 700;
    color: #3c7a4e;
    background: rgba(60, 122, 78, 0.10);
    border: 1.5px solid rgba(60, 122, 78, 0.35);
    border-radius: 20px;
    padding: 4px 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}
.b-saved.is-visible { opacity: 1; }
.b-saved.is-pulse { animation: b-saved-pulse 0.45s ease; }
@keyframes b-saved-pulse {
    0% { transform: scale(1); }
    35% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* --------------------------------------------------- layout */
.b-layout {
    display: grid;
    grid-template-columns: minmax(380px, 5fr) minmax(0, 7fr);
    /* jediný řádek přesně na výšku kontejneru — jinak sloupce přerostou a scroll panelu nefunguje */
    grid-template-rows: minmax(0, 1fr);
    flex: 1;
    min-height: 0;
}

.b-editor {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: var(--border-strong);
    background: var(--card);
}

/* kroky */
.b-steps {
    display: flex;
    flex-wrap: wrap;
    border-bottom: var(--border);
    flex-shrink: 0;
    background: var(--paper);
}
.b-step {
    flex: 1;
    padding: 12px 6px;
    font-size: 13.5px;
    font-weight: 700;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--ink-soft);
    white-space: nowrap;
}
.b-step .b-step-n {
    font-family: var(--font-display);
    color: var(--accent);
    margin-right: 2px;
}
.b-step.is-active {
    color: var(--ink-deep);
    border-bottom-color: var(--accent);
    background: var(--card);
}

/* panel formuláře */
.b-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px 48px;
}

.b-sub {
    font-family: var(--font-display);
    font-size: 19px;
    margin: 28px 0 12px;
}
.b-sub:first-child { margin-top: 0; }

.b-field { display: block; margin-bottom: 14px; }
.b-field > span, .b-field-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 4px;
}

.b-field input[type="text"],
.b-field input[type="email"],
.b-field textarea,
.b-field select {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: 15.5px;
    color: var(--ink-deep);
    background: var(--card);
    border: var(--border);
    border-radius: var(--radius);
}
.b-field input:focus, .b-field textarea:focus, .b-field select:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 2px 2px 0 rgba(27, 24, 64, 0.25);
}

.b-grid { display: flex; gap: 12px; }
.b-grid .b-field--half { flex: 1; }
.b-grid--grow { flex: 1; }

.b-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 14px;
    font-size: 15px;
    cursor: pointer;
}
.b-check input { width: 17px; height: 17px; accent-color: var(--ink); }

/* opakovatelné položky */
.b-item {
    border: var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    background: var(--card);
    position: relative;
}
.b-item.is-dragging { opacity: 0.4; }

.b-item--row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px;
}
.b-item--row .b-field { margin-bottom: 0; }

.b-item-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: var(--border);
}
.b-item-tools-spacer { flex: 1; }
.b-item-n {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: bold;
    color: var(--accent);
    letter-spacing: 0.06em;
}

.b-drag {
    cursor: grab;
    color: var(--ink-faint);
    user-select: none;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    transition: color 0.12s ease;
}
.b-drag:hover { color: var(--ink); }
.b-drag:active { cursor: grabbing; }

/* ikonová tlačítka (sbalit, odebrat, oko) */
.b-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--card);
    border: var(--border);
    border-radius: var(--radius);
    color: var(--ink-soft);
    transition: all 0.12s ease;
    flex-shrink: 0;
}
.b-icon-btn:hover {
    color: var(--ink);
    border-color: var(--ink);
    box-shadow: 2px 2px 0 rgba(27, 24, 64, 0.35);
}
.b-icon-btn--danger:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 2px 2px 0 rgba(201, 79, 46, 0.3);
}
.b-item--row .b-icon-btn { margin-bottom: 6px; }

.b-add {
    margin: 4px 0 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* sbalené položky — karta s levým akcentním proužkem */
.b-item--collapsed {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 10px 8px;
    border-left: 4px solid var(--accent);
    transition: box-shadow 0.12s ease, transform 0.12s ease;
}
.b-item--collapsed:hover {
    box-shadow: var(--shadow-hard-sm);
    transform: translate(-1px, -1px);
}
.b-item-summary {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    text-align: left;
    font: inherit;
    color: var(--ink-deep);
    padding: 0;
    min-width: 0;
    cursor: pointer;
}
.b-item-sumtext {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.b-item-sumtext strong {
    font-family: var(--font-display);
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.b-item-sumsub {
    font-size: 13px;
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.b-item-summary:hover strong { color: var(--accent); }
.b-item-sumdates {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-soft);
    white-space: nowrap;
    background: var(--paper);
    border: var(--border);
    border-radius: 20px;
    padding: 3px 10px;
}
.b-chev { display: inline-flex; color: var(--ink-soft); }
.b-item-summary:hover .b-chev { color: var(--accent); }

/* výběr měsíc/rok */
.b-date-row { display: flex; gap: 6px; }
.b-date-row select {
    padding: 10px 8px;
    font: inherit;
    font-size: 15px;
    color: var(--ink-deep);
    background: var(--card);
    border: var(--border);
    border-radius: var(--radius);
}
.b-date-row select:first-child { flex: 1.3; min-width: 0; }
.b-date-row select:last-child { flex: 1; min-width: 0; }

/* řazení seznamu — segmentový přepínač */
.b-sort {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.b-sort-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
}
.b-seglist {
    display: inline-flex;
    border: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--card);
}
.b-seg {
    padding: 7px 14px;
    font-size: 13.5px;
    font-weight: 600;
    background: transparent;
    border: none;
    color: var(--ink-soft);
    white-space: nowrap;
}
.b-seg + .b-seg { border-left: var(--border); }
.b-seg:hover { background: var(--accent-soft); color: var(--ink); }
.b-seg.is-active {
    background: var(--ink);
    color: var(--paper);
}

.b-hint {
    font-size: 13px;
    color: var(--ink-soft);
    margin: -6px 0 10px;
}

/* navigace mezi kroky pod formulářem */
.b-stepnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: var(--border);
}

/* fotografie */
.b-photo { margin: 6px 0 16px; }
.b-photo-thumb {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 50%;
    border: var(--border-strong);
    margin-bottom: 10px;
}
.b-photo-actions { display: flex; gap: 10px; }

/* viditelnost a pořadí sekcí */
.b-sec-list { list-style: none; margin-top: 8px; }
.b-sec-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    background: var(--card);
    font-size: 15px;
}
.b-sec-row.is-hidden .b-sec-name { opacity: 0.4; text-decoration: line-through; }
.b-sec-row.is-dragging { opacity: 0.4; }
.b-sec-toggle {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 15px;
    color: var(--ink);
}

/* --------------------------------------------------- náhled */
.b-preview {
    overflow-y: auto;
    padding: 28px;
    background: var(--paper-warm);
}

.b-sheet-wrap { width: 794px; }

/* --------------------------------------------------- mobilní záložky */
.b-mobile-tabs { display: none; }

@media (max-width: 900px) {
    .builder-body { height: auto; min-height: 100vh; overflow: auto; }

    .b-top { flex-wrap: wrap; height: auto; padding: 10px 14px; row-gap: 8px; }
    .b-pickers { order: 3; width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 12px; }

    .b-mobile-tabs {
        display: flex;
        border-bottom: var(--border-strong);
        background: var(--paper);
        position: sticky;
        top: 0;
        z-index: 30;
    }
    .b-mobile-tabs button {
        flex: 1;
        padding: 12px;
        font-size: 15px;
        font-weight: 700;
        background: transparent;
        border: none;
        border-bottom: 3px solid transparent;
        color: var(--ink-soft);
    }
    .b-mobile-tabs button.is-active {
        color: var(--ink-deep);
        border-bottom-color: var(--accent);
    }

    .b-layout { display: block; }
    .b-editor { border-right: none; }
    .b-preview { display: none; padding: 16px; }

    body.show-preview .b-editor { display: none; }
    body.show-preview .b-preview { display: block; }
}

/* --------------------------------------------------- PDF brána */
.gate-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(27, 24, 64, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.gate-card {
    position: relative;
    max-width: 440px;
    width: 100%;
    background: var(--card);
    border: var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    padding: 32px 30px;
}
.gate-card h2 {
    font-size: 23px;
    margin-bottom: 10px;
    padding-right: 24px;
}
.gate-card p {
    font-size: 15px;
    color: var(--ink-soft);
    margin-bottom: 22px;
}
.gate-actions { display: flex; flex-direction: column; gap: 10px; }
.gate-actions .btn { text-align: center; }
.gate-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 16px;
    color: var(--ink-soft);
    padding: 4px;
}
.gate-close:hover { color: var(--ink); }

/* --------------------------------------------------- tisk */
@media print {
    .b-top, .b-mobile-tabs, .b-editor { display: none !important; }
    .builder-body { height: auto; overflow: visible; display: block; background: none; }
    .b-layout { display: block; }
    .b-preview {
        display: block !important;
        overflow: visible;
        padding: 0;
        background: none;
        height: auto !important;
    }
    .b-sheet-wrap {
        transform: none !important;
        width: auto;
        height: auto !important;
    }
}
