/* =========================================================
   CareerPilot Resume Templates v1.0
========================================================= */

.template-modal {
    position: fixed;
    inset: 0;
    z-index: 1600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.template-modal.is-open {
    display: flex;
}

.template-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(5px);
}

.template-modal-content {
    position: relative;
    z-index: 1;
    width: min(980px, 100%);
    max-height: min(820px, 90vh);
    overflow-y: auto;
    padding: 30px;
    background: var(--cp-surface, #ffffff);
    color: var(--cp-text, #111827);
    border: 1px solid var(--cp-border, #dce4ef);
    border-radius: 24px;
    box-shadow: 0 30px 90px rgba(15, 23, 42, 0.32);
}

.template-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.template-modal-header h2 {
    margin: 6px 0 0;
    font-size: 30px;
}

.template-modal-description {
    margin: 16px 0 24px;
    color: var(--cp-text-soft, #64748b);
}

.template-modal-close {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid var(--cp-border, #dce4ef);
    border-radius: 50%;
    background: var(--cp-surface-soft, #f8fafc);
    color: var(--cp-text, #111827);
    font-size: 26px;
    cursor: pointer;
}

.resume-template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.resume-template-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    padding: 15px;
    background: var(--cp-surface-soft, #f8fafc);
    color: var(--cp-text, #111827);
    border: 2px solid transparent;
    border-radius: 18px;
    text-align: left;
    cursor: pointer;
}

.resume-template-card:hover,
.resume-template-card.is-selected {
    border-color: var(--cp-primary, #2563eb);
    transform: translateY(-2px);
}

.resume-template-card strong {
    font-size: 16px;
}

.resume-template-card small {
    min-height: 54px;
    color: var(--cp-text-soft, #64748b);
    line-height: 1.45;
}

.resume-template-selected-label {
    color: var(--cp-primary, #2563eb);
    font-size: 13px;
    font-weight: 700;
}

.resume-template-thumbnail {
    height: 150px;
    display: grid;
    grid-template-rows: 32px repeat(3, 1fr);
    gap: 9px;
    padding: 15px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #dbe3ee;
    border-radius: 11px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.09);
}

.resume-template-thumbnail span {
    display: block;
    border-radius: 3px;
    background: #dbe3ee;
}

.template-thumbnail-professional span:first-child {
    background: #2563eb;
}
.template-thumbnail-executive span:first-child {
    background: #111827;
}
.template-thumbnail-ats span:first-child {
    height: 8px;
    align-self: center;
    background: #334155;
}
.template-thumbnail-modern {
    border-left: 22px solid #0f766e;
}
.template-thumbnail-modern span:first-child {
    background: #0f766e;
}
.template-thumbnail-creative {
    background: linear-gradient(135deg, #fff7ed, #fdf2f8);
}
.template-thumbnail-creative span:first-child {
    background: linear-gradient(90deg, #ea580c, #db2777);
}
.template-thumbnail-minimal span {
    height: 6px;
    align-self: center;
    background: #cbd5e1;
}

.template-modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
}

.template-cancel-button {
    padding: 11px 18px;
    background: var(--cp-surface-soft, #f8fafc);
    color: var(--cp-text, #111827);
    border: 1px solid var(--cp-border, #dce4ef);
    border-radius: 11px;
    font-weight: 700;
    cursor: pointer;
}

body.template-modal-open {
    overflow: hidden;
}

/* Shared template foundations */
.resume-preview-page {
    --resume-accent: #2563eb;
    --resume-dark: #0f172a;
    --resume-body: #334155;
    --resume-muted: #64748b;
    --resume-soft: #eff6ff;
    --resume-line: #dbeafe;
    font-family: Inter, Arial, sans-serif;
}

.resume-preview-page .preview-header {
    border-bottom-color: var(--resume-accent);
}

.resume-preview-page .preview-header > p,
.resume-preview-page .preview-entry-heading p {
    color: var(--resume-accent);
}

.resume-preview-page .preview-section h2 {
    color: var(--resume-dark);
}

.resume-preview-page .preview-skill-badge {
    background: var(--resume-soft);
    color: var(--resume-accent);
    border-color: var(--resume-line);
}

/* 1 — Professional Blue */
.resume-template-professional {
    --resume-accent: #2563eb;
    --resume-dark: #0f172a;
    --resume-soft: #eff6ff;
    --resume-line: #bfdbfe;
}

/* 2 — Executive */
.resume-template-executive {
    --resume-accent: #111827;
    --resume-dark: #000000;
    --resume-soft: #f3f4f6;
    --resume-line: #d1d5db;
    padding: 62px;
    font-family: Georgia, "Times New Roman", serif;
}

.resume-template-executive .preview-header {
    text-align: center;
    border-bottom: 1px solid #111827;
}

.resume-template-executive .preview-header-layout {
    align-items: center;
}

.resume-template-executive .preview-header h1 {
    font-size: 44px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.resume-template-executive .preview-header > p,
.resume-template-executive .preview-header-content > p {
    color: #111827;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.resume-template-executive .preview-contact {
    justify-content: center;
}

.resume-template-executive .preview-section h2 {
    padding-bottom: 7px;
    border-bottom: 1px solid #9ca3af;
    letter-spacing: 0.15em;
}

.resume-template-executive .preview-skill-badge {
    border-radius: 3px;
}

/* 3 — ATS Professional */
.resume-template-ats {
    --resume-accent: #111827;
    --resume-dark: #111827;
    --resume-body: #111827;
    --resume-muted: #374151;
    --resume-soft: #ffffff;
    --resume-line: #9ca3af;
    padding: 42px;
    box-shadow: none;
    border: 1px solid #d1d5db;
    border-radius: 0;
    font-family: Arial, Helvetica, sans-serif;
}

.resume-template-ats .preview-header {
    padding-bottom: 16px;
    border-bottom: 2px solid #111827;
}

.resume-template-ats .preview-header h1 {
    font-size: 32px;
}

.resume-template-ats .preview-profile-photo {
    display: block;
}

.resume-template-ats .preview-section {
    margin-top: 20px;
}

.resume-template-ats .preview-section h2 {
    margin-bottom: 9px;
    font-size: 14px;
    letter-spacing: 0.04em;
}

.resume-template-ats .preview-skill-badge {
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: #111827;
    font-weight: 400;
}

.resume-template-ats .preview-skill-badge:not(:last-child)::after {
    content: " •";
}

/* 4 — Modern */
.resume-template-modern {
    --resume-accent: #0f766e;
    --resume-dark: #134e4a;
    --resume-soft: #f0fdfa;
    --resume-line: #99f6e4;
    border-left: 18px solid #0f766e;
}

.resume-template-modern .preview-header {
    margin: -52px -52px 0;
    padding: 44px 52px 30px;
    background: #0f766e;
    border: 0;
}

.resume-template-modern .preview-header h1,
.resume-template-modern .preview-header > p,
.resume-template-modern .preview-header-content > p,
.resume-template-modern .preview-contact {
    color: #ffffff;
}

.resume-template-modern .preview-profile-photo {
    border-color: rgba(255, 255, 255, 0.8);
}

/* 5 — Creative */
.resume-template-creative {
    --resume-accent: #db2777;
    --resume-dark: #831843;
    --resume-soft: #fdf2f8;
    --resume-line: #fbcfe8;
    background:
        linear-gradient(180deg, #fff7ed 0, #ffffff 230px);
}

.resume-template-creative .preview-header {
    border-bottom: 0;
}

.resume-template-creative .preview-header h1 {
    color: #9a3412;
    font-size: 42px;
}

.resume-template-creative .preview-section h2 {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(90deg, #ffedd5, #fce7f3);
    border-radius: 999px;
    color: #9d174d;
}

.resume-template-creative .preview-profile-photo {
    border-width: 5px;
    border-color: #f9a8d4;
    transform: rotate(2deg);
}

/* 6 — Minimal */
.resume-template-minimal {
    --resume-accent: #475569;
    --resume-dark: #1e293b;
    --resume-body: #475569;
    --resume-muted: #64748b;
    --resume-soft: #f8fafc;
    --resume-line: #e2e8f0;
    padding: 64px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

.resume-template-minimal .preview-header {
    padding-bottom: 20px;
    border-bottom: 1px solid #cbd5e1;
}

.resume-template-minimal .preview-header h1 {
    font-size: 35px;
    font-weight: 500;
    letter-spacing: 0;
}

.resume-template-minimal .preview-header > p,
.resume-template-minimal .preview-header-content > p {
    color: #64748b;
    font-weight: 500;
}

.resume-template-minimal .preview-section {
    margin-top: 34px;
}

.resume-template-minimal .preview-section h2 {
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.18em;
}

.resume-template-minimal .preview-skill-badge {
    background: transparent;
    border-color: #cbd5e1;
    color: #475569;
}

/* Print and PDF */
@media print {
    .resume-preview-page {
        box-shadow: none !important;
    }
}

@media (max-width: 760px) {
    .resume-template-grid {
        grid-template-columns: 1fr;
    }

    .template-modal-content {
        padding: 20px;
    }
}

/* =========================================================
   CareerPilot Template Modal Position Fix v1.0
   Keep template selector fully visible from the top
========================================================= */

.template-modal {
    align-items: flex-start !important;
    justify-content: center !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding: 32px 24px !important;
    box-sizing: border-box !important;
}

.template-modal-content {
    flex: 0 0 auto !important;
    width: min(980px, 100%) !important;
    max-height: calc(100dvh - 64px) !important;
    margin: 0 auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-sizing: border-box !important;
}

@media (max-width: 760px) {
    .template-modal {
        padding: 16px !important;
    }

    .template-modal-content {
        max-height: calc(100dvh - 32px) !important;
    }
}



/* =========================================================
   CareerPilot Template Modal — Professional Immediate Display Fix
   Keeps the chooser inside the viewport with no outer blank scroll.
========================================================= */

.template-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    padding: 20px !important;
    box-sizing: border-box !important;
}

.template-modal.is-open {
    display: flex !important;
}

.template-modal-overlay {
    position: fixed !important;
    inset: 0 !important;
}

.template-modal-content {
    position: relative !important;
    z-index: 1 !important;
    width: min(980px, calc(100vw - 40px)) !important;
    max-width: 980px !important;
    max-height: calc(100dvh - 40px) !important;
    margin: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
}

body.template-modal-open {
    overflow: hidden !important;
}

@media (max-width: 760px) {
    .template-modal {
        padding: 12px !important;
    }

    .template-modal-content {
        width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        padding: 20px !important;
        border-radius: 18px !important;
    }
}

/* =========================================================
   CareerPilot Template Modal — Mobile Sheet Fix v3
   Desktop remains unchanged. On phones the chooser begins
   below the mobile navigation and only the panel itself scrolls.
========================================================= */
@media (max-width: 760px) {
    html,
    body {
        overscroll-behavior-y: none;
    }

    body.template-modal-open {
        overflow: hidden !important;
        height: 100dvh !important;
        touch-action: none;
    }

    .template-modal {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: 130px !important;
        bottom: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 8px 10px 10px !important;
        align-items: flex-start !important;
        justify-content: center !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .template-modal-overlay {
        position: absolute !important;
        inset: 0 !important;
    }

    .template-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 18px 18px calc(20px + env(safe-area-inset-bottom)) !important;
        border-radius: 18px 18px 0 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        box-sizing: border-box !important;
    }

    .template-modal-header {
        gap: 12px !important;
        margin: 0 !important;
    }

    .template-modal-header h2 {
        margin-top: 4px !important;
        font-size: clamp(27px, 8vw, 34px) !important;
        line-height: 1.08 !important;
    }

    .template-modal-description {
        margin: 12px 0 16px !important;
        line-height: 1.5 !important;
    }

    .template-modal-close {
        width: 44px !important;
        height: 44px !important;
        flex-basis: 44px !important;
    }

    .resume-template-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .resume-template-card {
        gap: 8px !important;
        padding: 14px !important;
        border-radius: 16px !important;
    }

    .resume-template-thumbnail {
        height: 126px !important;
        padding: 12px !important;
        gap: 7px !important;
    }

    .resume-template-card small {
        min-height: 0 !important;
    }

    .template-modal-footer {
        position: sticky !important;
        bottom: -1px !important;
        z-index: 4 !important;
        margin: 16px -18px -18px !important;
        padding: 12px 18px calc(12px + env(safe-area-inset-bottom)) !important;
        background: var(--cp-surface, #ffffff) !important;
        border-top: 1px solid var(--cp-border, #dce4ef) !important;
    }
}

/* Short mobile screens: reserve slightly less space for compact navs. */
@media (max-width: 760px) and (max-height: 700px) {
    .template-modal {
        top: 112px !important;
    }
}

/* =========================================================
   CareerPilot Template Modal — Desktop Navigation Clearance v4
   Desktop only. Keeps the chooser fully below the workspace
   navigation while preserving the proven mobile sheet behavior.
========================================================= */
@media (min-width: 761px) {
    body.template-modal-open {
        overflow: hidden !important;
    }

    .template-modal {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: 82px !important;
        bottom: 0 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 18px 24px 24px !important;
        align-items: flex-start !important;
        justify-content: center !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .template-modal-overlay {
        position: absolute !important;
        inset: 0 !important;
    }

    .template-modal-content {
        flex: 0 0 auto !important;
        width: min(980px, calc(100vw - 48px)) !important;
        max-width: 100% !important;
        max-height: calc(100dvh - 124px) !important;
        min-height: 0 !important;
        margin: 0 auto !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        scrollbar-gutter: stable !important;
        box-sizing: border-box !important;
    }
}

