/* ══════════════════════════════════════════
   CV Builder – Styles
   ══════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+Arabic:wght@400;600;700&display=swap');

:root {
    --cv-primary: #6c5ce7;
    --cv-primary-light: #a29bfe;
    --cv-accent: #00cec9;
    --cv-accent2: #fd79a8;
    --cv-bg: #0f0f23;
    --cv-card: #1a1a2e;
    --cv-card-hover: #222240;
    --cv-border: rgba(108, 92, 231, 0.15);
    --cv-text: #e2e8f0;
    --cv-text-muted: #94a3b8;
    --cv-success: #00b894;
    --cv-danger: #e17055;
    --cv-radius: 12px;
    --cv-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --cv-glow: 0 0 20px rgba(108, 92, 231, 0.15);
}

.light-theme {
    --cv-bg: #f1f5f9;
    --cv-card: #ffffff;
    --cv-card-hover: #f8fafc;
    --cv-border: rgba(108, 92, 231, 0.12);
    --cv-text: #1e293b;
    --cv-text-muted: #64748b;
    --cv-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --cv-glow: 0 0 20px rgba(108, 92, 231, 0.08);
}

/* ── Layout ── */
.cv-app { font-family: 'Inter', sans-serif; }

.cv-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--cv-card);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    box-shadow: var(--cv-shadow);
}

.cv-top-bar .cv-lang-select,
.cv-top-bar .cv-template-select {
    padding: 8px 14px;
    background: var(--cv-bg);
    color: var(--cv-text);
    border: 1px solid var(--cv-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 160px;
}
.cv-top-bar .cv-lang-select:focus,
.cv-top-bar .cv-template-select:focus {
    border-color: var(--cv-primary);
    outline: none;
}

.cv-top-bar .cv-bar-spacer { flex: 1; }

.cv-top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cv-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}
.cv-btn-primary {
    background: linear-gradient(135deg, var(--cv-primary), var(--cv-primary-light));
    color: #fff;
    box-shadow: 0 2px 12px rgba(108, 92, 231, 0.3);
}
.cv-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(108, 92, 231, 0.45); }

.cv-btn-accent {
    background: linear-gradient(135deg, var(--cv-accent), #00b894);
    color: #fff;
}
.cv-btn-accent:hover { transform: translateY(-1px); }

.cv-btn-outline {
    background: transparent;
    color: var(--cv-text-muted);
    border: 1px solid var(--cv-border);
}
.cv-btn-outline:hover { border-color: var(--cv-primary); color: var(--cv-primary); }

.cv-btn-danger {
    background: transparent;
    color: var(--cv-danger);
    border: 1px solid rgba(225, 112, 85, 0.3);
}
.cv-btn-danger:hover { background: rgba(225, 112, 85, 0.1); }

.cv-btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Two-Column Layout ── */
.cv-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1200px) {
    .cv-main-grid { grid-template-columns: 1fr; }
}

/* ── Editor Panel ── */
.cv-editor {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cv-section-card {
    background: var(--cv-card);
    border: 1px solid var(--cv-border);
    border-radius: var(--cv-radius);
    overflow: hidden;
    box-shadow: var(--cv-shadow);
    transition: border-color 0.3s;
}
.cv-section-card:hover { border-color: rgba(108, 92, 231, 0.3); }

.cv-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.cv-section-header:hover { background: var(--cv-card-hover); }

.cv-section-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cv-section-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 14px;
    color: #fff;
}
.cv-section-icon.personal { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.cv-section-icon.summary  { background: linear-gradient(135deg, #00cec9, #00b894); }
.cv-section-icon.exp      { background: linear-gradient(135deg, #e17055, #fdcb6e); }
.cv-section-icon.edu      { background: linear-gradient(135deg, #0984e3, #74b9ff); }
.cv-section-icon.skills   { background: linear-gradient(135deg, #fd79a8, #e84393); }
.cv-section-icon.langs    { background: linear-gradient(135deg, #00b894, #55efc4); }
.cv-section-icon.projects { background: linear-gradient(135deg, #fdcb6e, #f39c12); }
.cv-section-icon.certs    { background: linear-gradient(135deg, #636e72, #b2bec3); }

.cv-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--cv-text);
}

.cv-section-toggle {
    color: var(--cv-text-muted);
    font-size: 12px;
    transition: transform 0.3s;
}
.cv-section-card.open .cv-section-toggle { transform: rotate(180deg); }

.cv-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
}
.cv-section-card.open .cv-section-body {
    max-height: 2000px;
    padding: 0 18px 18px;
}

/* ── Form Elements ── */
.cv-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.cv-form-grid .cv-form-full { grid-column: 1 / -1; }

.cv-form-group { display: flex; flex-direction: column; gap: 4px; }

.cv-form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--cv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cv-form-group input,
.cv-form-group textarea,
.cv-form-group select {
    padding: 9px 12px;
    background: var(--cv-bg);
    color: var(--cv-text);
    border: 1px solid var(--cv-border);
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.cv-form-group input:focus,
.cv-form-group textarea:focus {
    border-color: var(--cv-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
    outline: none;
}
.cv-form-group textarea { resize: vertical; min-height: 70px; }

/* ── Repeatable Items ── */
.cv-item-list { display: flex; flex-direction: column; gap: 12px; }

.cv-item-entry {
    background: var(--cv-bg);
    border: 1px solid var(--cv-border);
    border-radius: 10px;
    padding: 14px;
    position: relative;
    transition: border-color 0.2s;
}
.cv-item-entry:hover { border-color: rgba(108, 92, 231, 0.25); }

.cv-item-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(225, 112, 85, 0.1);
    color: var(--cv-danger);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
[dir="rtl"] .cv-item-remove { right: auto; left: 8px; }
.cv-item-remove:hover { background: rgba(225, 112, 85, 0.25); }

.cv-add-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border: 2px dashed var(--cv-border);
    border-radius: 10px;
    background: transparent;
    color: var(--cv-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    font-family: 'Inter', sans-serif;
}
.cv-add-item:hover {
    border-color: var(--cv-primary);
    background: rgba(108, 92, 231, 0.05);
}

/* ── Skills Tags ── */
.cv-skills-input-wrap {
    display: flex;
    gap: 8px;
}
.cv-skills-input-wrap input { flex: 1; }
.cv-skills-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.cv-skill-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: rgba(108, 92, 231, 0.12);
    color: var(--cv-primary-light);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    animation: cvTagIn 0.2s ease;
}
@keyframes cvTagIn { from { transform: scale(0.8); opacity: 0; } }
.cv-skill-tag button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    opacity: 0.6;
}
.cv-skill-tag button:hover { opacity: 1; }

/* ── Photo Upload ── */
.cv-photo-upload {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}
.cv-photo-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--cv-bg);
    border: 2px dashed var(--cv-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s;
    flex-shrink: 0;
}
.cv-photo-preview:hover { border-color: var(--cv-primary); }
.cv-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.cv-photo-preview .cv-photo-placeholder { color: var(--cv-text-muted); font-size: 22px; }

/* ══════════════════════════════════════════
   PREVIEW PANEL
   ══════════════════════════════════════════ */
.cv-preview-wrap {
    position: sticky;
    top: 80px;
}

.cv-preview-container {
    background: #fff;
    border-radius: var(--cv-radius);
    box-shadow: var(--cv-shadow);
    overflow: hidden;
    min-height: 600px;
    color: #1e293b;
    font-size: 13px;
    line-height: 1.6;
}

/* ── Template: Modern ── */
.cv-tpl-modern .cv-preview-header {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
    padding: 30px 28px;
    display: flex;
    align-items: center;
    gap: 20px;
}
.cv-tpl-modern .cv-preview-photo {
    width: 80px; height: 80px; border-radius: 50%;
    object-fit: cover; border: 3px solid rgba(255,255,255,0.3);
}
.cv-tpl-modern .cv-preview-name { font-size: 22px; font-weight: 700; margin: 0; }
.cv-tpl-modern .cv-preview-jobtitle { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.cv-tpl-modern .cv-preview-contacts {
    display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 11px; opacity: 0.9;
}
.cv-tpl-modern .cv-preview-contacts span { display: flex; align-items: center; gap: 4px; }

.cv-tpl-modern .cv-preview-body { padding: 24px 28px; }
.cv-tpl-modern .cv-preview-section { margin-bottom: 20px; }
.cv-tpl-modern .cv-preview-section-title {
    font-size: 13px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1px; color: #6c5ce7; border-bottom: 2px solid #6c5ce7;
    padding-bottom: 4px; margin-bottom: 12px;
}

/* ── Template: Classic ── */
.cv-tpl-classic .cv-preview-header {
    text-align: center;
    padding: 28px;
    border-bottom: 2px solid #1e293b;
}
.cv-tpl-classic .cv-preview-photo {
    width: 70px; height: 70px; border-radius: 50%;
    object-fit: cover; margin: 0 auto 10px; display: block; border: 2px solid #ddd;
}
.cv-tpl-classic .cv-preview-name { font-size: 24px; font-weight: 700; color: #1e293b; margin: 0; }
.cv-tpl-classic .cv-preview-jobtitle { color: #64748b; font-size: 14px; }
.cv-tpl-classic .cv-preview-contacts {
    display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 10px; font-size: 11px; color: #64748b;
}
.cv-tpl-classic .cv-preview-contacts span { display: flex; align-items: center; gap: 4px; }

.cv-tpl-classic .cv-preview-body { padding: 24px 28px; }
.cv-tpl-classic .cv-preview-section { margin-bottom: 18px; }
.cv-tpl-classic .cv-preview-section-title {
    font-size: 14px; font-weight: 700; text-transform: uppercase;
    color: #1e293b; border-bottom: 1px solid #cbd5e1;
    padding-bottom: 4px; margin-bottom: 10px;
}

/* ── Template: Minimal ── */
.cv-tpl-minimal .cv-preview-header {
    padding: 28px; display: flex; align-items: center; gap: 18px;
    border-bottom: 1px solid #e2e8f0;
}
.cv-tpl-minimal .cv-preview-photo {
    width: 60px; height: 60px; border-radius: 8px; object-fit: cover;
}
.cv-tpl-minimal .cv-preview-name { font-size: 20px; font-weight: 600; color: #1e293b; margin: 0; }
.cv-tpl-minimal .cv-preview-jobtitle { color: #94a3b8; font-size: 13px; }
.cv-tpl-minimal .cv-preview-contacts {
    display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 11px; color: #94a3b8;
}
.cv-tpl-minimal .cv-preview-contacts span { display: flex; align-items: center; gap: 4px; }

.cv-tpl-minimal .cv-preview-body { padding: 22px 28px; }
.cv-tpl-minimal .cv-preview-section { margin-bottom: 18px; }
.cv-tpl-minimal .cv-preview-section-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 2px; color: #94a3b8; margin-bottom: 8px;
}

/* ── Common Preview Items ── */
.cv-preview-item { margin-bottom: 12px; }
.cv-preview-item-title { font-weight: 600; font-size: 13px; color: #1e293b; }
.cv-preview-item-sub { font-size: 12px; color: #64748b; }
.cv-preview-item-date { font-size: 11px; color: #94a3b8; }
.cv-preview-item-desc { font-size: 12px; color: #475569; margin-top: 4px; white-space: pre-line; }

.cv-preview-skills-list {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.cv-preview-skill-tag {
    padding: 3px 10px; background: #f1f5f9; border-radius: 4px;
    font-size: 11px; color: #475569; font-weight: 500;
}
.cv-tpl-modern .cv-preview-skill-tag {
    background: rgba(108, 92, 231, 0.1); color: #6c5ce7;
}

.cv-preview-summary { font-size: 12px; color: #475569; line-height: 1.7; white-space: pre-line; }

.cv-preview-lang-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; font-size: 12px;
}
.cv-preview-lang-level {
    font-size: 11px; color: #94a3b8; font-weight: 500;
}

/* ── Empty State ── */
.cv-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #94a3b8;
    text-align: center;
    padding: 40px;
}
.cv-preview-empty i { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.cv-preview-empty p { font-size: 14px; }

/* ── RTL Support ── */
[dir="rtl"] .cv-app { font-family: 'Noto Sans Arabic', 'Inter', sans-serif; }
[dir="rtl"] .cv-form-group label { text-align: right; }
[dir="rtl"] .cv-section-header { flex-direction: row-reverse; }
[dir="rtl"] .cv-section-header-left { flex-direction: row-reverse; }
[dir="rtl"] .cv-preview-header { direction: rtl; }
[dir="rtl"] .cv-preview-body { direction: rtl; text-align: right; }
[dir="rtl"] .cv-preview-contacts { direction: rtl; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .cv-form-grid { grid-template-columns: 1fr; }
    .cv-top-bar { flex-direction: column; align-items: stretch; }
    .cv-top-actions { justify-content: center; }
    .cv-preview-wrap { position: static; }
}

/* ── Print ── */
@media print {
    /* Hide the entire page layout */
    body > *:not(#cv-print-root) { display: none !important; }

    #cv-print-root {
        display: block !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        height: auto !important;
        background: #fff !important;
    }

    #cv-print-root .cv-preview-container {
        position: static !important;
        width: 100% !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    .cv-preview-section { break-inside: avoid; }
    .cv-preview-item    { break-inside: avoid; }

    @page { margin: 10mm; size: A4; }
}
