.cv-tool-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.tool-header {
    text-align: center;
    margin-bottom: 80px;
}

.tool-header h2 {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 10px;
}

.tool-header p {
    color: var(--footer-text);
    font-size: 0.95rem;
}

/* ================= Workspace (Vertical) ================= */
.cv-workspace {
    display: flex;
    flex-direction: column;
    /* الترتيب العمودي: الإدخال فوق، الورقة تحت */
    gap: 40px;
}

/* ================= Input Section ================= */
.cv-input-section {
    width: 100%;
}

.input-card {
    background: var(--nav-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.cv-accordion {
    background-color: var(--bg-color);
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    transition: 0.3s;
}

.cv-accordion summary {
    font-weight: 600;
    cursor: pointer;
    outline: none;
    font-size: 1rem;
    color: var(--text-color);
}

.cv-accordion summary::marker {
    color: var(--primary-color);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-color);
}

.cv-input-section input,
.cv-input-section textarea {
    width: 100%;
    padding: 12px;
    background-color: var(--nav-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 6px;
    font-size: 16px;
    /* Prevents iOS Zoom */
    transition: 0.3s;
    font-family: inherit;
}

.cv-input-section input:focus,
.cv-input-section textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.cv-input-section textarea {
    min-height: 100px;
    resize: vertical;
}

.action-row {
    margin-top: 25px;
}

.action-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.05rem;
    cursor: pointer;
    transition: 0.3s;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
}

.action-btn.primary:hover {
    background: var(--hover-color);
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: transparent;
    border: 2px dashed var(--primary-color);
    color: var(--primary-color);
    margin-top: 15px;
}

.action-btn.secondary:hover {
    background: var(--primary-color);
    color: white;
}

.dynamic-group {
    background: var(--bg-color);
    padding: 15px;
    margin-top: 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
    align-self: flex-start;
}

/* ================= Live Preview Area ================= */
.cv-preview-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-header {
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.preview-header h3 {
    color: var(--text-color);
    font-size: 1.2rem;
}

/* Wrapper Fix for Mobile Horizontal Scroll */
.cv-paper-wrapper {
    width: 100%;
    max-width: 210mm;
    overflow-x: auto;
    /* Fallback for safe scrolling */
    -webkit-overflow-scrolling: touch;
    display: flex;
    justify-content: center;
    padding: 10px;
    background: var(--nav-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

/* Strict A4 Paper Format */
.cv-paper {
    width: 210mm;
    height: 297mm;
    flex-shrink: 0;
    background: white;
    padding: 15mm 20mm;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    color: #000;
    font-family: 'Times New Roman', Times, serif;
    box-sizing: border-box;
    overflow: hidden;
    transform-origin: top center;
}

/* Paper Content Styling */
.cv-paper * {
    color: #000;
}

.paper-header {
    text-align: center;
    border-bottom: 2px solid #000;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.paper-header h1 {
    font-size: 24pt;
    margin: 0;
    text-transform: uppercase;
}

.title-sub {
    font-size: 14pt;
    font-weight: bold;
    margin: 5px 0;
}

.contact-info {
    font-size: 10pt;
    color: #444;
}

.section-title {
    font-size: 12pt;
    border-bottom: 1px solid #000;
    margin: 20px 0 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    padding-left: 20px;
    margin: 0;
}

.exp-item,
.edu-item {
    margin-bottom: 15px;
}

.exp-item p {
    margin-top: 5px;
    font-size: 10.5pt;
    line-height: 1.4;
}

/* ================= Mobile Responsiveness ================= */
@media (max-width: 850px) {
    .cv-paper-wrapper {
        justify-content: flex-start;
        /* Allows natural panning on small screens */
    }

    .cv-paper {
        zoom: 0.7;
        /* Perfect scaling fix for mobile WebKit without blank spaces */
    }
}

@media (max-width: 500px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .cv-paper {
        zoom: 0.45;
    }
}

/* ================= Bulletproof 1-Page PDF Print ================= */
@media print {
    @page {
        size: A4;
        margin: 0mm !important;
    }

    html,
    body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        height: 297mm !important;
    }

    body * {
        visibility: hidden !important;
    }

    .cv-paper,
    .cv-paper * {
        visibility: visible !important;
    }

    .cv-paper {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        height: 297mm !important;
        margin: 0 !important;
        padding: 15mm 20mm !important;
        box-shadow: none !important;
        border: none !important;
        transform: scale(1) !important;
        zoom: 1 !important;
        overflow: hidden !important;
    }
}


.languages-list-paper {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-left: 5px;
}

.language-item-paper {
    font-size: 10.5pt;
    line-height: 1.4;
    color: #000;
}

.language-item-paper strong {
    text-transform: capitalize;
}

/* Ensure language section is handled in print */
@media print {
    .languages-list-paper {
        display: block !important;
    }
}