/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #fff;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e5e7eb;
}

.header-left {
    flex: 1;
}

.header-right {
    flex: 1;
    text-align: right;
}

.name {
    font-size: 2.2rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.title {
    font-size: 1.1rem;
    color: #6b7280;
    margin-bottom: 0;
}

.contact-item {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.contact-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.contact-link:hover {
    color: #1d4ed8;
}

/* Sections */
.section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

/* Summary */
.summary {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #374151;
}

/* Skills Grid */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.skill-group h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.skill-group p {
    color: #6b7280;
    font-size: 0.95rem;
}

/* Experience */
.experience-item {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #f3f4f6;
}

.experience-item:last-child {
    border-bottom: none;
}

.experience-header {
    margin-bottom: 1rem;
}

.job-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.company {
    font-weight: 600;
    color: #2563eb;
    margin-right: 1rem;
}

.company a {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.company a:hover {
    color: #1d4ed8;
}

.duration {
    color: #6b7280;
    font-size: 0.9rem;
}

.job-intro {
    font-style: italic;
    color: #6b7280;
    margin: 0.75rem 0;
    font-size: 0.95rem;
}

.job-description {
    margin-top: 0.75rem;
}

.job-description li {
    margin-bottom: 0.5rem;
    color: #374151;
}

.tech-stack {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tech-tag {
    background: #f3f4f6;
    color: #374151;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid #e5e7eb;
}

/* Education */
.education-item {
    padding: 1.5rem 0;
}

.degree {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.institution {
    color: #2563eb;
    font-weight: 500;
    margin-right: 1rem;
}

.institution a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.institution a:hover {
    color: #1d4ed8;
}

.education-duration {
    color: #6b7280;
    font-size: 0.9rem;
}

/* Languages */
.languages {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.language-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.language {
    color: #1f2937;
    font-weight: 600;
    font-size: 1.1rem;
}

.language-level {
    color: #6b7280;
    font-size: 0.9rem;
    font-style: italic;
}

/* Print Button */
.print-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #2563eb;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.print-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(0, 0, 0, 0.15);
}

.print-icon {
    margin-right: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        gap: 1rem;
    }

    .header-right {
        text-align: left;
    }

    .name {
        font-size: 1.8rem;
    }

    .skills-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .languages {
        flex-direction: column;
        gap: 1rem;
    }

    .print-btn {
        bottom: 1rem;
        right: 1rem;
        padding: 0.5rem 1rem;
    }

    /* CV Navigation responsive */
    .cv-nav-container {
        padding: 0 1rem;
    }

    .cv-nav-links {
        gap: 1rem;
    }

    .cv-nav-link {
        font-size: 0.85rem;
    }
}

/* CV Navigation Header */
.cv-nav-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e5e7eb;
    z-index: 1000;
    padding: 0.75rem 0;
}

.cv-nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cv-nav-brand a {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    text-decoration: none;
}

.cv-nav-brand a:hover {
    color: #2563eb;
}

.cv-nav-links {
    display: flex;
    gap: 1.5rem;
}

.cv-nav-link {
    color: #6b7280;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.cv-nav-link:hover {
    color: #2563eb;
}

.cv-nav-link.active {
    color: #2563eb;
}

/* Add top margin to body when nav is present */
body.has-nav {
    margin-top: 60px;
}

/* Print Visibility Classes */
.print-only {
    display: none !important;
}

/* Print Styles */
@media print {

    /* Show print-only elements */
    .print-only {
        display: block !important;
    }

    .cv-nav-header {
        display: none !important;
    }

    body.has-nav {
        margin-top: 0 !important;
    }

    .print-btn {
        display: none;
    }

    body {
        font-size: 10pt;
        line-height: 1.3;
        color: #000;
    }

    .container {
        max-width: none;
        padding: 0.75rem 1rem;
        margin: 0;
    }

    /* Header - keep side by side layout */
    .header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        flex-direction: row !important;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #000;
        page-break-inside: avoid;
        page-break-after: avoid;
        width: 100%;
    }

    .header-left {
        flex: 1 1 55% !important;
        max-width: 55% !important;
        min-width: 45% !important;
        display: inline-block !important;
        vertical-align: top !important;
    }

    .header-right {
        flex: 1 1 45% !important;
        max-width: 45% !important;
        min-width: 35% !important;
        text-align: right !important;
        display: inline-block !important;
        vertical-align: top !important;
        padding-right: 0.5rem;
    }

    .name {
        font-size: 16pt;
        margin-bottom: 0.25rem;
        color: #000;
    }

    .title {
        font-size: 11pt;
        color: #000;
        margin-bottom: 0;
    }

    .contact-item {
        font-size: 9pt;
        color: #000;
        margin-bottom: 0.1rem;
    }

    .contact-link {
        color: #000;
        text-decoration: none;
    }

    /* Sections */
    .section {
        margin-bottom: 1rem;
        page-break-inside: auto;
    }

    /* Allow specific sections to break if needed */
    .section:not(.header) {
        page-break-before: auto;
        page-break-after: auto;
    }

    .section-title {
        font-size: 12pt;
        margin-bottom: 0.75rem;
        padding-bottom: 0.25rem;
        border-bottom: 0.5pt solid #000;
        color: #000;
    }

    /* Summary */
    .summary {
        font-size: 10pt;
        line-height: 1.3;
        margin-bottom: 0.5rem;
        color: #000;
    }

    /* Skills */
    .skills-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        page-break-inside: auto;
    }

    .skill-group {
        page-break-inside: avoid;
        margin-bottom: 0.5rem;
    }

    .skill-group h3 {
        font-size: 10pt;
        margin-bottom: 0.25rem;
        color: #000;
    }

    .skill-group p {
        font-size: 9pt;
        line-height: 1.2;
        color: #000;
    }

    /* Experience */
    .experience-item {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
        border-bottom: 0.5pt solid #ccc;
        page-break-inside: auto;
        page-break-after: auto;
    }

    .experience-item:last-child {
        border-bottom: none;
    }

    .experience-header {
        margin-bottom: 0.5rem;
        page-break-inside: avoid;
        page-break-after: auto;
        break-inside: avoid;
        break-after: auto;
    }

    .job-intro {
        page-break-inside: avoid;
        page-break-after: auto;
        break-inside: avoid;
        break-after: auto;
    }

    .job-description {
        page-break-inside: avoid;
        page-break-after: auto;
        break-inside: avoid;
        break-after: auto;
    }

    .tech-stack {
        page-break-inside: avoid;
        page-break-after: auto;
        break-inside: avoid;
        break-after: auto;
    }

    .job-title {
        font-size: 11pt;
        margin-bottom: 0.1rem;
        color: #000;
    }

    .company {
        font-size: 10pt;
        color: #000;
        margin-right: 0.5rem;
    }

    .duration {
        font-size: 9pt;
        color: #000;
    }

    .job-intro {
        font-size: 9pt;
        margin: 0.25rem 0;
        color: #000;
    }

    .job-description {
        margin-top: 0.5rem;
    }

    .job-description li {
        font-size: 9pt;
        margin-bottom: 0.25rem;
        color: #000;
        line-height: 1.2;
    }

    .tech-stack {
        margin-top: 0.5rem;
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .tech-tag {
        background: #f0f0f0;
        color: #000;
        padding: 0.1rem 0.4rem;
        border-radius: 0.2rem;
        font-size: 8pt;
        border: 0.5pt solid #ccc;
    }

    /* Education */
    .education-item {
        padding: 0.75rem 0;
    }

    .degree {
        font-size: 10pt;
        color: #000;
        margin-bottom: 0.1rem;
    }

    .institution {
        font-size: 9pt;
        color: #000;
        margin-right: 0.5rem;
    }

    .education-duration {
        font-size: 9pt;
        color: #000;
    }

    /* Languages */
    .languages {
        display: flex !important;
        flex-direction: row !important;
        gap: 1rem;
        flex-wrap: wrap;
    }

    .language-item {
        display: flex;
        flex-direction: column;
        gap: 0.1rem;
    }

    .language {
        font-size: 10pt;
        color: #000;
    }

    .language-level {
        font-size: 9pt;
        color: #000;
    }
}

/* Firefox-specific print optimizations */
@-moz-document url-prefix() {
    @media print {
        /* Firefox is more aggressive with page-break-inside: avoid */
        /* Allow more flexible breaking for better space usage */
        .experience-item {
            page-break-inside: auto !important;
            break-inside: auto !important;
        }
        
        .job-description {
            page-break-inside: avoid !important;
            page-break-after: auto !important;
            break-inside: avoid !important;
            break-after: auto !important;
        }
        
        .tech-stack {
            page-break-inside: avoid !important;
            page-break-after: auto !important;
            break-inside: avoid !important;
            break-after: auto !important;
        }
        
        /* Keep only the most critical elements together */
        .experience-header {
            page-break-inside: avoid !important;
            break-inside: avoid !important;
            page-break-after: auto !important;
            break-after: auto !important;
        }
        
        .job-intro {
            page-break-inside: avoid !important;
            break-inside: avoid !important;
            page-break-after: auto !important;
            break-after: auto !important;
        }
    }
}