:root {
    --bg: #ffffff;
    --text: #000000;
    --text-muted: #666666;
    --text-light: #888888;
    --border: #e0e0e0;
    --primary: #0066cc;
    --font-sans: "Inter var", "Inter", system-ui, sans-serif;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --text: #ffffff;
    --text-muted: #cccccc;
    --text-light: #999999;
    --border: #333333;
    --primary: #4da6ff;
}

[data-theme="dark"] .github-link {
    background: #1a1a1a;
    border-color: #444444;
}

[data-theme="dark"] .github-link:hover {
    background: #ffffff;
    color: #0a0a0a;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .company-link,
[data-theme="dark"] .institution-link {
    color: var(--primary);
}

[data-theme="dark"] .company-link:hover,
[data-theme="dark"] .institution-link:hover {
    color: var(--text);
}

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

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    padding: 40px 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.header-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 10px;
}

.control-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-muted);
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.control-btn:hover {
    color: var(--text);
    background: var(--border);
}

.resume-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 20px;
}

.name {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.title {
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 500;
}

.contact-info {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.contact-info a {
    color: var(--primary);
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

.summary {
    text-align: center;
    margin: 25px 0;
    padding: 20px;
    background: rgba(0, 102, 204, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.summary p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    position: relative;
}

.section-title::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--primary);
}

.item {
    margin-bottom: 20px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
}

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

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.item-title {
    font-weight: 600;
    color: var(--text);
    font-size: 15px;
}

.item-company {
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
}

.company-link,
.institution-link {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

.company-link:hover,
.institution-link:hover {
    color: var(--text);
    text-decoration: underline;
}

.company-link::after,
.institution-link::after {
    content: "🔗";
    font-size: 10px;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.company-link:hover::after,
.institution-link:hover::after {
    opacity: 0.7;
}

.item-location {
    color: var(--text-light);
    font-size: 13px;
    font-style: italic;
}

.item-duration {
    color: var(--text-light);
    font-size: 13px;
    background: var(--border);
    padding: 4px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.item-description {
    margin-top: 10px;
}

.item-description ul {
    margin-left: 20px;
}

.item-description li {
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.project-links {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.links-label {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
    display: block;
    margin-bottom: 8px;
}

.links-container {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.project-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.live-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.live-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.github-link {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}

.github-link:hover {
    background: var(--text);
    color: var(--bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.skill-category {
    background: rgba(0, 102, 204, 0.05);
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.skill-category-title {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 8px;
}

.skill-list {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.project-item {
    background: rgba(0, 102, 204, 0.02);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 15px;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.project-title {
    font-weight: 600;
    color: var(--text);
    font-size: 15px;
}

.project-year {
    color: var(--text-light);
    font-size: 13px;
    background: var(--border);
    padding: 2px 8px;
    border-radius: 10px;
}

.project-description {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.project-tech {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tech-tag {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.achievement-list {
    margin-left: 20px;
}

.achievement-list li {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.share-section {
    text-align: center;
    margin: 30px 0;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.share-section button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
    min-width: 140px;
}

.share-section button:hover {
    background: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.share-section .copy-link-btn {
    background: #6c757d;
}

.share-section .copy-link-btn:hover {
    background: #5a6268;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

/* Legacy download button styles for backward compatibility */
.download-btn {
    text-align: center;
    margin: 30px 0;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.download-btn button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
    min-width: 140px;
}

.download-btn button:hover {
    background: #0052a3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.download-btn .print-btn {
    background: #6c757d;
}

.download-btn .print-btn:hover {
    background: #5a6268;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        padding: 0;
        margin: 0;
        font-size: 11px;
        line-height: 1.4;
        background: white !important;
        color: black !important;
    }

    .header-controls {
        display: none !important;
    }

    .download-btn {
        display: none !important;
    }

    .share-section {
        display: none !important;
    }

    .container {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 0.5in;
        box-sizing: border-box;
    }

    .resume-header {
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 2px solid #333 !important;
        page-break-inside: avoid;
    }

    .name {
        font-size: 24px;
        margin-bottom: 6px;
        color: black !important;
    }

    .title {
        font-size: 14px;
        margin-bottom: 10px;
        color: #333 !important;
    }

    .contact-info {
        font-size: 11px;
        gap: 15px;
        color: #333 !important;
    }

    .contact-info a {
        color: #0066cc !important;
        text-decoration: none;
    }

    .summary {
        margin: 15px 0;
        padding: 12px;
        background: #f8f9fa !important;
        border-left: 3px solid #0066cc !important;
        page-break-inside: avoid;
    }

    .summary p {
        font-size: 11px;
        color: #333 !important;
    }

    .section {
        margin-bottom: 20px;
        page-break-inside: avoid;
    }

    .section-title {
        font-size: 14px;
        margin-bottom: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #333 !important;
        color: black !important;
        page-break-after: avoid;
    }

    .item {
        margin-bottom: 15px;
        padding: 8px 0;
        border-bottom: 1px solid #eee !important;
        page-break-inside: avoid;
    }

    .item-header {
        margin-bottom: 6px;
    }

    .item-title {
        font-size: 12px;
        color: black !important;
    }

    .item-company {
        font-size: 11px;
        color: #0066cc !important;
    }

    .item-location {
        font-size: 10px;
        color: #666 !important;
    }

    .item-duration {
        font-size: 10px;
        background: #f0f0f0 !important;
        color: #333 !important;
        padding: 2px 6px;
        border-radius: 8px;
    }

    .item-description ul {
        margin-left: 15px;
    }

    .item-description li {
        font-size: 10px;
        margin-bottom: 4px;
        color: #333 !important;
        line-height: 1.3;
    }

    .project-links {
        margin-top: 8px;
        padding-top: 6px;
        border-top: 1px solid #ddd !important;
    }

    .links-label {
        font-size: 10px;
        color: black !important;
        margin-bottom: 4px;
    }

    .links-container {
        gap: 8px;
    }

    .project-link {
        font-size: 9px;
        padding: 3px 8px;
        border: 1px solid #ddd !important;
        border-radius: 4px;
        text-decoration: none;
        background: white !important;
        color: #0066cc !important;
    }

    .live-link {
        background: #f0f8ff !important;
        border-color: #0066cc !important;
    }

    .github-link {
        background: #f8f8f8 !important;
        border-color: #666 !important;
        color: #333 !important;
    }

    .company-link,
    .institution-link {
        color: #0066cc !important;
        text-decoration: none;
    }

    .company-link::after,
    .institution-link::after {
        display: none;
    }

    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .skill-category {
        background: #f8f9fa !important;
        padding: 10px;
        border-left: 2px solid #0066cc !important;
        border-radius: 4px;
    }

    .skill-category-title {
        font-size: 11px;
        color: black !important;
        margin-bottom: 6px;
    }

    .skill-list {
        font-size: 10px;
        color: #333 !important;
    }

    /* Ensure no page breaks in the middle of important sections */
    .resume-header,
    .summary,
    .item,
    .skill-category {
        page-break-inside: avoid;
    }

    /* Ensure sections start together when possible */
    .section {
        orphans: 2;
        widows: 2;
    }

    /* Keep project links together */
    .project-links {
        page-break-inside: avoid;
    }

    /* Force page breaks before major sections if needed */
    .section:not(:first-child) {
        page-break-before: auto;
    }

    /* Ensure adequate space for content */
    @page {
        margin: 0.75in;
        size: letter;
    }
}

@media (max-width: 768px) {
    body {
        padding: 20px 15px;
    }

    .header-controls {
        position: static;
        justify-content: center;
        margin-bottom: 20px;
    }

    .contact-info {
        flex-direction: column;
        gap: 10px;
    }

    .item-header,
    .project-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .item-duration,
    .project-year {
        margin-top: 5px;
    }

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

    .name {
        font-size: 28px;
    }

    .links-container {
        flex-direction: column;
        gap: 8px;
    }

    .project-link {
        justify-content: center;
        padding: 8px 16px;
    }

    .share-section,
    .download-btn {
        flex-direction: column;
        align-items: center;
    }

    .share-section button,
    .download-btn button {
        width: 100%;
        max-width: 200px;
    }
}