/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-primary));
    color: var(--text-primary);
    line-height: 1.6;
}

/* Layout */
.container {
    display: grid;
    grid-template-areas:
        "header header header"
        "nav main toc"
        "footer footer footer";
    grid-template-columns: 250px 1fr 250px;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    gap: 0;
}

/* Header Styles */
header {
    grid-area: header;
    background: linear-gradient(120deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 4px 6px var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo i {
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.theme-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.research-papers-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
}

.research-papers-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Navigation */
nav {
    grid-area: nav;
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    height: 100%;
}

.topics-list {
    list-style: none;
}

.topics-list h3 {
    margin: 1.5rem 0 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
    color: var(--primary-dark);
}

.topic-item {
    margin: 0.5rem 0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.topic-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.topic-item.active {
    background: var(--primary);
    color: white;
}

.topic-item i {
    font-size: 0.9rem;
}

.coming-soon {
    opacity: 0.6;
    cursor: not-allowed;
}

.coming-soon:hover {
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Main Content */
main {
    grid-area: main;
    padding: 2rem;
    background: var(--bg-secondary);
    overflow-y: auto;
}

.article-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.article-header h1 {
    font-size: 2.2rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.article-meta {
    display: flex;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.article-content {
    max-width: 800px;
}

.article-content h2 {
    color: var(--primary);
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.article-content h3 {
    color: var(--text-primary);
    margin: 1.2rem 0 0.8rem;
}

.article-content p {
    margin-bottom: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.article-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 6px var(--shadow);
}

.code-block {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
}

/* Table of Contents */
.toc {
    grid-area: toc;
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    height: 100%;
}

.toc h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
    color: var(--primary-dark);
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.toc-item:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.toc-item.active {
    background: var(--primary);
    color: white;
}

/* Footer */
footer {
    grid-area: footer;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
}

.social-links a {
    color: var(--text-primary);
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: var(--accent);
}


/* About Me Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideIn 0.3s ease;
}

.close {
    color: var(--text-muted);
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
}

.close:hover {
    color: var(--primary);
}

#about-me-content {
    padding: 2rem;
}

.about-me-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary);
}

.about-me-header h2 {
    color: var(--primary-dark);
    font-size: 2.2rem;
}

.about-me-section {
    margin-bottom: 2.5rem;
}

.about-me-section h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

.skill-category {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
}

.skill-category h4 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.skill-category ul {
    list-style-type: none;
}

.skill-category li {
    padding: 0.3rem 0;
    position: relative;
    padding-left: 1.2rem;
}

.skill-category li:before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Projects */
.project {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.project h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

/* Education */
.education-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

.education-item h4 {
    color: var(--primary);
    margin-bottom: 0.3rem;
}

.education-item em {
    color: var(--text-muted);
    font-style: italic;
}

/* Contact */
.contact-info {
    text-align: center;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.contact-link:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Code block styling */
.code-block {
    position: relative;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    border-left: 4px solid var(--primary);
    white-space: pre-wrap;
}

.code-block br {
    display: block;
    content: "";
    margin: 0;
    line-height: 0.5rem;
}

/* Ensure proper spacing */
.code-block {
    line-height: 1.6;
}

.code-block .keyword {
    color: #ff79c6;
    font-weight: bold;
}

.code-block .string {
    color: #f1fa8c;
}

.code-block .comment {
    color: #6272a4;
    font-style: italic;
}

/* Copy button styles */
.copy-code-btn {
    transition: all 0.3s ease !important;
}

.copy-code-btn:hover {
    transform: scale(1.1);
    opacity: 1 !important;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .code-block {
        padding: 1rem;
        font-size: 0.8rem;
    }

    .copy-code-btn {
        padding: 4px 6px !important;
        font-size: 0.8rem;
    }
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive design for modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

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

    .contact-links {
        flex-direction: column;
        align-items: center;
    }

    .contact-link {
        width: 200px;
        justify-content: center;
    }
}

/* About Me button in header */
.about-me-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.about-me-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .about-me-btn {
        display: none;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        grid-template-areas:
            "header header header"
            "nav main main"
            "footer footer footer";
        grid-template-columns: 200px 1fr;
    }

    .toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-areas:
            "header"
            "main"
            "footer";
        grid-template-columns: 1fr;
    }

    .nav-toggle {
        display: block;
    }

    .research-papers-btn {
        display: none;
    }

    nav {
        display: none;
        position: fixed;
        top: 70px;
        left: 0;
        height: calc(100vh - 70px);
        width: 250px;
        z-index: 99;
        box-shadow: 4px 0 10px var(--shadow);
    }

    nav.active {
        display: block;
    }

    .toc {
        display: none;
    }

    .header-right {
        gap: 0.5rem;
    }
}

/* Utility Classes */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 50px;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--primary);
    margin-right: 0.5rem;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.placeholder-content {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.placeholder-content i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: var(--primary);
}

/* Responsive Design Improvements */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 220px 1fr 220px;
    }
}

@media (max-width: 1024px) {
    .container {
        grid-template-areas:
            "header header header"
            "nav main main"
            "footer footer footer";
        grid-template-columns: 220px 1fr;
    }

    .toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .container {
        grid-template-columns: 200px 1fr;
    }

    .header-right {
        display: flex;
        gap: 0.8rem;
    }

    .research-papers-btn,
    .about-me-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .research-papers-btn span,
    .about-me-btn span {
        display: none;
    }

    .research-papers-btn i,
    .about-me-btn i {
        margin-right: 0;
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-areas:
            "header"
            "main"
            "footer";
        grid-template-columns: 1fr;
    }

    .nav-toggle {
        display: block;
    }

    nav {
        display: none;
        position: fixed;
        top: 70px;
        left: 0;
        height: calc(100vh - 70px);
        width: 280px;
        z-index: 99;
        box-shadow: 4px 0 10px var(--shadow);
        overflow-y: auto;
    }

    nav.active {
        display: block;
    }

    .toc {
        display: none;
    }

    /* Mobile header improvements */
    .header-right {
        gap: 0.5rem;
    }

    .research-papers-btn,
    .about-me-btn {
        display: flex;
        padding: 0.5rem;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        justify-content: center;
        align-items: center;
    }

    .research-papers-btn i,
    .about-me-btn i {
        font-size: 1.2rem;
        margin: 0;
    }

    .logo span {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .logo span {
        font-size: 1.1rem;
    }

    .header-right {
        gap: 0.3rem;
    }

    .research-papers-btn,
    .about-me-btn {
        width: 36px;
        height: 36px;
    }

    .theme-toggle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    main {
        padding: 1.5rem;
    }

    .article-header h1 {
        font-size: 1.8rem;
    }
}

/* Large screen responsiveness */
@media (min-width: 1600px) {
    .container {
        grid-template-columns: 300px 1fr 300px;
        max-width: 1800px;
        margin: 0 auto;
    }

    nav {
        padding: 2rem;
    }

    .toc {
        padding: 2rem;
    }

    main {
        padding: 3rem;
    }

    .article-content {
        max-width: 900px;
    }
}

@media (min-width: 2000px) {
    .container {
        grid-template-columns: 350px 1fr 350px;
        max-width: 2200px;
    }

    nav {
        padding: 2.5rem;
    }

    .toc {
        padding: 2.5rem;
    }

    main {
        padding: 3.5rem;
    }

    .article-content {
        max-width: 1000px;
    }

    .article-header h1 {
        font-size: 2.5rem;
    }

    .article-content h2 {
        font-size: 2rem;
    }
}

/* Mobile menu improvements */
.mobile-header-buttons {
    display: none;
}

@media (max-width: 768px) {
    .mobile-header-buttons {
        display: flex;
        gap: 1rem;
        padding: 1rem;
        background: var(--bg-tertiary);
        border-top: 1px solid var(--border-color);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        justify-content: center;
    }

    .mobile-header-buttons a {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        color: var(--text-primary);
        font-size: 0.8rem;
        gap: 0.3rem;
    }

    .mobile-header-buttons i {
        font-size: 1.2rem;
    }

    body {
        padding-bottom: 70px;
        /* Space for mobile buttons */
    }
}

/* Improved navigation for mobile */
@media (max-width: 768px) {
    nav {
        width: 100%;
        max-width: 320px;
    }

    .topics-list h3 {
        font-size: 1.1rem;
    }

    .topic-item {
        padding: 1rem;
        font-size: 1rem;
    }
}

/* Better table of contents for large screens */
@media (min-width: 1025px) {
    .toc {
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
    }
}

/* Smooth transitions for all interactive elements */
nav,
.toc,
.research-papers-btn,
.about-me-btn,
.theme-toggle {
    transition: all 0.3s ease;
}

/* Focus states for accessibility */
.research-papers-btn:focus,
.about-me-btn:focus,
.theme-toggle:focus,
.topic-item:focus,
.toc-item:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --shadow: rgba(0, 0, 0, 0.5);
    }

    .topic-item.active,
    .toc-item.active {
        outline: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}