/* =========================================
   BASE STYLES & VARIABLES
   ========================================= */
:root {
    --theme-color: #2563eb; /* Default Blue */
    --bg: #f8fafc;
    --editor-bg: #ffffff;
    --border: #e2e8f0;
    --text: #334155;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', sans-serif; background: var(--bg); height: 100vh; overflow: hidden; }

/* --- APP LAYOUT --- */
.app-container { display: flex; height: 100%; }

/* --- EDITOR SIDE (Left) --- */
.editor {
    width: 400px;
    background: var(--editor-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 2px 0 15px rgba(0,0,0,0.05);
}

.editor-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #fff; }

.download-btn { background: var(--theme-color); color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; font-weight: bold; transition: 0.2s; font-size: 0.9rem; }
.download-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* Mobile Preview Button (Hidden on Desktop) */
.mobile-preview-btn { display: none; background: #334155; color: white; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; margin-left: 5px; }

.tabs { display: flex; border-bottom: 1px solid var(--border); background: #f8fafc; }
.tab-btn { flex: 1; padding: 15px; background: none; border: none; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; color: #64748b; }
.tab-btn.active { border-bottom-color: var(--theme-color); color: var(--theme-color); background: #ffffff; }

.tab-content { padding: 20px; overflow-y: auto; display: none; height: 100%; }
.tab-content.active { display: block; }

/* --- INPUTS --- */
input, textarea { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 5px; font-family: inherit; font-size: 0.9rem; transition: 0.2s; }
input:focus, textarea:focus { outline: none; border-color: var(--theme-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
textarea { height: 80px; resize: vertical; }

details { margin-bottom: 15px; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; background: white; }
summary { padding: 12px; background: #f8fafc; cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; }
summary:hover { background: #f1f5f9; }
summary::after { content: '+'; font-size: 1.2rem; }
details[open] summary::after { content: '-'; }
details[open] summary { border-bottom: 1px solid var(--border); }
details input, details textarea, details .file-upload { margin: 15px; width: calc(100% - 30px); }

.add-btn { width: 100%; padding: 12px; background: white; border: 1px dashed #94a3b8; color: #64748b; cursor: pointer; margin-top: 5px; border-radius: 5px; font-weight: 600; }
.add-btn:hover { border-color: var(--theme-color); color: var(--theme-color); background: #f8fafc; }

.item-group { background: #f8fafc; padding: 15px; margin: 15px; border-radius: 6px; border: 1px solid var(--border); position: relative; }
.remove-btn { position: absolute; top: 10px; right: 10px; color: #ef4444; cursor: pointer; background: white; border: 1px solid #e2e8f0; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.remove-btn:hover { background: #fee2e2; }

/* --- DESIGN TAB --- */
.layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 25px; }
.layout-btn { padding: 10px; border: 1px solid var(--border); background: white; cursor: pointer; border-radius: 5px; text-align: left; font-size: 0.9rem; transition: 0.2s; }
.layout-btn:hover { border-color: #cbd5e1; }
.layout-btn.active { border-color: var(--theme-color); background: #eff6ff; color: var(--theme-color); font-weight: bold; box-shadow: 0 0 0 1px var(--theme-color); }

.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.color-btn { height: 40px; border-radius: 5px; cursor: pointer; transition: transform 0.1s; border: 2px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.color-btn:hover { transform: scale(1.1); }

/* --- PREVIEW AREA (Right) --- */
.preview-area { flex: 1; background: #525659; padding: 40px; display: flex; justify-content: center; overflow-y: auto; }
.a4-page { width: 210mm; min-height: 297mm; background: white; box-shadow: 0 0 20px rgba(0,0,0,0.3); position: relative; display: flex; flex-direction: column; color: #333; overflow: hidden; }

/* =========================================
   20 LAYOUT STYLES
   ========================================= */

/* Common Elements */
.job-entry, .edu-entry { margin-bottom: 15px; page-break-inside: avoid; }
.entry-title { font-weight: bold; font-size: 1.05rem; color: #000; }
.entry-subtitle { color: #555; font-size: 0.9rem; margin-bottom: 2px; font-weight: 500; }
.entry-date { float: right; font-size: 0.85rem; color: #666; font-weight: normal; }
.entry-desc { font-size: 0.9rem; line-height: 1.4; color: #444; margin-top: 5px; white-space: pre-wrap; }
.skill-tag { display: inline-block; background: #f1f5f9; padding: 4px 8px; border-radius: 4px; margin: 2px; font-size: 0.85rem; color: #334155; border: 1px solid #e2e8f0; }

/* 1. CLASSIC */
.layout-classic { padding: 40px; }
.layout-classic .cv-header { border-bottom: 2px solid var(--theme-color); padding-bottom: 20px; margin-bottom: 20px; display: flex; align-items: center; gap: 20px; }
.layout-classic .photo-box img { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
.layout-classic h1 { color: var(--theme-color); margin: 0; text-transform: uppercase; font-size: 2.2rem; }
.layout-classic .section-title { color: var(--theme-color); font-weight: bold; text-transform: uppercase; border-bottom: 1px solid #ddd; margin: 20px 0 10px 0; padding-bottom: 5px; }

/* 2. MODERN (Sidebar) */
.layout-modern { flex-direction: row; }
.layout-modern .sidebar { width: 32%; background: #1e293b; color: white; padding: 30px 20px; text-align: center; }
.layout-modern .main { width: 68%; padding: 30px; }
.layout-modern .section-title { color: var(--theme-color); font-size: 1.2rem; font-weight: bold; border-bottom: 2px solid #e2e8f0; margin: 25px 0 15px 0; }

/* 3. BOLD HEADER */
.layout-bold .cv-header { background: var(--theme-color); color: white; padding: 40px; text-align: center; }
.layout-bold h1 { margin: 0; font-size: 3rem; }
.layout-bold .content { padding: 30px 50px; }
.layout-bold .section-title { display: inline-block; background: var(--theme-color); color: white; padding: 5px 15px; margin: 30px 0 15px 0; font-weight: bold; border-radius: 4px; }

/* 4. MINIMALIST */
.layout-minimal { padding: 50px; text-align: left; }
.layout-minimal h1 { font-weight: 300; font-size: 3rem; margin-bottom: 5px; color: #000; }
.layout-minimal .job-title { text-transform: uppercase; letter-spacing: 2px; font-size: 0.9rem; margin-bottom: 30px; color: #666; }
.layout-minimal .section-title { font-weight: 700; text-transform: uppercase; margin: 30px 0 15px 0; letter-spacing: 1px; border-bottom: 1px solid #000; padding-bottom: 5px; }

/* 5. COMPACT */
.layout-compact { padding: 25px; font-size: 0.9rem; }
.layout-compact h1 { font-size: 1.8rem; margin: 0; color: var(--theme-color); }
.layout-compact .cv-header { display: flex; justify-content: space-between; border-bottom: 2px solid #ccc; padding-bottom: 10px; margin-bottom: 15px; align-items: flex-end; }
.layout-compact .section-title { background: #eee; padding: 4px 8px; font-weight: bold; margin: 15px 0 8px 0; border-left: 4px solid var(--theme-color); }
.layout-compact .job-entry { margin-bottom: 10px; }

/* 6. BANNER */
.layout-banner .cv-header { background: var(--theme-color); height: 160px; display: flex; align-items: center; justify-content: center; flex-direction: column; color: white; text-align: center; }
.layout-banner .main { padding: 30px 40px; }
.layout-banner h1 { margin: 0; font-size: 2.5rem; }
.layout-banner .section-title { color: var(--theme-color); border-bottom: 1px dashed var(--theme-color); margin: 25px 0 15px 0; font-weight: bold; font-size: 1.2rem; }

/* 7. TIMELINE */
.layout-timeline { padding: 40px; }
.layout-timeline .cv-header { text-align: center; margin-bottom: 40px; }
.layout-timeline h1 { color: var(--theme-color); font-size: 2.5rem; margin-bottom: 5px; }
.layout-timeline .section-title { font-size: 1.4rem; color: var(--theme-color); font-weight: bold; margin: 30px 0 20px 0; display: flex; align-items: center; gap: 10px; }
.layout-timeline .section-title::after { content: ''; flex: 1; height: 1px; background: #ddd; }
.layout-timeline .job-entry { border-left: 2px solid var(--theme-color); padding-left: 20px; margin-left: 10px; position: relative; padding-bottom: 20px; }
.layout-timeline .job-entry::before { content: ''; width: 12px; height: 12px; background: white; border: 2px solid var(--theme-color); border-radius: 50%; position: absolute; left: -7px; top: 5px; }
.layout-timeline .job-entry:last-child { border-left-color: transparent; }

/* 8. SPLIT VIEW */
.layout-split { display: flex; flex-direction: row; height: 100%; }
.layout-split .left { width: 35%; background: #f1f5f9; padding: 40px 30px; border-right: 1px solid #cbd5e1; }
.layout-split .right { width: 65%; padding: 40px 30px; }
.layout-split h1 { font-size: 2.2rem; color: var(--theme-color); line-height: 1.1; margin-bottom: 10px; }
.layout-split .section-title { font-weight: bold; font-size: 1.1rem; margin-top: 25px; margin-bottom: 10px; color: #0f172a; text-transform: uppercase; letter-spacing: 1px; }

/* 9. ELEGANT */
.layout-elegant { font-family: 'Georgia', serif; padding: 50px; background: #fffaf0; }
.layout-elegant h1 { font-family: 'Times New Roman', serif; border-bottom: 1px solid #000; padding-bottom: 20px; text-align: center; font-size: 2.5rem; margin-bottom: 10px; }
.layout-elegant .job-title { text-align: center; font-style: italic; margin-bottom: 30px; color: #555; }
.layout-elegant .section-title { font-style: italic; border-bottom: 1px solid #ccc; margin: 30px 0 15px 0; font-size: 1.3rem; color: var(--theme-color); }

/* 10. CREATIVE */
.layout-creative { padding: 40px; border: 15px solid var(--theme-color); margin: 20px; height: calc(100% - 40px); background: white; }
.layout-creative h1 { font-size: 3.5rem; line-height: 0.9; color: var(--theme-color); width: 60%; margin: 0; }
.layout-creative .header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 50px; border-bottom: 5px solid #000; padding-bottom: 20px; }
.layout-creative .section-title { background: #000; color: white; padding: 5px 15px; display: inline-block; font-weight: bold; text-transform: uppercase; margin: 20px 0 15px 0; transform: rotate(-1deg); }

/* 11. CORPORATE */
.layout-corporate { padding: 40px; }
.layout-corporate .header { text-align: center; margin-bottom: 30px; border-bottom: 4px solid var(--theme-color); padding-bottom: 30px; }
.layout-corporate h1 { font-size: 2.8rem; margin: 0; color: #1e293b; }
.layout-corporate .content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.layout-corporate .section-title { color: var(--theme-color); font-weight: bold; text-transform: uppercase; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px; margin-bottom: 15px; }

/* 12. STARTUP */
.layout-startup { padding: 40px; font-family: 'Verdana', sans-serif; }
.layout-startup .header { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; background: #f8fafc; padding: 20px; border-radius: 15px; }
.layout-startup img { width: 100px; height: 100px; border-radius: 15px; object-fit: cover; }
.layout-startup h1 { margin: 0; color: #333; }
.layout-startup .section-title { background: var(--theme-color); color: white; padding: 8px 15px; border-radius: 20px; display: inline-block; margin: 25px 0 15px 0; font-size: 0.9rem; font-weight: bold; }

/* 13. ACADEMIC */
.layout-academic { padding: 50px; font-family: 'Times New Roman', serif; }
.layout-academic h1 { text-align: center; font-size: 2rem; text-transform: uppercase; margin-bottom: 5px; }
.layout-academic .contact-info { text-align: center; border-bottom: 1px solid #000; padding-bottom: 15px; margin-bottom: 30px; font-size: 0.95rem; }
.layout-academic .section-title { font-weight: bold; text-transform: uppercase; margin-top: 25px; border-bottom: 1px solid #ccc; padding-bottom: 2px; }

/* 14. TECH DARK */
.layout-tech { background: #0f172a; color: #e2e8f0; display: flex; flex-direction: row; height: 100%; }
.layout-tech .sidebar { background: #1e293b; border-right: 1px solid #334155; }
.layout-tech h1 { color: var(--theme-color); }
.layout-tech .section-title { color: white; border-bottom: 1px solid #334155; margin: 25px 0 15px 0; }
.layout-tech .entry-title { color: #fff; }
.layout-tech .entry-subtitle { color: #94a3b8; }
.layout-tech .entry-desc { color: #cbd5e1; }
.layout-tech .skill-tag { background: #334155; color: white; border: 1px solid #475569; }

/* 15. SWISS */
.layout-swiss { padding: 50px; }
.layout-swiss h1 { font-size: 4.5rem; font-weight: 900; line-height: 0.85; margin: 0 0 30px 0; color: var(--theme-color); letter-spacing: -2px; }
.layout-swiss .section-title { font-size: 1.2rem; font-weight: 900; margin-top: 40px; margin-bottom: 10px; text-transform: uppercase; }
.layout-swiss hr { border: none; border-top: 3px solid #000; margin: 10px 0 20px 0; }
.layout-swiss .job-entry { margin-bottom: 25px; }

/* 16. GRID SYSTEM */
.layout-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; padding: 20px; height: 100%; align-content: start; }
.layout-grid .box { background: #f1f5f9; padding: 25px; border-radius: 8px; }
.layout-grid .header { grid-column: 1 / -1; background: var(--theme-color); color: white; padding: 30px; border-radius: 8px; display: flex; align-items: center; gap: 20px; }
.layout-grid .header img { border: 3px solid white; border-radius: 50%; width: 80px; height: 80px; object-fit: cover; }
.layout-grid .section-title { color: var(--theme-color); font-weight: bold; margin-bottom: 15px; border-bottom: 2px solid #e2e8f0; padding-bottom: 5px; }

/* 17. CENTERED */
.layout-centered { text-align: center; padding: 50px; }
.layout-centered h1 { font-size: 2.8rem; margin-bottom: 5px; color: var(--theme-color); }
.layout-centered .contact-info { margin-bottom: 40px; color: #666; }
.layout-centered .section-title { display: inline-block; border-bottom: 2px solid var(--theme-color); padding-bottom: 5px; margin: 30px 0 20px 0; text-transform: uppercase; letter-spacing: 2px; font-weight: bold; }
.layout-centered .job-entry { text-align: center; margin-bottom: 25px; }
.layout-centered .entry-date { float: none; display: block; margin-bottom: 5px; font-weight: bold; color: var(--theme-color); }

/* 18. LEFT BORDER */
.layout-left-border { padding: 40px; border-left: 20px solid var(--theme-color); margin-left: 20px; height: 100%; }
.layout-left-border h1 { color: var(--theme-color); margin: 0; font-size: 3rem; line-height: 1; }
.layout-left-border .section-title { font-weight: bold; color: #555; margin-top: 40px; text-transform: uppercase; border-bottom: 1px solid #eee; padding-bottom: 5px; }

/* 19. NEWSLETTER */
.layout-newsletter { padding: 40px; }
.layout-newsletter .header { text-align: center; border-bottom: 2px solid #000; padding-bottom: 20px; margin-bottom: 30px; }
.layout-newsletter h1 { font-family: serif; font-size: 3.5rem; margin: 0; line-height: 1; }
.layout-newsletter .col-container { column-count: 2; column-gap: 40px; }
.layout-newsletter .section-title { border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 5px 0; margin: 20px 0 10px 0; font-weight: bold; text-align: center; text-transform: uppercase; break-after: avoid; }

/* 20. HERO */
.layout-hero .header { height: 250px; background: var(--theme-color); position: relative; margin-bottom: 80px; }
.layout-hero .photo-box img { width: 160px; height: 160px; border-radius: 50%; border: 5px solid white; position: absolute; bottom: -80px; left: 50%; transform: translateX(-50%); object-fit: cover; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.layout-hero .content { padding: 0 50px; text-align: center; }
.layout-hero h1 { margin-bottom: 5px; }
.layout-hero .job-entry { text-align: left; margin-bottom: 20px; }
.layout-hero .section-title { color: var(--theme-color); font-weight: bold; margin: 30px 0 15px 0; text-transform: uppercase; }

/* =========================================
   MOBILE RESPONSIVENESS (The Fix)
   ========================================= */
@media (max-width: 900px) {
    body { height: auto; overflow-y: auto; }
    .app-container { flex-direction: column; height: auto; overflow: visible; }

    /* Editor full width on mobile */
    .editor { width: 100%; height: auto; border-right: none; border-bottom: 2px solid #ccc; box-shadow: none; }
    .editor-header h2 { font-size: 1rem; }
    
    /* Reveal the Preview button */
    .mobile-preview-btn { display: inline-block; }

    /* Show Preview Area */
    .preview-area { display: flex; height: auto; padding: 20px 10px; background: #525659; justify-content: center; overflow: hidden; }

    /* Scale Down the A4 Page to Fit Mobile */
    .a4-page {
        zoom: 0.45; /* Zoom out */
        -moz-transform: scale(0.45);
        -moz-transform-origin: top center;
        margin-bottom: 0;
        box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    }
}
@media print { .editor { display: none; } .preview-area { padding: 0; } .a4-page { box-shadow: none; margin: 0; width: 100%; } }