/* =========================================
   ICON STYLES
   ========================================= */
.icon-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    color: currentColor;
}

.icon-svg svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================
   DESIGN TOKENS & VARIABLES
   ========================================= */
:root {
    /* Color Palette - Dark Premium */
    --bg-dark: #09090b; /* Very dark zinc */
    --bg-panel: rgba(24, 24, 27, 0.7); /* Translucent zinc-900 */
    --bg-input: #27272a;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-focus: #0EA5E9;
    
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    
    /* Primary Accents */
    --accent-linear: linear-gradient(135deg, #2563EB, #0EA5E9, #06B6D4);
    --accent-solid: #0EA5E9;
    --accent-glow: rgba(14, 165, 233, 0.4);

    /* Document/Paper styling */
    --paper-bg: #ffffff;
    --paper-text: #18181b;
    --paper-muted: #52525b;
    --paper-accent: #27272a;
    --paper-primary: #000000;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: 'Playfair Display', serif;
    
    /* Shadows & Effects */
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-paper: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   RESET & BASE STYLES
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden; /* App layout takes over */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(37, 99, 235, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(6, 182, 212, 0.12), transparent 25%);
}

/* =========================================
   APP LAYOUT
   ========================================= */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* LEFT PANE - EDITOR */
.editor-pane {
    width: 480px;
    min-width: 480px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
}

.editor-header {
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.35rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: var(--accent-linear);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.logo i {
    color: var(--accent-solid);
    -webkit-text-fill-color: initial;
    font-size: 1.2rem;
}

/* Unprefixed version for Firefox */
.logo {
    background-clip: text;
}

.logo-tld {
    opacity: 0.7;
}

/* Language Toggle */
.lang-toggle {
    display: flex;
    gap: 0.25rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.2rem;
    flex-shrink: 0;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lang-btn.active {
    background: var(--accent-solid);
    color: white;
}

.lang-btn:not(.active):hover {
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0;
}

.controls-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) transparent;
}

.controls-container::-webkit-scrollbar {
    width: 6px;
}
.controls-container::-webkit-scrollbar-thumb {
    background-color: var(--border-subtle);
    border-radius: 10px;
}

.editor-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-subtle);
    background: rgba(24, 24, 27, 0.9);
}

/* RIGHT PANE - PREVIEW */
.preview-pane {
    flex: 1;
    background-color: #000000;
    background-image: radial-gradient(var(--border-subtle) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow-y: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem;
}

/* =========================================
   FORM COMPONENTS
   ========================================= */
.group-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition-fast);
}

.group-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

.group-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.group-card h2 i {
    color: var(--accent-solid);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    margin-bottom: 0;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-fast);
    outline: none;
}

input::placeholder, textarea::placeholder {
    color: #52525b;
}

input:focus, textarea:focus {
    background: #18181b;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* BUTTONS */
.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--accent-linear);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-fast);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--accent-solid);
    color: white;
    transform: scale(1.05);
}

.btn-remove {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* DYNAMIC ITEMS */
.dynamic-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dynamic-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed var(--border-subtle);
    padding: 1rem;
    border-radius: var(--radius-sm);
    position: relative;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.item-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.btn-item-move {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition-fast);
    padding: 0;
}

.btn-item-move:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}


/* =========================================
   A4 CV PREVIEW DOC
   ========================================= */
.preview-wrapper {
    /* Container to hold the paper and allow it to scale naturally or have padding */
    display: flex;
    justify-content: center;
    width: 100%;
}

.cv-document {
    background: var(--paper-bg);
    color: var(--paper-text);
    width: 210mm; /* A4 width */
    min-height: 297mm; /* A4 height */
    padding: 40mm 30mm;
    box-shadow: var(--shadow-paper);
    border-radius: 4px;
    position: relative;
    /* Transformation for responsive look if needed, currently set to fixed A4 */
}

/* CV Internal Styling */
.cv-header {
    margin-bottom: 2.5rem;
    border-bottom: 2px solid var(--paper-primary);
    padding-bottom: 1.5rem;
}

.cv-header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.cv-header-text {
    flex: 1;
    min-width: 0;
}

/* Photo in CV header */
.cv-header-photo {
    flex-shrink: 0;
}

.cv-header-photo img {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--paper-primary);
    display: block;
}

.cv-name {
    font-family: var(--font-serif);
    font-size: 3rem;
    line-height: 1.1;
    font-weight: 700;
    color: var(--paper-primary);
    margin-bottom: 0.25rem;
    letter-spacing: -0.03em;
}

.cv-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--paper-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.cv-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--paper-muted);
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.contact-item i {
    color: var(--paper-primary);
}

.cv-body {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
}

.cv-section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--paper-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cv-summary-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--paper-text);
}

.cv-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cv-item-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--paper-primary);
    margin-bottom: 0.2rem;
}

.cv-item-subtitle {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--paper-accent);
}

.cv-item-date {
    font-size: 0.85rem;
    color: var(--paper-muted);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.cv-item-desc {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--paper-text);
}

.skills-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.skill-chip {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 20px;
    color: var(--paper-primary);
}

/* SELECT INPUT */
select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-fast);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%23a1a1aa'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.5rem;
}

select:focus {
    background-color: #18181b;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

select option {
    background: #18181b;
    color: var(--text-main);
}

/* EXTRA FIELDS */
#extra-fields-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#extra-fields-container:not(:empty) {
    margin-top: 1rem;
}

.add-field-wrapper {
    position: relative;
    margin-top: 1rem;
}

.btn-add-field {
    width: 100%;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: var(--transition-fast);
}

.btn-add-field:hover {
    border-color: var(--accent-solid);
    color: var(--accent-solid);
}

.field-picker {
    display: none;
    position: fixed;
    background: #1c1c1f;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    z-index: 9999;
    flex-wrap: wrap;
    gap: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    width: 380px;
}

.field-picker.open {
    display: flex;
}

.picker-option {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition-fast);
}

.picker-option:hover {
    background: var(--accent-solid);
    border-color: var(--accent-solid);
    color: white;
}

.picker-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    width: 100%;
    padding: 0.25rem 0;
}

.extra-field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.extra-field-label-row label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0;
}

.btn-remove-field {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.15rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: var(--transition-fast);
    font-size: 0.75rem;
}

.btn-remove-field:hover {
    color: #ef4444;
}

/* =========================================
   PHOTO UPLOAD AREA (editor)
   ========================================= */
.photo-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    border: 2px dashed rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    user-select: none;
}

.photo-upload-area:hover,
.photo-upload-area:focus-visible {
    border-color: var(--accent-solid);
    background: rgba(14, 165, 233, 0.06);
    color: var(--accent-solid);
    outline: none;
}

.photo-upload-area.dragover {
    border-color: var(--accent-solid);
    background: rgba(14, 165, 233, 0.1);
}

.photo-upload-area .ph-camera {
    font-size: 1.75rem;
    opacity: 0.7;
}

.photo-upload-text {
    font-size: 0.8rem;
}

/* Uploaded state */
.photo-upload-area.has-photo {
    flex-direction: row;
    padding: 0.75rem 1rem;
    gap: 0.85rem;
    justify-content: flex-start;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.12);
}

.photo-thumb {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--accent-solid);
}

.photo-change-text {
    font-size: 0.8rem;
    color: var(--accent-solid);
}

/* =========================================
   LANGUAGE SKILLS (editor)
   ========================================= */
.lang-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.lang-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
}

.lang-item .lang-name {
    font-size: 0.9rem;
}

.lang-item .lang-level {
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-remove-lang {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    transition: color var(--transition-fast);
}

.btn-remove-lang:hover {
    color: #ef4444;
}

.btn-add-lang {
    width: 100%;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    padding: 0.4rem;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.btn-add-lang:hover {
    border-color: var(--accent-solid);
    color: var(--accent-solid);
}

/* =========================================
   LANGUAGE SKILLS (CV preview)
   ========================================= */
.cv-languages-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.cv-language-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.cv-language-name {
    font-size: 0.9rem;
    color: var(--paper-text);
    font-weight: 500;
}

.cv-language-level {
    font-size: 0.78rem;
    color: var(--paper-muted);
    white-space: nowrap;
}

/* Export warning */
.export-warning {
    font-size: 0.78rem;
    color: #ef4444;
    text-align: center;
    margin-bottom: 0.5rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* CV EXTRA INFO (sidebar) */
.cv-extra-info-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.cv-extra-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.cv-extra-info-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--paper-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cv-extra-info-value {
    font-size: 0.9rem;
    color: var(--paper-text);
}

/* HIDDEN STATES */
.hidden {
    display: none !important;
}


/* =========================================
   PRINT STYLES FOR PDF EXPORT
   ========================================= */
@media print {
    /* Hide elements that show placeholder text — user never typed this */
    [data-placeholder] {
        display: none !important;
    }

    @page {
        margin: 0;
        size: A4;
    }
    
    body {
        background: none;
        box-shadow: none;
    }
    
    /* Hide the editor pane entirely */
    .editor-pane {
        display: none !important;
    }
    
    /* Adjust preview pane to fill screen naturally */
    .preview-pane {
        padding: 0;
        background: none;
        overflow: visible;
        display: block;
    }
    
    .preview-wrapper {
        display: block;
    }
    
    /* Remove shadows and margins from the paper */
    .cv-document {
        box-shadow: none;
        width: 100%;
        min-height: 100%;
        padding: 20mm; /* Slightly smaller padding for print so it fits nicely depending on printer margins */
    }
    
    /* Ensure colors print correctly */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* =========================================
   RESPONSIVE DESIGN (FOR VERY SMALL SCREENS)
   ========================================= */
@media (max-width: 1024px) {
    .app-layout {
        flex-direction: column;
    }
    
    .editor-pane {
        width: 100%;
        min-width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }
    
    .preview-pane {
        padding: 1rem;
    }
    
    .cv-document {
        transform: scale(0.6);
        transform-origin: top center;
        margin-bottom: -100mm; /* Account for scale gap */
    }
}
