:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --text-color: #1a202c;
    --meta-color: #4a5568;
    --sidebar-bg: #f4f6f7;
    --sidebar-text: #1a202c;
    --border-color: #cbd5e0;
    --line-color: #2c3e50;
    --font-main: 'Tajawal', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

body {
    font-family: var(--font-main);
    background-color: #ecf0f1;
    display: flex;
    justify-content: center;
    padding: 20px 0;
    color: var(--text-color);
}

body[dir="rtl"] {
    direction: rtl;
}

body[dir="ltr"] {
    direction: ltr;
    font-family: 'Roboto', sans-serif;
}

.cv-page {
    width: 210mm;
    height: 296mm;
    background: white;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 34%;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

body[dir="rtl"] .sidebar {
    border-left: 1px solid #d1d5db;
}

body[dir="ltr"] .sidebar {
    border-right: 1px solid #d1d5db;
}

.sidebar-title {
    font-size: 1.15rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 12px;
    font-weight: 800;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    word-break: break-all;
}

.contact-item i {
    color: var(--primary-color);
    width: 16px;
    text-align: center;
}

.edu-item {
    margin-bottom: 15px;
}

.edu-date {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--meta-color);
}

.edu-degree {
    font-weight: 800;
    font-size: 0.9rem;
    margin: 3px 0;
    line-height: 1.3;
}

.edu-school {
    font-size: 0.85rem;
    color: #2d3748;
    font-weight: 600;
}

.edu-grade {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--meta-color);
    margin-top: 2px;
}

/* Skills List */
.skills-list {
    list-style: none;
    position: relative;
    padding: 0;
}

.skills-list li {
    font-size: 0.85rem;
    margin-bottom: 0;
    display: flex;
    align-items: flex-start;
    gap: 0;
    line-height: 1.4;
    font-weight: 600;
    position: relative;
    color: #1a202c;
}

.skill-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 30px;
    min-height: 50px;
    flex-shrink: 0;
    margin-left: 10px;
}

body[dir="ltr"] .skill-icon {
    margin-left: 0;
    margin-right: 10px;
}

.skill-text {
    padding-top: 5px;
    padding-bottom: 15px;
}

.skill-icon::before {
    content: '';
    position: absolute;
    top: 25px;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    background-color: var(--line-color);
    z-index: 1;
}

.skills-list li:last-child .skill-icon::before {
    display: none;
}

.skill-icon i {
    color: white;
    background-color: var(--primary-color);
    font-size: 0.7rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 2;
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--line-color);
    margin-top: 2px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px 30px;
    /* More padding since page margin is 0 */
}

.header {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.name {
    font-size: 2.2rem;
    color: var(--primary-color);
    margin-bottom: 5px;
    font-weight: 800;
}

.job-title {
    font-size: 1.2rem;
    color: #4a5568;
    font-weight: 600;
    margin-bottom: 15px;
}

.summary-box {
    background-color: #f8fafc;
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #2d3748;
    font-weight: 500;
    text-align: justify;
    border-radius: 4px;
    margin-bottom: 5px;
}

body[dir="rtl"] .summary-box {
    border-right: 4px solid var(--primary-color);
}

body[dir="ltr"] .summary-box {
    border-left: 4px solid var(--primary-color);
}

.section-title {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

/* Experience Grid - MODIFIED FOR DATE POSITION */
.exp-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.exp-row {
    display: flex;
    flex-direction: row;
    /* Default */
    justify-content: space-between;
    /* Push items apart */
    align-items: flex-start;
    /* Align top */
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.exp-row:last-child {
    border-bottom: none;
}

/* Swap Order Logic */
.exp-details {
    flex: 1;
    font-size: 0.9rem;
    color: #1a202c;
    order: 1;
    /* Content First (Right in RTL) */
    padding-left: 15px;
    /* Spacing from date */
}

body[dir="ltr"] .exp-details {
    padding-left: 0;
    padding-right: 15px;
}

.exp-date {
    width: 100px;
    font-weight: 800;
    color: var(--primary-color);
    font-size: 0.85rem;
    flex-shrink: 0;
    order: 2;
    /* Date Second (Left in RTL) */
    text-align: left;
    /* Align date text to left end */
}

/* In English (LTR), Order 1 is Left, Order 2 is Right. 
   So Text Left, Date Right. Matches 'after the text' logic. */
body[dir="ltr"] .exp-date {
    width: 120px;
    text-align: right;
}

.exp-role {
    font-weight: 800;
    color: #1a202c;
    display: inline-block;
}

.exp-place {
    color: #4a5568;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Controls */
.print-control {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 999;
}

.print-control button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* PRINT SETTINGS - CLEAN PDF */
@page {
    size: A4;
    margin: 0;
    /* Removing margin suppresses headers/footers in most browsers */
}

@media print {

    html,
    body {
        width: 210mm;
        height: 297mm;
        margin: 0;
        padding: 0;
        background-color: white;
    }

    .cv-page {
        margin: 0;
        box-shadow: none;
        width: 100%;
        height: 100%;
        page-break-after: avoid;
        border: none;
    }

    .print-control {
        display: none !important;
    }

    /* Additional safety to ensure full bleed */
    .sidebar {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        height: 100%;
    }
}