/* ============================================
   CV BUILDER — Complete Styles v21
   ============================================ */
.cv-builder-container {
    display: flex;
    min-height: calc(100vh - 200px);
    gap: 0;
    background: #f0f2f5;
}
.cv-control-panel {
    width: 40%; min-width: 380px; max-width: 500px;
    overflow-y: auto; background: #fff;
    border-right: 1px solid #e2e8f0;
    padding: 20px;
    height: calc(100vh - 200px);
    position: sticky; top: 100px;
}
.cv-preview-panel {
    flex: 1; padding: 30px;
    display: flex; justify-content: center; align-items: flex-start;
    overflow-y: auto; background: #e8ecf1;
    height: calc(100vh - 200px);
}

.a4-container {
    width: 210mm;
    min-height: 297mm;
    overflow: visible;
    background: #ffffff;
    display: block;
    position: relative;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12);
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    box-sizing: border-box;
}

#cv_sortable_area {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.cv-section-block, .exp-item, .edu-item {
    page-break-inside: avoid;
    break-inside: avoid;
}

.page-gap-overlay {
    position: absolute;
    left: -20px; right: -20px;
    height: 24px;
    transform: translateY(-50%);
    background: #e2e8f0;
    border-top: 3px dashed #0f172a;
    border-bottom: 3px dashed #0f172a;
    pointer-events: none;
    z-index: 999;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.page-margin-guide {
    position: absolute;
    left: 0; right: 0;
    pointer-events: none;
    z-index: 60;
    background: repeating-linear-gradient(
        45deg,
        rgba(13, 148, 136, 0.03),
        rgba(13, 148, 136, 0.03) 6px,
        rgba(13, 148, 136, 0.08) 6px,
        rgba(13, 148, 136, 0.08) 12px
    );
}
.page-margin-guide.page-margin-top { border-bottom: 1px dashed rgba(13, 148, 136, 0.25); }
.page-margin-guide.page-margin-bottom { border-top: 1px dashed rgba(13, 148, 136, 0.25); }

.page-num-badge {
    position: absolute;
    right: 14px;
    background: #0f172a; color: #fff;
    font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
    padding: 3px 10px; border-radius: 10px;
    pointer-events: none;
    z-index: 1000;
    font-family: 'Inter', system-ui, sans-serif;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    opacity: 0.92;
}

.cv-builder-header { background: #0f172a; color: #fff; padding: 12px 0; }
.cv-builder-header h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.cv-builder-header .subtitle { font-size: 0.8rem; color: #94a3b8; }

.btn-teal { background: #0d9488; border-color: #0d9488; color: #fff; }
.btn-teal:hover, .btn-teal:focus { background: #0f766e; border-color: #0f766e; color: #fff; }
.btn-outline-teal { color: #0d9488; border-color: #0d9488; }
.btn-outline-teal:hover { background: #0d9488; color: #fff; }

.cv-tag {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.75rem; padding: 3px 10px;
    border-radius: 12px; background: #e2e8f0; color: #1e293b;
    transition: all 0.2s ease;
}
.cv-tag .btn-close { font-size: 0.6rem; cursor: pointer; opacity: 0.7; background: none; border: none; color: inherit; line-height: 1; }
.cv-tag .btn-close:hover { opacity: 1; }
.cv-tag:hover { background: #cbd5e1; }
.cv-tag .lang-level {
    background: #0d9488; color: #fff;
    font-size: 9.5px; font-weight: 600;
    padding: 2px 6px; border-radius: 8px;
    letter-spacing: 0.2px; text-transform: uppercase;
}

.drag-handle, .drag-handle-exp, .drag-handle-edu {
    cursor: move; user-select: none;
    padding: 2px 8px; background: rgba(0,0,0,0.04);
    border-radius: 4px; font-size: 12px;
    display: inline-block; transition: all 0.2s ease;
}
.drag-handle:hover, .drag-handle-exp:hover, .drag-handle-edu:hover { background: #0d9488; color: #fff; }
.drag-handle-exp, .drag-handle-edu { font-size: 11px; padding: 1px 6px; }

.cv-section-block {
    position: relative; padding: 8px 8px 8px 4px;
    border-radius: 6px; transition: background 0.2s ease, border-color 0.2s ease;
    border: 1px solid transparent;
}
.cv-section-block:hover { background: rgba(248, 250, 252, 0.5); border-color: #e2e8f0; }
.cv-section-block .drag-handle,
.cv-section-block[data-section-id] .drag-handle { position: absolute; top: 4px; right: 4px; }

.exp-item, .edu-item { transition: all 0.2s ease; border: 1px solid #e2e8f0 !important; }
.exp-item:hover, .edu-item:hover { border-color: #0d9488 !important; box-shadow: 0 2px 8px rgba(13,148,136,0.1); }
.exp-item.sortable-chosen, .edu-item.sortable-chosen {
    opacity: 0.8; border-color: #0d9488; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.template-btn { transition: all 0.2s ease; }
.template-btn.active.btn-teal { background: #0d9488; color: #fff; border-color: #0d9488; }
.template-btn.btn-outline-dark { border: 1px solid #cbd5e1; color: #475569; }
.template-btn.btn-outline-dark:hover { border-color: #0d9488; color: #0d9488; background: #f0fdfa; }

.form-control-color { height: 32px; padding: 2px; cursor: pointer; border-radius: 6px; }
.form-control-color::-webkit-color-swatch-wrapper { padding: 0; }
.form-control-color::-webkit-color-swatch { border: 1px solid #e2e8f0; border-radius: 4px; }
.theme-preset {
    background: #f1f5f9; border: 1px solid #e2e8f0; color: #334155;
    font-size: 0.72rem; padding: 3px 10px; border-radius: 6px;
    transition: all 0.15s ease;
}
.theme-preset:hover { background: #0d9488; color: #fff; border-color: #0d9488; transform: translateY(-1px); }
.theme-preset:active { transform: translateY(0); }
#inp_theme_font { cursor: pointer; }

.cv-empty-state { display: none; }
.cv-empty-state.visible { display: block; }

.cv-toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #1e293b; color: #fff;
    padding: 12px 20px; border-radius: 8px;
    font-size: 0.85rem; z-index: 9999;
    transform: translateY(100px); opacity: 0;
    transition: all 0.3s ease;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.cv-toast.show { transform: translateY(0); opacity: 1; }
.cv-toast.success { background: #059669; }
.cv-toast.error { background: #dc2626; }
.cv-toast.info { background: #0284c7; }

.photo-uploader { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.photo-dropzone {
    position: relative; width: 140px; height: 140px;
    border-radius: 50%; background: #f8fafc;
    border: 2px dashed #cbd5e1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    outline: none;
}
.photo-dropzone:hover, .photo-dropzone:focus-visible { border-color: #0d9488; background: #f0fdfa; }
.photo-dropzone.dragover { border-color: #0d9488; background: #ccfbf1; transform: scale(1.04); }
.photo-dropzone.has-photo { border-style: solid; border-color: #0d9488; background: #fff; }
.photo-empty {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: #94a3b8; text-align: center; padding: 8px;
    pointer-events: none; user-select: none;
}
.photo-empty svg { color: #94a3b8; }
.photo-empty-title { font-size: 11px; font-weight: 600; color: #334155; line-height: 1.2; margin-top: 4px; }
.photo-empty-sub { font-size: 9.5px; color: #94a3b8; letter-spacing: 0.3px; }
.photo-preview { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-overlay {
    position: absolute; inset: 0;
    background: rgba(15,23,42,0.68); color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; opacity: 0; transition: opacity 0.2s ease;
    font-size: 11px; font-weight: 600; pointer-events: none;
}
.photo-preview:hover .photo-overlay,
.photo-dropzone:focus-visible .photo-overlay { opacity: 1; }
.photo-hint { font-size: 11px; color: #94a3b8; margin: 0; text-align: center; line-height: 1.3; }
.photo-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.photo-actions .btn { min-width: 84px; }

.photo-size-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: #475569;
}
.photo-size-row .badge { background: #0d9488 !important; font-size: 10px; padding: 3px 8px; }

.margins-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.margins-grid input { text-align: center; font-size: 11.5px; padding: 3px 2px; }
.margins-grid input::placeholder { font-size: 10px; color: #94a3b8; }
.margins-hint {
    font-size: 10px; color: #94a3b8;
    text-align: center; letter-spacing: 0.3px;
    margin-top: 4px;
}
#margins_card hr { border: none; border-top: 1px dashed #e2e8f0; }

.language-input-row {
    display: grid;
    grid-template-columns: 1fr 90px 52px;
    gap: 4px; align-items: stretch;
}

@media print {
    html, body {
        background: #fff !important;
        margin: 0 !important; padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body > *:not(#cv-builder-app) { display: none !important; }
    header, footer, nav, aside, .navbar, .navbar-custom, .footer-custom { display: none !important; }
    [class*="footer"], [class*="site-footer"], [class*="page-footer"], [class*="main-footer"],
    [class*="navbar"], [class*="site-header"], [class*="page-header"]:not(.cv-builder-header) { display: none !important; }
    .cv-builder-header, .cv-control-panel, .cv-toast, #cv_overflow_warning, #cv_save_status, .cv-empty-state,
    .drag-handle, .drag-handle-exp, .drag-handle-edu { display: none !important; }
    .page-gap-overlay,
    .page-margin-guide,
    .page-break-marker { display: none !important; }
    .page-num-badge {
        display: block !important;
        position: absolute !important;
        opacity: 1 !important;
    }
    .cv-builder-container { display: block !important; background: #fff !important; min-height: 0 !important; gap: 0 !important; }
    .cv-preview-panel {
        display: block !important; padding: 0 !important; margin: 0 !important;
        height: auto !important; max-height: none !important; overflow: visible !important;
        background: #fff !important; width: auto !important;
        justify-content: flex-start !important; align-items: flex-start !important;
    }
    .a4-container {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        background-size: 100% 100% !important;
        background-repeat: no-repeat !important;
        display: block !important;
        overflow: visible !important;
    }
    .cv-section-block, .exp-item, .edu-item {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}

@media (max-width: 1024px) {
    .cv-builder-container { flex-direction: column; }
    .cv-control-panel {
        width: 100%; min-width: unset; max-width: unset;
        height: auto; position: static;
        border-right: none; border-bottom: 1px solid #e2e8f0;
    }
    .cv-preview-panel { height: auto; padding: 16px; max-height: 80vh; overflow-y: auto; }
    .a4-container { width: 100%; min-height: auto; max-height: none; }
    .drag-handle, .drag-handle-exp, .drag-handle-edu { padding: 6px 10px !important; font-size: 13px !important; }
}
@media (max-width: 576px) {
    .cv-toast { right: 12px; left: 12px; max-width: none; }
    .theme-preset { font-size: 0.68rem; padding: 2px 8px; }
    .language-input-row { grid-template-columns: 1fr 80px 44px; }
}