:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --input-focus: #3b82f6;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --input-focus: #60a5fa;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: var(--card-bg);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- FORM SECTION --- */
.form-section {
    width: 480px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1.5rem;
}

.section-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

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

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

input, select, textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

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

.btn {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-color); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

.remove-btn { float: right; margin-top: -35px; margin-right: -10px; }

.dynamic-list-item {
    border: 1px dashed var(--border-color);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    position: relative;
    background: var(--card-bg);
}

/* --- PREVIEW SECTION --- */
.preview-section {
    flex: 1;
    background-color: var(--bg-color);
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
}

#preview-container {
    width: 210mm; /* A4 width */
    min-height: 297mm; /* A4 height */
    background: white;
    box-shadow: var(--shadow-md);
    padding: 20mm;
    color: #111;
    position: relative;
    transition: var(--transition);
}

.resume-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.header-text { 
    flex: 1; 
    min-width: 250px;
}

.resume-photo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-color);
    flex-shrink: 0;
}

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

/* General Resume inner classes */
.section-h { 
    font-size: 1.1rem; 
    font-weight: 700; 
    margin: 25px 0 10px 0; 
    color: #333; 
    border-bottom: 1px solid #eee;
}
.contact-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 0.85rem;
    margin: 10px 0;
}
.contact-info div { display: flex; align-items: center; gap: 5px; }
.contact-info svg { width: 14px; height: 14px; color: var(--primary-color); }
.summary-content { font-size: 0.95rem; line-height: 1.5; margin-bottom: 10px; }

/* --- TEMPLATE SPECIALIZATIONS --- */

/* 1. Classic */
.template-classic { font-family: 'Times New Roman', Times, serif; }
.template-classic h1 { text-align: left; text-transform: uppercase; font-size: 2.2rem; margin: 0; }
.template-classic .resume-header { border-bottom: 2px solid #000; padding-bottom: 10px; flex-direction: row; }
.template-classic .resume-header h3 { text-align: left; font-style: italic; color: #444; margin: 5px 0; }
.template-classic .contact-info { justify-content: flex-start; margin-top: 10px; font-weight: bold; }
.template-classic .resume-photo { border-radius: 4px; border-color: #000; width: 90px; height: 110px; border-radius: 0; }
.template-classic .section-h { border-bottom: 1px solid #000; text-transform: uppercase; letter-spacing: 1px; }

/* 2. Modern */
.template-modern { font-family: 'Inter', sans-serif; padding-top: 0 !important; }
.template-modern .resume-header { 
    background: #2563eb; 
    color: white; 
    padding: 30px; 
    margin: -20mm -20mm 25px -20mm; 
    display: flex;
    flex-wrap: wrap;
    align-items: center; 
    gap: 25px; 
}
.template-modern .header-text { flex: 1; min-width: 200px; }
.template-modern .contact-info { 
    background: rgba(255, 255, 255, 0.1); 
    padding: 10px 15px; 
    border-radius: 8px; 
    margin: 0; 
}
.template-modern .resume-header h1 { margin: 0; font-size: 2.5rem; letter-spacing: -1px; }
.template-modern .resume-header h3 { color: #bfdbfe !important; opacity: 1; margin: 5px 0; }
.template-modern .resume-photo { border-color: white; width: 110px; height: 110px; }
.template-modern .contact-info svg { color: white; }
.template-modern .section-h { color: #2563eb; border-left: 5px solid #2563eb; padding-left: 10px; background: #f1f5f9; border-bottom: none; }

/* 3. Creative (Two Column) */
.template-creative { display: grid; grid-template-columns: 240px 1fr; gap: 0; padding: 0 !important; }
.template-creative .sidebar { background: #1e293b; color: #f1f5f9; padding: 30px 20px; height: 100%; min-height: 100%; }
.template-creative .sidebar .section-h { color: #60a5fa; border-bottom: 1px solid #334155; margin-top: 30px; }
.template-creative .resume-photo { width: 120px; height: 120px; margin: 0 auto 20px; border-color: #60a5fa; }
.template-creative .main-content { padding: 40px; background: white; }
.template-creative .contact-info { flex-direction: column; gap: 10px; }
.template-creative .contact-info svg { color: #60a5fa; }
.template-creative .sidebar h2 { font-size: 1.5rem; }

/* 4. Minimalist */
.template-minimalist { font-family: 'Roboto Mono', monospace; color: #333; }
.template-minimalist h1 { border-bottom: 6px solid #111; display: inline-block; padding-bottom: 5px; }
.template-minimalist .section-h { background: #111; color: white; padding: 3px 10px; display: inline-block; border: none; font-size: 0.9rem; }
.template-minimalist .contact-info { border-top: 1px dashed #ccc; padding-top: 10px; }

/* 5. Executive */
.template-executive { font-family: 'Georgia', serif; }
.template-executive h1 { font-weight: 400; font-size: 2.6rem; border-bottom: 3px double #333; }
.template-executive .section-h { border-bottom: 2px solid #333; text-decoration: underline; text-underline-offset: 5px; }
.template-executive .list-item strong { color: #2c3e50; }

/* RESPONSIVE */
@media (max-width: 1024px) {
    main { flex-direction: column; overflow-y: auto; }
    .form-section { 
        width: 100%; 
        height: 500px; /* Fixed height for form area on smaller screens */
        flex: none;
        border-right: none; 
        border-bottom: 2px solid var(--border-color); 
    }
    .preview-section { 
        width: 100%;
        flex: 1;
        padding: 1rem; 
        background: #e2e8f0;
        overflow: visible; /* Let it grow */
    }
    #preview-container { 
        width: 100%; 
        max-width: 800px; /* Allow it to be full width on mobile but cap at 800px */
        min-width: unset; 
        height: auto; 
        padding: 10mm;
        margin: 0 auto;
        transform: none; /* Removed scale as it often causes issues with input visibility */
    }
}

@media (max-width: 600px) {
    header { padding: 0.8rem 1rem; flex-direction: column; gap: 10px; }
    .header-actions { flex-wrap: wrap; justify-content: center; }
    .form-section { height: 400px; }
    #preview-container { padding: 5mm; }
}

/* Theme Switch */
.theme-switch { display: flex; align-items: center; gap: 0.5rem; }
.theme-switch svg { width: 18px; color: var(--text-secondary); }
.switch { position: relative; width: 44px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(22px); }

/* Notifier */
#notifier {
    position: fixed; top: 1rem; right: 1rem; padding: 0.8rem 1.5rem; background: var(--primary-color); color: white; border-radius: 8px; box-shadow: var(--shadow-md); transform: translateX(200%); transition: transform 0.4s ease; z-index: 2000; font-weight: 500;
}
#notifier.show { transform: translateX(0); }