/* ============================================
   VISUAL TEMPLATE PICKER
   Renders a real, scaled-down preview of each template
   so users see exactly what they're choosing.
   ============================================ */

.template-selector{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:14px;
}
/* Desktop gets bigger, breathing thumbnails. */
@media (min-width:1024px){
    .template-selector{ grid-template-columns:repeat(4,1fr); gap:18px; }
}
@media (min-width:1400px){
    .template-selector{ grid-template-columns:repeat(5,1fr); gap:20px; }
}

.tpl-pick{
    all:unset;
    display:flex;
    flex-direction:column;
    background:rgba(15,23,42,0.55);
    border:2px solid rgba(56,189,248,0.18);
    border-radius:14px;
    overflow:hidden;
    cursor:pointer;
    transition:transform .15s ease, border-color .15s ease, box-shadow .15s ease;
    position:relative;
}
.tpl-pick:hover{
    border-color:var(--accent-color);
    transform:translateY(-2px);
    box-shadow:0 8px 22px -10px rgba(56,189,248,0.45);
}
.tpl-pick:focus-visible{
    outline:2px solid var(--accent-color);
    outline-offset:2px;
}
.tpl-pick.is-selected{
    border-color:var(--accent-color);
    box-shadow:0 0 0 3px rgba(56,189,248,0.28), 0 8px 22px -10px rgba(56,189,248,0.45);
}

/* Scaled live preview — uses container query units so thumbnails
   scale perfectly to whatever width the grid gives them. */
.tpl-pick-preview{
    position:relative;
    width:100%;
    aspect-ratio:794/1058;
    background:white;
    overflow:hidden;
    container-type:inline-size;
    container-name:tplthumb;
}
.tpl-pick-frame{
    position:absolute;
    top:0;
    left:0;
    width:794px;        /* A4 width @ ~96dpi */
    height:1058px;
    transform:scale(0.255);
    transform-origin:top left;
    pointer-events:none;
}
@container tplthumb (min-width: 0px){
    .tpl-pick-frame{ transform:scale(calc(100cqw / 794)); }
}
.tpl-pick-frame > .tpl{
    width:794px;
    min-height:1058px;
    box-sizing:border-box;
}

.tpl-pick-meta{
    display:flex;
    align-items:center;
    gap:10px;
    padding:10px 12px;
    background:rgba(15,23,42,0.85);
    border-top:1px solid rgba(56,189,248,0.18);
}
.tpl-pick-icon{
    font-size:18px;
    line-height:1;
    width:26px;
    text-align:center;
    flex-shrink:0;
}
.tpl-pick-text{
    flex:1;
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:2px;
}
.tpl-pick-name{
    font-size:13px;
    font-weight:700;
    color:var(--text-primary);
    line-height:1.2;
    display:flex;
    align-items:center;
    gap:6px;
}
.tpl-pick-desc{
    font-size:11px;
    color:var(--text-secondary);
    line-height:1.35;
    overflow:hidden;
    text-overflow:ellipsis;
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
}
.tpl-pick-badge{
    font-size:9px;
    font-weight:700;
    background:#16a34a;
    color:white;
    padding:1px 6px;
    border-radius:3px;
    letter-spacing:0.5px;
}
.tpl-pick-check{
    font-size:14px;
    color:var(--accent-color);
    font-weight:800;
    width:22px;
    height:22px;
    border-radius:50%;
    background:rgba(56,189,248,0.15);
    display:flex;
    align-items:center;
    justify-content:center;
    opacity:0;
    transition:opacity .15s ease;
    flex-shrink:0;
}
.tpl-pick.is-selected .tpl-pick-check{ opacity:1; }

/* Empty state used inside #cvPreview when no data yet */
.tpl-empty{
    text-align:center;
    padding:40px 20px;
    color:var(--accent-color);
    background:white;
    color:#334155;
}
.tpl-empty h3{
    font-size:18px;
    margin-bottom:10px;
    color:#0f172a;
}
.tpl-empty p{
    font-size:14px;
    color:#64748b;
}

/* Mobile picker layout — keep 2 columns so thumbnails stay readable */
@media (max-width:768px){
    .template-selector{ grid-template-columns:repeat(2,1fr); gap:10px; }
    .tpl-pick-meta{ padding:8px 10px; gap:8px; }
    .tpl-pick-name{ font-size:12px; }
    .tpl-pick-desc{ font-size:10.5px; -webkit-line-clamp:2; }
    .tpl-pick-icon{ font-size:16px; width:22px; }
}
@media (max-width:480px){
    .template-selector{ grid-template-columns:repeat(2,1fr); gap:8px; }
    .tpl-pick-desc{ display:none; }
}
