/* ============================================
   CV EDITOR PRO — Main Styles
   Modern, Clean, Professional Design System
   ============================================ */

:root {
    /* Color System */
    --accent: #2563eb;
    --accent-light: #3b82f6;
    --accent-dark: #1d4ed8;
    --accent-bg: #eff6ff;
    
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-inverse: #ffffff;
    
    --border: #e2e8f0;
    --border-focus: var(--accent);
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Playfair Display', Georgia, serif;
    
    --header-h: 64px;
    --sidebar-w: 440px;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

/* ============ HEADER / NAVBAR ============ */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    color: var(--text-primary);
    -webkit-user-select: none;
    user-select: none;
}

.logo-img {
    height: 28px;
    width: auto;
    object-fit: contain;
}

.logo i {
    color: var(--accent);
    font-size: 1.4rem;
}

.logo strong {
    color: var(--accent);
}

/* ============ APP FOOTER ============ */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
    z-index: 100;
    -webkit-user-select: none;
    user-select: none;
}

/* Save indicator */
.save-indicator {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(-50px);
    background: #16a34a;
    color: #fff;
    font-size: 0.8rem;
    padding: 5px 14px;
    border-radius: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 200;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.save-indicator.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.header-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.5);
}

.nav-btn.active {
    background: var(--bg-secondary);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-switcher {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-sm);
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.lang-btn:hover {
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--bg-secondary);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.flag {
    font-size: 1rem;
}

.btn-template {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-template:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-export {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border: none;
    background: var(--accent);
    color: var(--text-inverse);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-export:hover {
    background: var(--accent-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* ============ TEMPLATE PANEL ============ */
.template-panel {
    position: fixed;
    top: var(--header-h);
    right: -400px;
    width: 380px;
    height: calc(100vh - var(--header-h) - 32px);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    z-index: 90;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding: 24px;
}

.template-panel.open {
    right: 0;
}

.template-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.template-panel-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.close-panel {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-panel:hover {
    background: #fee2e2;
    color: #dc2626;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.template-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.template-card:hover {
    border-color: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-card.active {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.template-preview {
    width: 100%;
    height: 120px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    position: relative;
    overflow: hidden;
}

/* Mini template preview illustrations */
.tpl-modern::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 35%;
    height: 100%;
    background: var(--accent);
    opacity: 0.15;
}
.tpl-modern::after {
    content: '';
    position: absolute;
    top: 12px; left: 10px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.3;
}

.tpl-elegant::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 30px;
    background: linear-gradient(135deg, #1e293b, #334155);
}

.tpl-minimal::before {
    content: '';
    position: absolute;
    top: 15px; left: 15px; right: 15px;
    height: 2px;
    background: var(--text-primary);
}

.tpl-executive::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: #b45309;
}

.tpl-gradient::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 35%; height: 100%;
    background: linear-gradient(160deg, var(--accent), #7c3aed, #ec4899);
    opacity: 0.25;
}
.tpl-gradient::after {
    content: '';
    position: absolute;
    top: 14px; left: 10px;
    width: 22px; height: 22px;
    border-radius: 6px;
    background: white;
    opacity: 0.4;
    border: 2px solid rgba(124,58,237,0.3);
}

.tpl-bold::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 40%;
    background: var(--accent);
    opacity: 0.2;
}
.tpl-bold::after {
    content: '';
    position: absolute;
    top: 10px; right: 10px;
    width: 30px; height: 30px;
    background: var(--accent);
    opacity: 0.15;
    transform: rotate(45deg);
}

.tpl-infographic::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 28px;
    background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
}
.tpl-infographic::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #ec4899, #f59e0b, #10b981);
}

.tpl-metro::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 28%; height: 100%;
    background: var(--accent);
    opacity: 0.15;
}
.tpl-metro::after {
    content: '';
    position: absolute;
    top: 45px; left: 36%; right: 8px;
    height: 18px;
    background: var(--accent);
    opacity: 0.12;
    border-radius: 3px;
}

.template-card span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.color-picker-section {
    margin-top: 8px;
}

.color-picker-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.color-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.color-dot:hover {
    transform: scale(1.15);
}

.color-dot.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-secondary);
}

.color-blue { background: #2563eb; }
.color-green { background: #059669; }
.color-red { background: #dc2626; }
.color-purple { background: #7c3aed; }
.color-orange { background: #ea580c; }
.color-teal { background: #0891b2; }
.color-pink { background: #be185d; }
.color-dark { background: #1e293b; }

.photo-hidden { display: none; }

/* ============ IMPORT OVERLAY ============ */
.import-overlay {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 32px;
    background: rgba(15, 23, 42, 0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 80;
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding: 24px 16px;
}

.import-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.import-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: 48px;
    max-width: 520px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.4s ease;
    margin: auto 0;
    flex-shrink: 0;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.import-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: var(--accent-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.import-icon i {
    font-size: 2rem;
    color: var(--accent);
}

.import-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.import-card > p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 32px;
    line-height: 1.5;
}

.import-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    cursor: pointer;
}

.import-dropzone:hover,
.import-dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.import-dropzone i {
    font-size: 2.5rem;
    color: var(--text-tertiary);
}

.import-dropzone span {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.btn-browse {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-browse:hover {
    background: var(--accent);
    color: var(--text-inverse);
}

.import-divider {
    position: relative;
    margin: 28px 0;
    text-align: center;
}

.import-divider::before {
    content: '';
    position: absolute;
    top: 50%; left: 0; right: 0;
    height: 1px;
    background: var(--border);
}

.import-divider span {
    position: relative;
    background: var(--bg-secondary);
    padding: 0 16px;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
}

.btn-start-fresh {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-start-fresh:hover {
    background: var(--accent);
    color: var(--text-inverse);
}

/* Continue editing draft */
.continue-draft-section {
    display: none;
    width: 100%;
    margin-bottom: 4px;
}

.btn-continue-draft {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 2px solid var(--accent);
    background: var(--accent-bg);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: var(--font-sans);
}

.btn-continue-draft:hover {
    background: var(--accent);
    color: var(--text-inverse);
}

.btn-continue-draft:hover .continue-draft-name,
.btn-continue-draft:hover .continue-draft-label,
.btn-continue-draft:hover .continue-draft-arrow {
    color: var(--text-inverse);
}

.btn-continue-draft > i:first-child {
    font-size: 1.3rem;
    color: var(--accent);
    flex-shrink: 0;
}

.btn-continue-draft:hover > i:first-child {
    color: var(--text-inverse);
}

.continue-draft-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.continue-draft-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.continue-draft-label {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
}

.continue-draft-arrow {
    color: var(--accent);
    font-size: 1rem;
    flex-shrink: 0;
}

/* Recent files */
.recent-files-section {
    width: 100%;
    text-align: left;
    display: none;
}

.recent-files-list {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recent-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.recent-file-item:hover {
    background: var(--bg-tertiary);
}

.recent-file-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.recent-file-icon i {
    color: var(--accent);
    font-size: 0.95rem;
}

.recent-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-file-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-file-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.recent-file-delete {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    flex-shrink: 0;
}

.recent-file-item:hover .recent-file-delete {
    opacity: 1;
}

.recent-file-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* New CV button in header */
.btn-new-cv {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-new-cv:hover {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

/* ============ MAIN LAYOUT ============ */
.app-main {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 32px;
}

.view-container {
    display: none;
    height: 100%;
}

.view-container.active {
    display: block;
}

/* ============ EDITOR LAYOUT ============ */
.editor-layout {
    display: flex;
    height: 100%;
}

.editor-sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ============ CONTENT LANGUAGE BADGE ============ */
.content-lang-badge {
    background: var(--accent-bg, rgba(37,99,235,0.06));
    border: 1px solid var(--accent, #2563eb);
    color: var(--accent, #2563eb);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ============ EDITOR SECTIONS ============ */
.editor-section {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition-slow);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: var(--transition);
    -webkit-user-select: none;
    user-select: none;
}

.section-header:hover {
    background: var(--bg-tertiary);
}

.section-header i:first-child {
    color: var(--accent);
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.section-header h3 {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
}

.section-toggle {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.editor-section.open .section-toggle {
    transform: rotate(180deg);
}

.section-body {
    display: none;
    padding: 0 16px 16px;
}

.editor-section.open .section-body {
    display: block;
    animation: expandSection 0.3s ease;
}

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

/* ============ FORM ELEMENTS ============ */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

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

.form-row {
    display: flex;
    gap: 12px;
}

.form-row.two-col .form-group {
    flex: 1;
}

.char-counter {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Photo Upload */
.photo-upload {
    width: 100px;
    height: 100px;
    border: 2px dashed var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: var(--transition);
    margin: 0 auto;
}

.photo-upload:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.photo-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-upload i {
    font-size: 1.5rem;
    color: var(--text-tertiary);
}

/* Tags Input */
.tags-input {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 44px;
    transition: var(--transition);
    cursor: text;
}

.tags-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    animation: tagIn 0.2s ease;
}

@keyframes tagIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.tag .remove-tag {
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0.6;
    transition: var(--transition);
}

.tag .remove-tag:hover {
    opacity: 1;
    color: #dc2626;
}

.tags-input input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 100px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 4px;
}

.tag-input-row {
    display: flex;
    width: 100%;
    gap: 6px;
    align-items: center;
}

.tag-input-row input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 80px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    padding: 4px;
}

.btn-add-tag {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    font-size: 0.75rem;
}

.btn-add-tag:hover {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

/* Repeater Items */
.repeater-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.repeater-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    position: relative;
    background: var(--bg-primary);
    transition: var(--transition);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.repeater-item:hover {
    border-color: var(--accent-light);
}

.repeater-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.repeater-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
}

.repeater-actions {
    display: flex;
    gap: 4px;
}

.btn-repeater-action {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-repeater-action:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-repeater-action.delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 12px;
}

.btn-add:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-bg);
}

/* ============ EDITOR PREVIEW ============ */
.editor-preview {
    flex: 1;
    background: var(--bg-tertiary);
    display: flex;
    flex-direction: column;
    overflow: visible;
    min-width: 0;
}

.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-controls button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.zoom-controls button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.zoom-controls span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: center;
}

.preview-lang-indicator {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-bg);
    padding: 4px 12px;
    border-radius: 20px;
}

/* ---- View mode toggle (single / paged) ---- */
.view-mode-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.view-mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.view-mode-btn i {
    font-size: 0.72rem;
}

.view-mode-btn.active {
    background: var(--bg-secondary);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.view-mode-btn:not(.active):hover {
    color: var(--text-primary);
}

/* ---- Scroll container ---- */
.preview-scroll {
    flex: 1;
    overflow: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* ---- Modo hoja única ---- */
.canvas-single {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-width: min-content;
}

/* ---- Modo paginado ---- */
.canvas-paged {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
}

/* Cada página A4 en modo paginado */
.cv-page-slice {
    width: 210mm;
    height: 297mm;
    background: white;
    box-shadow: var(--shadow-xl);
    border-radius: 0;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    /* clip interno para mostrar solo el "trozo" de esa página */
}

/* Etiqueta de número de página */
.page-label {
    width: 210mm;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    padding: 6px 0 6px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Separador entre páginas */
.page-divider {
    width: 210mm;
    height: 1px;
    background: var(--border);
    margin: 0;
}

.preview-scroll::-webkit-scrollbar {
    width: 8px;
}

.preview-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.preview-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* CV Page (A4) */
.cv-page {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: var(--shadow-xl);
    border-radius: 4px;
    overflow: visible;
    transform-origin: top center;
    flex-shrink: 0;
    position: relative;
    align-self: flex-start;
}

/* ============ COVER LETTER LAYOUT ============ */
.cover-letter-layout {
    display: flex;
    height: 100%;
}

.cl-sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.cl-sidebar .sidebar-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
}

.btn-generate-cl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: var(--text-inverse);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 16px;
}

.btn-generate-cl:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.btn-export-cl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-export-cl:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.cl-preview {
    flex: 1;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.cl-preview .preview-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    justify-content: center;
}

.cl-page {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: var(--shadow-xl);
    border-radius: 4px;
    padding: 50px 60px;
    font-family: var(--font-sans);
    flex-shrink: 0;
}

/* ============ FULL PREVIEW ============ */
.full-preview-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.full-preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.preview-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-sm);
}

.preview-tab {
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.preview-tab.active {
    background: var(--bg-secondary);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.btn-export-both {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: var(--text-inverse);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-export-both:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.full-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.preview-dual {
    display: flex;
    gap: 40px;
    justify-content: center;
}

.preview-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preview-column h4 {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.preview-column-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.btn-export-single {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export-single:hover {
    background: var(--accent);
    color: white;
}

.preview-column .cv-page {
    transform: scale(0.7);
    transform-origin: top center;
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--text-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 400px;
}

.toast.success { border-left: 4px solid #22c55e; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

/* ============ LOADING OVERLAY ============ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.loading-overlay.active {
    display: flex;
}

.loader {
    text-align: center;
    color: var(--text-inverse);
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

.loader p {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
    :root {
        --sidebar-w: 380px;
    }
}

@media (max-width: 992px) {
    .editor-layout {
        flex-direction: column;
    }
    .editor-sidebar,
    .cl-sidebar {
        width: 100%;
        min-width: unset;
        max-height: 50vh;
    }
    .cl-sidebar .sidebar-scroll {
        max-height: 50vh;
    }
    .preview-dual {
        flex-direction: column;
        align-items: center;
    }
    .preview-column .cv-page {
        transform: scale(0.5);
    }
    .header-nav span,
    .btn-template span,
    .btn-export span {
        display: none;
    }
    .template-panel {
        width: 320px;
    }
}

@media (max-width: 768px) {
    :root {
        --header-h: 56px;
        --sidebar-w: 100%;
    }

    body {
        overflow: auto;
        height: auto;
    }

    /* Header */
    .app-header {
        padding: 0 12px;
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-h);
        gap: 6px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .header-left {
        gap: 8px;
    }

    .logo span {
        display: none;
    }

    .logo-img {
        height: 24px;
    }

    .header-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .nav-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .nav-btn span {
        display: none;
    }

    .header-right {
        gap: 6px;
    }

    .lang-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
    }

    .btn-template span,
    .btn-export span {
        display: none;
    }

    .btn-template,
    .btn-export {
        padding: 8px 12px;
    }

    /* Main area */
    .app-main {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        min-height: calc(100vh - var(--header-h) - 32px);
    }

    .view-container.active {
        display: flex;
        flex-direction: column;
    }

    /* Editor layout */
    .editor-layout {
        flex-direction: column;
        height: auto;
    }

    .editor-sidebar {
        width: 100%;
        min-width: unset;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .cl-sidebar {
        width: 100%;
        min-width: unset;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .cl-sidebar .sidebar-scroll {
        height: auto;
        max-height: none;
        overflow-y: visible;
    }

    .sidebar-scroll {
        height: auto;
        max-height: none;
        overflow-y: visible;
    }

    .editor-preview {
        width: 100%;
        min-height: 60vh;
    }

    /* Import overlay */
    .import-overlay {
        position: fixed;
        top: 0;
        bottom: 0;
        padding: 16px;
    }

    .import-card {
        padding: 28px 20px;
        width: 100%;
        max-width: 440px;
    }

    .import-card h2 {
        font-size: 1.25rem;
    }

    .import-card > p {
        font-size: 0.85rem;
        margin-bottom: 20px;
    }

    .import-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 16px;
    }

    .import-icon i {
        font-size: 1.5rem;
    }

    .import-dropzone {
        padding: 24px 16px;
    }

    .import-divider {
        margin: 18px 0;
    }

    .recent-files-list {
        max-height: 160px;
    }

    /* Template panel */
    .template-panel {
        width: 100%;
        right: -100%;
    }

    .template-panel.open {
        right: 0;
    }

    /* Preview dual */
    .preview-dual {
        flex-direction: column;
        align-items: center;
        gap: 24px;
    }

    .preview-column .cv-page {
        transform: scale(0.45);
    }

    /* Toast */
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 40px;
    }

    .toast {
        max-width: 100%;
    }

    /* Footer */
    .app-footer {
        position: relative;
    }
}

@media (max-width: 480px) {
    .import-card {
        padding: 20px 16px;
        border-radius: var(--radius-lg);
    }

    .import-card h2 {
        font-size: 1.1rem;
    }

    .import-dropzone {
        padding: 18px 12px;
    }

    .import-dropzone i {
        font-size: 1.8rem;
    }

    .btn-start-fresh {
        width: 100%;
        justify-content: center;
    }

    .nav-btn {
        padding: 6px 10px;
    }

    .lang-switcher {
        display: none;
    }

    .preview-column .cv-page {
        transform: scale(0.35);
    }

    .sidebar-scroll {
        padding: 12px;
    }

    .section-header {
        padding: 10px;
    }

    .section-body {
        padding: 10px;
    }
}
