@page {
    size: A4;
    margin: 16mm 15mm;
}

:root {
    --navy: #0b2545;
    --navy-dark: #071a33;
    --orange: #e8720c;
    --orange-dark: #c65e05;
    --grey-bg: #f5f7fa;
    --border: #d8dee6;
    --text: #1e2733;
    --text-light: #5b6b7c;
    --white: #ffffff;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--grey-bg);
    line-height: 1.5;
}

a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--navy);
    color: var(--white);
}
.site-header .brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 8px;
}
.site-header .brand span { color: var(--orange); }
.brand-logo {
    height: 28px;
    width: auto;
    vertical-align: middle;
    object-fit: contain;
}
.site-nav a { color: var(--white); margin-left: 16px; opacity: 0.85; }

.site-footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-light);
    font-size: 0.85rem;
}

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 60px; }

/* Landing page */
.hero {
    text-align: center;
    padding: 48px 16px 32px;
}
.hero h1 { font-size: 2rem; color: var(--navy); margin-bottom: 8px; }
.hero .tagline { color: var(--orange-dark); font-weight: 600; margin-bottom: 12px; }
.hero p.sub { color: var(--text-light); max-width: 480px; margin: 0 auto 28px; }

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 340px;
    margin: 0 auto;
}

.btn {
    display: inline-block;
    padding: 14px 22px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    text-align: center;
}
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-dark); text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--navy); border: 2px solid var(--navy); }
.btn-secondary:hover { background: var(--navy); color: var(--white); text-decoration: none; }
.btn-block { width: 100%; }
.btn-small { padding: 8px 14px; font-size: 0.85rem; }
.btn-whatsapp { background: #25D366; color: var(--white); }
.btn-whatsapp:hover { background: #1ebc59; text-decoration: none; }

.whatsapp-link { color: #25D366 !important; font-weight: 600; opacity: 1 !important; }
.site-footer a { color: #1ebc59; }

.login-note { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.free-note { margin-top: 24px; font-size: 0.85rem; color: var(--text-light); }

.how-it-works {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 40px;
}
.how-it-works h2 { color: var(--navy); font-size: 1.1rem; margin-top: 0; }
.how-it-works ol { padding-left: 20px; color: var(--text); }
.how-it-works li { margin-bottom: 8px; }

/* Progress indicator */
.progress-wrap { margin-bottom: 24px; }
.progress-label { font-size: 0.85rem; color: var(--text-light); margin-bottom: 6px; }
.progress-bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--orange); }

/* Wizard card */
.wizard-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.wizard-card h1 { color: var(--navy); font-size: 1.4rem; margin-top: 0; }
.wizard-help { color: var(--text-light); font-size: 0.9rem; margin-top: -8px; margin-bottom: 16px; }

form .field { margin-bottom: 16px; }
form label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; color: var(--navy); }
form input[type=text], form input[type=email], form input[type=url],
form input[type=tel], form input[type=file], form input[type=password],
form textarea, form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d8dee6;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
    background: #ffffff;
    color: #1e2733;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    line-height: 1.4;
}
form input[type=password] {
    /* Explicit reset — some browsers apply different metrics to password fields */
    padding: 10px 12px;
    border: 1px solid #d8dee6;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.4;
}
form input[type=text]:focus, form input[type=email]:focus, form input[type=url]:focus,
form input[type=tel]:focus, form input[type=password]:focus,
form textarea:focus, form select:focus {
    border-color: #0b2545;
    box-shadow: 0 0 0 2px rgba(11,37,69,0.1);
    outline: none;
}
form textarea { resize: vertical; }
form .checkbox-field { display: flex; align-items: center; gap: 8px; }
form .checkbox-field label { margin-bottom: 0; }
.help-text { color: var(--text-light); font-size: 0.8rem; margin-top: 4px; }
.errorlist { color: #b3261e; font-size: 0.85rem; padding-left: 16px; margin: 4px 0; }

.wizard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 10px;
    flex-wrap: wrap;
}

/* Template selection */
.template-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 640px) {
    .template-grid { grid-template-columns: 1fr 1fr; }
}
.template-option {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    position: relative;
}
.template-option.selected { border-color: var(--orange); background: #fff7ef; }
.template-option input { position: absolute; top: 14px; right: 14px; }
.template-thumb {
    height: 130px;
    border-radius: 6px;
    margin-bottom: 10px;
    background: var(--grey-bg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 5px;
}
.thumb-bar { height: 6px; border-radius: 3px; background: var(--border); }
.thumb-bar.dark { background: var(--navy); width: 60%; }
.thumb-bar.accent { background: var(--orange); width: 35%; }
.template-option strong { color: var(--navy); }
.template-option p { margin: 4px 0 0; font-size: 0.82rem; color: var(--text-light); }
.premium-badge {
    display: inline-block;
    background: var(--navy);
    color: var(--orange);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
}
.template-option.locked { opacity: 0.92; }
.template-option.locked .template-thumb { position: relative; }

/* Formset rows */
.formset-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
    position: relative;
}
.formset-row .row-number { font-size: 0.8rem; color: var(--text-light); margin-bottom: 8px; font-weight: 600; }
.delete-field { font-size: 0.85rem; color: var(--text-light); }

/* Preview */
.preview-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.a4-page {
    background: var(--white);
    width: 100%;
    max-width: 794px;
    min-height: 1123px;
    margin: 0 auto 24px;
    padding: 48px 52px;
    box-shadow: 0 0 0 1px var(--border), 0 6px 18px rgba(0,0,0,0.08);
}
@media (max-width: 820px) {
    .a4-page { padding: 28px 22px; min-height: auto; }
}

/* CV content styling (shared base — templates override accents) */
.cv-name { font-size: 1.6rem; font-weight: 700; margin: 0; color: #1e2733; }
.cv-title { color: #c65e05; font-weight: 600; margin: 2px 0 10px; }
.cv-contact { font-size: 0.85rem; color: #5b6b7c; margin-bottom: 18px; }
.cv-contact span { margin-right: 14px; }
.cv-contact span:not(:last-child)::after { content: "  ·  "; color: #5b6b7c; }
/* Section divider line — literal hex so WeasyPrint renders it in PDFs */
.cv-section-title {
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #0b2545;
    border-bottom: 2px solid #0b2545;
    padding-bottom: 4px;
    margin: 22px 0 10px;
}
.cv-entry { margin-bottom: 12px; }
.cv-entry-header { display: flex; justify-content: space-between; font-weight: 600; flex-wrap: wrap; gap: 4px; }
.cv-entry-sub { font-size: 0.85rem; color: var(--text-light); margin-bottom: 4px; }
.cv-entry p { margin: 2px 0; font-size: 0.92rem; }
.cv-skills-list, .cv-lang-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.cv-skills-list li, .cv-lang-list li {
    background: var(--grey-bg);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.82rem;
}

/* ATS-simple override: no pills, no colour blocks, plain print-safe layout */
.tpl-ats_simple .cv-section-title { border-bottom: 1px solid #000; color: #000; }
.tpl-ats_simple .cv-title { color: #000; }
.tpl-ats_simple .cv-skills-list li, .tpl-ats_simple .cv-lang-list li {
    background: none; border: none; padding: 0; border-radius: 0;
}
.tpl-ats_simple .cv-skills-list, .tpl-ats_simple .cv-lang-list { display: block; }
.tpl-ats_simple .cv-skills-list li::after, .tpl-ats_simple .cv-lang-list li::after { content: ", "; }
.tpl-ats_simple .cv-skills-list li:last-child::after, .tpl-ats_simple .cv-lang-list li:last-child::after { content: ""; }

/* Graduate/entry: education-first emphasis handled by template ordering */
.tpl-graduate_entry .cv-name { color: var(--navy); }

/* Classic professional: centered header */
.tpl-classic_professional .cv-header { text-align: center; }
.tpl-classic_professional .cv-contact { justify-content: center; display: flex; flex-wrap: wrap; }
.tpl-classic_professional .cv-section-title { text-align: left; }

/* ===================== PREMIUM TEMPLATES ===================== */

/* --- Executive: navy sidebar ---
   WeasyPrint (PDF) does not support CSS Grid reliably across page breaks.
   We use a table-based layout for print to guarantee the sidebar renders.
   The screen layout uses the existing flex/grid classes. */
.exec-grid { display: grid; grid-template-columns: 34% 66%; gap: 0; align-items: stretch; }
@media (max-width: 600px) {
    /* On mobile preview, stack sidebar above main and keep the navy background */
    .exec-grid { display: block; }
    .exec-grid .exec-sidebar {
        background: #0b2545;
        /* Reset the negative margin for mobile — full width flush block */
        margin: -48px -52px 0 !important;
        padding: 32px 24px 24px !important;
        border-radius: 0;
    }
    .exec-grid .exec-main {
        padding: 24px 0 0 !important;
        margin: 0 !important;
    }
}
@media (max-width: 820px) and (min-width: 601px) {
    .exec-grid { grid-template-columns: 38% 62%; }
}
.exec-sidebar { background: #0b2545; color: #dbe4f0; padding: 8mm 6mm; }
.exec-photo { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; margin-bottom: 14px; border: 3px solid #e8720c; }
.exec-name { font-size: 1.3rem; font-weight: 700; color: #ffffff; margin: 0 0 2px; }
.exec-title { color: #e8720c; font-weight: 600; font-size: 0.9rem; margin: 0 0 20px; }
.exec-block { margin-bottom: 20px; }
.exec-block-title {
    text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.08em;
    color: #e8720c; border-bottom: 1px solid rgba(255,255,255,0.25);
    padding-bottom: 4px; margin-bottom: 8px; font-weight: 700;
}
.exec-block p { margin: 3px 0; font-size: 0.82rem; word-break: break-word; }
.exec-list { list-style: none; padding: 0; margin: 0; }
.exec-list li { font-size: 0.82rem; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.12); }
.exec-main { padding: 6mm 4mm 4mm 8mm; }
.exec-main .cv-section-title { color: #0b2545; border-bottom-color: #e8720c; }

/* --- Creative Minimal --- */
.tpl-creative_premium { font-family: Georgia, 'Times New Roman', serif; }
.tpl-creative_premium .cv-name { font-size: 1.8rem; font-weight: 400; letter-spacing: 0.02em; }
.tpl-creative_premium .cv-title { color: #5b6b7c; font-style: italic; font-weight: 400; }
.tpl-creative_premium .cv-header { border-bottom: 1px solid #e8720c; padding-bottom: 16px; margin-bottom: 4px; }
.tpl-creative_premium .cv-section-title {
    border-bottom: none; color: #1e2733; font-weight: 400; letter-spacing: 0.14em;
    position: relative; padding-bottom: 8px;
}
.tpl-creative_premium .cv-section-title::after {
    content: ""; display: block; width: 32px; height: 2px; background: #e8720c; margin-top: 6px;
}
.tpl-creative_premium .cv-skills-list li, .tpl-creative_premium .cv-lang-list li {
    background: none; border: 1px solid #d8dee6; color: #5b6b7c;
}

/* --- Tech Focus --- */
.tpl-tech_premium .cv-name { color: #0b2545; }
.tpl-tech_premium .cv-title { font-family: 'Courier New', monospace; }
.tpl-tech_premium .cv-skills-list li {
    background: #0b2545; color: #ffffff; font-family: 'Courier New', monospace;
    font-size: 0.78rem; border: none;
}
.tpl-tech_premium .cv-section-title { color: #0b2545; border-bottom-color: #0b2545; font-family: 'Courier New', monospace; }

/* ===================== PDF / PRINT STYLES =====================
   WeasyPrint renders the CV HTML directly — it does NOT load the
   browser's media queries, but it DOES honour @media print rules.
   All colors here use literal hex values because WeasyPrint has
   limited support for CSS custom properties (var(--x)).
   ============================================================= */
@media print {
    .site-header, .site-footer, .preview-toolbar, .no-print { display: none !important; }
    .a4-page { box-shadow: none; margin: 0; padding: 0; max-width: 100%; }
    body { background: #ffffff; }

    /* Ensure colors render in print */
    .cv-section-title { color: #0b2545 !important; border-bottom-color: #0b2545 !important; }
    .cv-name { color: #1e2733 !important; }
    .cv-title { color: #c65e05 !important; }

    /* Executive PDF layout — table-based so sidebar background prints,
       and negative margins pull flush to the @page margin edges */
    .exec-grid {
        display: table !important;
        width: 100% !important;
        table-layout: fixed !important;
        /* Pull flush to @page margins (16mm top/bottom, 15mm left/right) */
        margin: -16mm -15mm !important;
        width: calc(100% + 30mm) !important;
        min-height: calc(100% + 32mm) !important;
    }
    .exec-sidebar {
        display: table-cell !important;
        width: 34% !important;
        background: #0b2545 !important;
        color: #dbe4f0 !important;
        padding: 16mm 6mm 16mm 8mm !important;
        vertical-align: top !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .exec-main {
        display: table-cell !important;
        width: 66% !important;
        padding: 14mm 6mm 14mm 8mm !important;
        vertical-align: top !important;
    }
    .exec-name  { color: #ffffff !important; font-size: 1.3rem !important; font-weight: 700 !important; }
    .exec-title { color: #e8720c !important; }
    .exec-block-title { color: #e8720c !important; border-bottom-color: rgba(255,255,255,0.25) !important; }
    .exec-list li { color: #dbe4f0 !important; border-bottom-color: rgba(255,255,255,0.12) !important; }
    .exec-block p { color: #dbe4f0 !important; }
    .exec-main .cv-section-title { color: #0b2545 !important; border-bottom-color: #e8720c !important; }

    /* Creative Minimal print */
    .tpl-creative_premium .cv-header { border-bottom-color: #e8720c !important; }
    .tpl-creative_premium .cv-section-title::after { background: #e8720c !important; }

    /* Tech Focus print */
    .tpl-tech_premium .cv-skills-list li { background: #0b2545 !important; color: #ffffff !important; }
    .tpl-tech_premium .cv-section-title { color: #0b2545 !important; border-bottom-color: #0b2545 !important; }

    /* Modern Professional print */
    .tpl-modern_professional .cv-header,
    .tpl-modern_professional .cv-header * { color: #ffffff !important; }

    /* Skills pills print */
    .cv-skills-list li, .cv-lang-list li {
        background: #f5f7fa !important;
        border: 1px solid #d8dee6 !important;
    }
}
