/* =============================================================================
   Template Builder — page-specific styles
   Layered on top of the shared design system in styles.css. Colors, radii,
   and typography come from the same CSS custom properties.
   ============================================================================= */

.builder-hero {
    padding: clamp(28px, 5vw, 54px) 0 clamp(16px, 3vw, 28px);
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, rgba(11, 61, 145, 0.10), transparent 70%),
        linear-gradient(180deg, #FFFFFF 0%, #F5F8FD 100%);
}
.builder-hero .container { text-align: center; }
.builder-hero h1 { margin-bottom: 10px; }
.builder-hero p { max-width: 640px; margin: 0 auto 24px; color: var(--ink-soft); }

.builder-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.builder-actions .btn {
    padding: 11px 18px;
    font-size: 0.94rem;
}
.builder-actions .btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Hide the file input — triggered from a styled label. */
.file-input { display: none; }

.builder-main {
    padding: 20px 0 120px;
    max-width: 860px;
    margin: 0 auto;
}

/* Info card (name, reference, description) */
.builder-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: clamp(20px, 4vw, 30px);
    box-shadow: var(--shadow-sm);
    margin: 0 var(--gutter) 24px;
}
.builder-card h2 { font-size: 1.2rem; margin: 0 0 16px; }
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.field:last-child { margin-bottom: 0; }
.field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: 0.01em;
}
.field input,
.field textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.98rem;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.12);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: 0.8rem; color: var(--ink-muted); }

/* Section card */
.section-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px 20px 16px;
    box-shadow: var(--shadow-sm);
    margin: 0 var(--gutter) 18px;
}
.section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.section-num {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.section-title-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.section-title-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.12);
}
.icon-btn {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ink-soft);
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    flex-shrink: 0;
}
.icon-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}
.icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.icon-btn.danger:hover { border-color: #DC2626; color: #DC2626; }
.icon-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Items list */
.items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 38px;
    margin-bottom: 12px;
}
.item-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.item-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-accent);
    flex-shrink: 0;
}
.item-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.12s, box-shadow 0.12s;
}
.item-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(11, 61, 145, 0.12);
}
.item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.item-actions .icon-btn {
    width: 30px;
    height: 30px;
}
.items-empty {
    padding: 14px;
    background: var(--bg-soft);
    border-radius: 10px;
    font-size: 0.88rem;
    color: var(--ink-muted);
    text-align: center;
}

.section-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    margin-top: 6px;
}
.add-btn {
    background: var(--brand-primary-soft);
    color: var(--brand-primary-on-soft);
    border: 0;
    padding: 9px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.12s;
}
.add-btn:hover { background: rgba(11, 61, 145, 0.18); }
.add-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2.3;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Global "Add section" button */
.add-section-wrap {
    text-align: center;
    padding: 0 var(--gutter);
    margin: 10px 0 30px;
}
.add-section-wrap .add-btn {
    padding: 12px 20px;
    font-size: 0.96rem;
}

.empty-state {
    margin: 0 var(--gutter) 24px;
    padding: 40px 24px;
    border: 2px dashed var(--line);
    border-radius: var(--radius-lg);
    text-align: center;
    color: var(--ink-muted);
}
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }

/* Sticky action bar at the bottom */
.builder-bar {
    position: sticky;
    bottom: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
    padding: 12px var(--gutter);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
.builder-bar .btn {
    padding: 8px 14px;
    font-size: 0.85rem;
    gap: 6px;
}
.builder-bar .btn svg { width: 14px; height: 14px; }
.builder-bar .status {
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    color: var(--ink-muted);
    margin-top: 6px;
    min-height: 1em;
}
.builder-bar .status.ok { color: #0A7B3C; }
.builder-bar .status.err { color: #B42318; }

@media (max-width: 640px) {
    .section-head { flex-wrap: wrap; }
    .section-title-input { order: -1; width: 100%; flex: 1 1 100%; }
    .items { padding-left: 0; }
    .builder-bar .btn { flex: 1; min-width: 120px; }
}
