/* ========== CSS RESET & VARIABLES ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary:        #1b2e4b;
    --primary-light:  #243d63;
    --accent:         #2563eb;
    --accent-soft:    #eff4ff;
    --accent-mid:     #93bbfc;
    --text:           #1e293b;
    --text-light:     #475569;
    --text-muted:     #94a3b8;
    --white:          #ffffff;
    --bg:             #eef1f7;
    --border:         #e2e8f0;
    --sidebar-bg:     #1b2e4b;
    --sidebar-text:   #b8cde0;
    --sidebar-accent: #60a5fa;
    --shadow:         0 6px 32px rgba(0,0,0,0.10);
    --shadow-sm:      0 2px 10px rgba(0,0,0,0.06);
    --radius:         8px;
    --font-main:      'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ========== CONTROL BAR ========== */
.control-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 10px 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    box-shadow: 0 2px 24px rgba(0,0,0,0.18);
}

.control-bar .btn-group {
    display: flex;
    gap: 2px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 3px;
}

.control-bar button {
    font-family: var(--font-main);
    font-size: 12.5px;
    font-weight: 500;
    padding: 7px 18px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.22s ease;
    color: rgba(255,255,255,0.65);
    background: transparent;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.control-bar button svg {
    flex-shrink: 0;
    opacity: 0.8;
    transition: opacity 0.22s;
}

.control-bar button.active {
    background: rgba(255,255,255,0.94);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.14);
}

.control-bar button.active svg { opacity: 1; }

.control-bar button:hover:not(.active) {
    color: #fff;
    background: rgba(255,255,255,0.13);
}

.control-bar button:hover:not(.active) svg { opacity: 1; }

.control-bar .separator {
    width: 1px;
    height: 26px;
    background: rgba(255,255,255,0.18);
    flex-shrink: 0;
}

.print-btn {
    font-family: var(--font-main);
    font-size: 12.5px;
    font-weight: 600;
    padding: 7px 22px;
    border: 1.5px solid rgba(255,255,255,0.28);
    border-radius: 8px;
    cursor: pointer;
    color: #fff;
    background: transparent;
    transition: all 0.22s ease;
    display: flex;
    align-items: center;
    gap: 7px;
}

.print-btn:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.55);
}

.ai-btn {
    background: linear-gradient(135deg, #2563eb, #3b82f6) !important;
    color: #fff !important;
    border: none !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 10px rgba(37,99,235,0.4) !important;
}

.ai-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #2563eb) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37,99,235,0.5) !important;
}

/* ========== PAGE CONTAINER ========== */
.page-wrapper {
    display: flex;
    justify-content: center;
    padding: 76px 20px 48px;
}

.page {
    width: 210mm;
    min-height: 297mm;
    background: var(--white);
    box-shadow: var(--shadow);
    display: none;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.28s ease;
}

.page.active {
    display: block;
}

.page.visible {
    opacity: 1;
}

/* ========== CV LAYOUT ========== */
.cv-layout {
    display: grid;
    grid-template-columns: 188px 1fr;
    min-height: 297mm;
}

/* --- SIDEBAR --- */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 26px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Photo */
.photo-container {
    width: 106px;
    height: 106px;
    border-radius: 12px;
    overflow: hidden;
    margin: 0 auto 2px;
    border: 2px solid rgba(255,255,255,0.12);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 12%;
}

/* Sidebar section */
.sidebar-section { margin-bottom: 0; }

.sidebar-title {
    font-size: 7.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--sidebar-accent);
    margin-bottom: 7px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

/* Contact items — SVG icons */
.contact-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 8px;
    margin-bottom: 5px;
    color: var(--sidebar-text);
    line-height: 1.35;
}

.contact-item .c-icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    margin-top: 0.5px;
    opacity: 0.75;
}

/* Skill Tags (replacing bars) */
.skill-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.skill-tag {
    font-size: 7.5px;
    font-weight: 500;
    padding: 2.5px 7px;
    background: rgba(255,255,255,0.08);
    color: var(--sidebar-text);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
    line-height: 1.4;
    white-space: nowrap;
}

/* Languages */
.lang-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 8px;
    margin-bottom: 5px;
}

.lang-name { font-weight: 500; color: #fff; }

.lang-level {
    font-size: 7px;
    color: var(--sidebar-accent);
    font-weight: 500;
    background: rgba(96,165,250,0.12);
    padding: 1.5px 5px;
    border-radius: 10px;
}

/* Education */
.edu-item { margin-bottom: 7px; }

.edu-degree {
    font-size: 8px;
    font-weight: 600;
    color: #fff;
    line-height: 1.25;
}

.edu-school {
    font-size: 7.5px;
    color: var(--sidebar-text);
    margin-top: 1px;
}

.edu-year {
    font-size: 7px;
    color: var(--sidebar-accent);
    margin-top: 1px;
}

/* Certifications */
.cert-item {
    font-size: 7.5px;
    margin-bottom: 6px;
    line-height: 1.3;
}

.cert-item strong {
    display: block;
    font-size: 8px;
    color: #fff;
    font-weight: 600;
}

.cert-item span {
    color: rgba(184,205,224,0.7);
    font-size: 7px;
}

/* --- MAIN CONTENT --- */
.main-content {
    padding: 26px 26px 20px 22px;
}

.header-name {
    font-family: var(--font-main);
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    letter-spacing: -0.3px;
    margin-bottom: 3px;
}

.header-title {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.profile-summary {
    font-size: 8.5px;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Key metrics */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.metric {
    text-align: center;
    padding: 8px 4px;
    background: var(--accent-soft);
    border-radius: 6px;
    border: 1px solid rgba(37,99,235,0.08);
}

.metric-value {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.metric-label {
    font-size: 6.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 3px;
    font-weight: 500;
}

/* Section */
.section { margin-bottom: 12px; }

.section-header {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: var(--primary);
    margin-bottom: 9px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Experience entry */
.exp-entry {
    margin-bottom: 9px;
    position: relative;
    padding-left: 11px;
}

.exp-entry::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

.exp-entry::after {
    content: '';
    position: absolute;
    left: 1.5px;
    top: 12px;
    bottom: -3px;
    width: 1px;
    background: var(--border);
}

.exp-entry:last-child::after { display: none; }

.exp-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1px;
}

.exp-title {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.exp-date {
    font-size: 7.5px;
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
    margin-left: 6px;
    flex-shrink: 0;
}

.exp-company {
    font-size: 8px;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 3px;
}

.exp-bullets {
    list-style: none;
    padding: 0;
}

.exp-bullets li {
    font-size: 8px;
    color: var(--text-light);
    margin-bottom: 1.5px;
    padding-left: 10px;
    position: relative;
    line-height: 1.45;
}

.exp-bullets li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-size: 7.5px;
}

.highlight {
    font-weight: 600;
    color: var(--text);
}

/* ========== COVER LETTER LAYOUT ========== */
.cover-layout {
    padding: 0;
    min-height: 297mm;
    display: flex;
    flex-direction: column;
}

/* Cover Header — light style */
.cover-header {
    background: var(--white);
    border-bottom: 2.5px solid var(--accent);
    padding: 28px 50px 22px;
    display: flex;
    align-items: center;
    gap: 22px;
}

.cover-photo {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--border);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.cover-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 12%;
}

.cover-header-text { flex: 1; }

.cover-header-name {
    font-family: var(--font-main);
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    letter-spacing: -0.2px;
    margin-bottom: 3px;
}

.cover-header-title {
    font-size: 10.5px;
    color: var(--accent);
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.cover-contact-row {
    display: flex;
    gap: 18px;
    font-size: 8.5px;
    color: var(--text-light);
    flex-wrap: wrap;
}

.cover-contact-row span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cover-contact-row svg {
    width: 11px;
    height: 11px;
    opacity: 0.65;
    flex-shrink: 0;
}

/* Cover body */
.cover-body {
    padding: 30px 50px 38px;
    flex: 1;
}

.cover-date {
    font-size: 9.5px;
    color: var(--text-muted);
    margin-bottom: 18px;
    font-weight: 400;
}

.cover-greeting {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 14px;
}

.cover-paragraph {
    font-size: 10px;
    color: var(--text);
    line-height: 1.72;
    margin-bottom: 12px;
    text-align: justify;
}

.cover-closing {
    margin-top: 22px;
    font-size: 10px;
    color: var(--text);
    line-height: 1.65;
}

.cover-signature {
    margin-top: 14px;
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--primary);
    font-weight: 700;
}

.signature-img {
    max-height: 38px;
    max-width: 130px;
    width: auto;
    height: auto;
    margin-bottom: 3px;
    opacity: 0.82;
    display: block;
}

.cover-highlight-box {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    padding: 13px 18px;
    margin: 14px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.cover-highlight-box ul {
    list-style: none;
    padding: 0;
}

.cover-highlight-box li {
    font-size: 9.5px;
    color: var(--text);
    margin-bottom: 5px;
    padding-left: 16px;
    position: relative;
    line-height: 1.55;
}

.cover-highlight-box li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
    font-size: 9px;
}

/* ========== PRINT STYLES ========== */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        background: white;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    .control-bar,
    .generator-panel,
    .panel-overlay { display: none !important; }

    .page-wrapper { padding: 0; }

    .page {
        width: 210mm;
        min-height: 297mm;
        box-shadow: none;
        page-break-after: avoid;
        page-break-inside: avoid;
        opacity: 1 !important;
    }

    .cv-layout { min-height: 297mm; }
    .cover-layout { min-height: 297mm; }

    .sidebar,
    .cover-header,
    .metric,
    .skill-tag,
    .skill-bar,
    .skill-bar-fill,
    .cover-highlight-box {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
}

/* ========== RESPONSIVE ========== */
@media screen and (max-width: 900px) {
    .page { width: 100%; min-height: auto; }
    .cv-layout { grid-template-columns: 1fr; }
    .sidebar { padding: 20px; }
    .control-bar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
    .cover-header { padding: 20px 24px; }
    .cover-body { padding: 20px 24px 28px; }
}

/* ========== AI GENERATOR PANEL ========== */
.panel-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,23,42,0.55);
    z-index: 1001;
    display: none;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.generator-panel {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.97);
    width: 92%;
    max-width: 580px;
    background: #fff;
    border-radius: 16px;
    z-index: 1002;
    box-shadow: 0 20px 60px rgba(0,0,0,0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.generator-panel.open {
    transform: translate(-50%, -50%) scale(1);
}

.panel-header {
    padding: 18px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover { background: rgba(255,255,255,0.22); }

.panel-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-desc {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
}

#jobDescriptionInput {
    width: 100%;
    height: 200px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 13px;
    resize: vertical;
    transition: border-color 0.2s;
    color: var(--text);
    outline: none;
}

#jobDescriptionInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.generate-btn {
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    color: #fff;
    border: none;
    padding: 13px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.22s;
    font-family: var(--font-main);
    letter-spacing: 0.2px;
    box-shadow: 0 2px 12px rgba(37,99,235,0.3);
}

.generate-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    box-shadow: 0 4px 18px rgba(37,99,235,0.45);
    transform: translateY(-1px);
}

.generate-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-light);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.error-msg {
    color: #dc2626;
    font-size: 13px;
    text-align: center;
    background: #fef2f2;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

/* Hide photo utility */
.photo-hidden { display: none !important; }