/* CSS Variables for Theming */
:root {
    /* Default Dark Theme */
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --text-muted: #aaa;
    --card-bg: #1e1e1e;
    --navbar-bg: #1f1f1f;
    --header-gradient-start: #1a1a1a;
    --header-gradient-end: #1e392a;
    --primary-color: #2ecc71;
    --shadow-color: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
    /* Light Theme Override */
    --bg-color: #f4f4f9;
    --text-color: #333;
    --text-muted: #666;
    --card-bg: white;
    --navbar-bg: #2c3e50;
    --header-gradient-start: #2c3e50;
    --header-gradient-end: #27ae60;
    --primary-color: #27ae60;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Modal Styles */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    /* Black w/ opacity */
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    /* Flex helps center it */
    opacity: 1;
}

/* Modal Content */
.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border: 1px solid var(--border-color, #444);
    border-radius: 15px;
    width: 80%;
    max-width: 700px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.19);
    position: relative;
    animation: slideDown 0.4s ease-out;
    color: var(--text-color);
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

/* Close Button */
.close-modal {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    line-height: 20px;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
}

/* Modal Specifics */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-right: 30px;
    /* Space for close button */
    flex-wrap: wrap;
    /* Wrap on smaller screens */
    gap: 15px;
}

.modal-header h2 {
    margin: 0;
}

/* Override project-tech styles within modal header */
.modal-header .project-tech {
    margin: 0;
    justify-content: flex-end;
}

.modal-links {
    margin-top: 25px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.modal-links .cta-button {
    font-size: 0.9em;
    padding: 10px 20px;
}

/* Responsive Modal */
@media screen and (max-width: 600px) {
    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 20px;
    }
}

/* Scroll Reveal Animation */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Toggle Button */
.icon-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 5px;
}

.icon-button:hover {
    transform: rotate(15deg) scale(1.1);
}

/* Scroll Progress Bar */
.scroll-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 1001;
    /* Ensure it's above the navbar */
    background: transparent;
}

.scroll-progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.1s ease-out;
}

/* New Navbar Styles */
.navbar {
    background-color: var(--navbar-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s;
}

.nav-links a {
    color: white;
    text-decoration: none;
    margin-right: 20px;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

.nav-links a.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

header {
    text-align: center;
    padding: 80px 20px;
    background: linear-gradient(135deg, var(--header-gradient-start) 0%, var(--header-gradient-end) 100%);
    color: white;
    position: relative;
    transition: background 0.3s;
    overflow: hidden;
}

.lang-switch-container {
    position: static;
}

#language-selector {
    padding: 8px 12px;
    border-radius: 5px;
    border: none;
    background-color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    color: #2c3e50;
}

#language-selector:hover {
    background-color: white;
}

.profile-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #ecf0f1;
    margin-bottom: 20px;
}

h1 {
    margin: 0;
    font-size: 2.5em;
}

.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    /* Prepare for 3D Tilt */
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* Card Hover Animation - modified to be handled by JS for tilt, 
   but keep simple hover for non-js scenarios or as fallback */
.card:hover {
    box-shadow: 0 15px 30px var(--shadow-color);
    /* transform handled by JS for tilt effect */
}

.card h2 {
    margin-top: 0;
    color: var(--text-color);
}

.project-tech {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tech-badge {
    background-color: var(--bg-color);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--primary-color);
    transition: background-color 0.3s, color 0.3s;
}

.card p {
    color: var(--text-muted);
    line-height: 1.6;
    flex-grow: 1;
}

.card span.link-text {
    margin-top: 20px;
    color: var(--primary-color);
    font-weight: bold;
}

footer {
    text-align: center;
    padding: 40px 20px;
    background-color: var(--navbar-bg);
    color: white;
    margin-top: 60px;
    transition: background-color 0.3s;
}

.social-links {
    margin-bottom: 20px;
}

.social-links a {
    color: white;
    margin: 0 15px;
    text-decoration: none;
    font-size: 1.1em;
    font-weight: 500;
    transition: color 0.3s ease;
}

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

/* Section Styles */
.section {
    margin-bottom: 60px;
    padding-top: 60px;
    /* Offset for sticky header */
    margin-top: -60px;
}

.section-title {
    text-align: center;
    font-size: 2em;
    margin-bottom: 30px;
    color: var(--text-color);
    position: relative;
    transition: color 0.3s;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--primary-color);
    margin: 10px auto;
    border-radius: 2px;
}

/* Project Filters */
.project-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 18px;
}

.filter-btn {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1.5px solid var(--primary-color);
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    outline: none;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.filter-btn[data-filter="all"] {
    font-weight: 600;
    border-style: dashed;
}

.filter-btn[data-filter="all"].active {
    background: var(--primary-color);
    color: #fff;
    border-style: solid;
}

/* Skills Grid */
.skills-grid {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
}

.skills-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    font-size: 0.9em;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.skill-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot-advanced {
    background-color: #2ecc71;
}

/* Green */
.dot-intermediate {
    background-color: #f1c40f;
}

/* Yellow */
.dot-beginner {
    background-color: #3498db;
}

/* Blue */

.skill-card {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 4px 6px var(--shadow-color);
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, background-color 0.3s, color 0.3s;
    position: relative;
}

.skill-card i {
    font-size: 1.2em;
}

/* Contact Section Styles */
.contact-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 30px;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: background-color 0.3s;
}

#contact-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    transition: color 0.3s;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--bg-color);
    /* Matches theme background */
    color: var(--text-color);
    transition: all 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.contact-button {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    margin-top: 10px;
    width: 100%;
    /* Full width button */
}

.contact-button:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

.form-status {
    text-align: center;
    margin-top: 15px;
    font-weight: 500;
    min-height: 24px;
}

.success-message {
    color: #2ecc71;
}

.error-message {
    color: #e74c3c;
}

/* Typing Animation */
.typed-text {
    color: var(--primary-color);
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.cursor {
    display: inline-block;
    background-color: var(--text-color);
    width: 3px;
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* CTA Buttons in Header */
.header-buttons {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 30px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 160px;
    background-color: white;
    color: #2c3e50;
    border: 2px solid white;
}

.cta-button:hover {
    background-color: transparent;
    color: white;
}

/* Timeline Styles */
.timeline-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
}

/* The vertical line */
.timeline-container::after {
    content: '';
    position: absolute;
    width: 4px;
    background-color: var(--primary-color);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -2px;
    border-radius: 2px;
}

/* Timeline card container */
.timeline-item {
    padding: 10px 40px;
    position: relative;
    background-color: transparent;
    width: 50%;
    box-sizing: border-box;
}

/* Place items on left and right */
.timeline-item.left {
    left: 0;
    text-align: right;
}

.timeline-item.right {
    left: 50%;
    text-align: left;
}

/* The circle on the timeline */
.timeline-item::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    right: -10px;
    background-color: var(--card-bg);
    border: 4px solid var(--primary-color);
    top: 20px;
    border-radius: 50%;
    z-index: 1;
    transition: background-color 0.3s, border-color 0.3s;
}

/* Fix circle position for right items */
.timeline-item.right::after {
    left: -10px;
}

/* Actual content box */
.timeline-content {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: background-color 0.3s, color 0.3s, transform 0.3s;
    color: var(--text-color);
}

.timeline-content:hover {
    transform: translateY(-5px);
}

.timeline-date {
    font-size: 0.9em;
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
}

.timeline-content h3 {
    margin: 0 0 5px 0;
    color: var(--text-color);
}

.timeline-content h4 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: var(--text-muted);
    font-weight: 500;
}

.timeline-content p {
    margin: 0;
    font-size: 0.95em;
    line-height: 1.5;
    color: var(--text-muted);
}

/* Responsive Timeline for Mobile */
@media screen and (max-width: 768px) {
    .timeline-container::after {
        left: 31px;
    }

    .timeline-item {
        width: 100%;
        padding-left: 70px;
        padding-right: 25px;
    }

    .timeline-item.left,
    .timeline-item.right {
        left: 0;
        text-align: left;
    }

    .timeline-item.left::after,
    .timeline-item.right::after {
        left: 21px;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    /* Initially hidden but layout-ready */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;

    /* Animation props */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s, background-color 0.3s;
}

.back-to-top:hover {
    background-color: #2980b9;
    transform: translateY(-5px);
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 404 Page Styles */
.page-404 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--background, #181c1f);
    color: var(--text, #e0e0e0);
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
}

.page-404 .error-container {
    text-align: center;
    padding: 40px 24px;
}

.page-404 .error-code {
    font-size: 7rem;
    font-weight: bold;
    color: var(--primary, #27ae60);
    margin-bottom: 0.2em;
}

.page-404 .error-message {
    font-size: 2rem;
    margin-bottom: 0.5em;
}

.page-404 .error-desc {
    font-size: 1.2rem;
    margin-bottom: 2em;
    color: var(--text-muted, #aaa);
}

.page-404 .back-btn {
    display: inline-block;
    padding: 12px 32px;
    background: var(--primary, #27ae60);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

.page-404 .back-btn:hover {
    background: #219150;
}

.page-404 .emoji {
    font-size: 3rem;
    margin-bottom: 0.5em;
    display: block;
}

#project-search {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    font-size: 1em;
    transition: background 0.3s, color 0.3s, border-color 0.3s;
}

#project-search:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.2);
}

.search-input-wrapper {
    position: relative;
    display: inline-block;
}

#clear-project-search {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted, #aaa);
    font-size: 1.2em;
    cursor: pointer;
    padding: 0;
    z-index: 2;
    transition: color 0.2s;
}

#clear-project-search:hover {
    color: var(--primary-color);
}

#project-search:not(:placeholder-shown)+#clear-project-search,
#project-search:focus+#clear-project-search {
    display: block;
}

/* Project Filter Multi-Select Styles */
#project-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 18px;
}

#project-filters .filter-btn {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1.5px solid var(--primary-color);
    border-radius: 6px;
    padding: 7px 18px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    outline: none;
}

#project-filters .filter-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

#project-filters .filter-btn[data-filter="all"] {
    font-weight: 600;
    border-style: dashed;
}

#project-filters .filter-btn[data-filter="all"].active {
    background: var(--primary-color);
    color: #fff;
    border-style: solid;
}

/* Prev/Next Pagination Buttons */
.projects-pagination-btn,
#projects-prev,
#projects-next {
    background: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 6px;
    padding: 10px 28px;
    font-size: 1.1em;
    font-weight: 600;
    margin: 0 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s;
    outline: none;
    letter-spacing: 0.5px;
}

#projects-prev:disabled,
#projects-next:disabled {
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7;
}

#projects-prev:hover:not(:disabled),
#projects-next:hover:not(:disabled) {
    background: #27ae60;
    color: #000;
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 4px 16px var(--shadow-color);
}

[data-theme="light"] #projects-prev,
[data-theme="light"] #projects-next {
    background: var(--primary-color);
    color: #000;
}

[data-theme="light"] #projects-prev:disabled,
[data-theme="light"] #projects-next:disabled {
    background: var(--card-bg);
    color: var(--text-muted);
}