@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Open+Sans&family=Roboto&display=swap');

/* CSS Variables for Light/Dark Mode */
:root {
    /* Light mode colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
    --hero-overlay: rgba(0, 0, 0, 0.5);
    --navbar-bg: #ffffff;
    --button-primary: #007bff;
    --button-primary-hover: #0056b3;
    --link-color: #007bff;
    --link-hover: #0056b3;
}

/* Dark mode colors */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --border-color: #404040;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --card-bg: #2d2d2d;
    --hero-overlay: rgba(0, 0, 0, 0.7);
    --navbar-bg: #1a1a1a;
    --button-primary: #0d6efd;
    --button-primary-hover: #0b5ed7;
    --link-color: #66b3ff;
    --link-hover: #80c4ff;
}

/* General Body and Typography */
body {
    font-family: 'Open Sans', sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Ensure body takes at least full viewport height */
    overflow-x: hidden; /* Hide horizontal scroll bar */
    position: relative; /* Prevent horizontal scroll on mobile */
    width: 100%; /* Ensure body doesn't exceed viewport width */
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.display-3, .display-4 {
    font-family: 'Roboto', sans-serif;
}

/* Hero Section */
.hero-section {
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    /* Dark mode adaptive gradient background */
    background: linear-gradient(135deg,
        var(--button-primary) 0%,
        var(--link-color) 50%,
        var(--button-primary-hover) 100%);
}

.hero-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--hero-overlay);
    z-index: 1;
    transition: background 0.3s ease;
}

.hero-section > .container {
    position: relative;
    z-index: 2;
}

/* Light mode hero gradient */
:root:not([data-theme="dark"]) .hero-section {
    background: linear-gradient(135deg, #007bff 0%, #00bcd4 50%, #0056b3 100%);
}

/* Dark mode hero gradient */
[data-theme="dark"] .hero-section {
    background: linear-gradient(135deg, #0d6efd 0%, #66b3ff 50%, #0b5ed7 100%);
}

.profile-photo-hero {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border: 5px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn-primary {
    background-color: var(--button-primary);
    border-color: var(--button-primary);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: var(--button-primary-hover);
    border-color: var(--button-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.btn-outline-light {
    border-color: rgba(255, 255, 255, 0.7);
    color: white;
    transition: all 0.3s ease;
}

.btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
}

/* Social Links */
.social-links a {
    display: inline-block; /* Use inline-block for simpler layout */
    width: 50px;
    height: 50px;
    line-height: 50px; /* Vertically center text/icons */
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    margin: 0 10px; /* Slightly more spacing */
    color: white;
    text-align: center; /* Horizontally center text/icons */
    transition: all 0.3s ease;
}

.social-links a:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

/* Quick Stats Section */
#stats {
    background-color: var(--bg-secondary);
    transition: background-color 0.3s ease;
}

#stats .p-4 {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    color: var(--text-primary);
}

#stats .p-4:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px var(--shadow-color) !important;
}

#stats .text-primary { color: var(--button-primary) !important; }
#stats .text-success { color: #28a745 !important; }
#stats .text-info { color: #17a2b8 !important; }

/* About Section Preview */
#about-preview img {
    max-height: 400px;
    object-fit: cover;
}

/* Animations (AOS, GSAP will handle most, but some custom CSS animations) */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in-element {
    animation: fadeIn 1s ease-out forwards;
}

/* General Section Padding */
section {
    padding: 80px 0;
}

/* Navigation Fonts */
.navbar-nav .nav-link {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500; /* Medium weight for regular links */
    color: var(--text-primary); /* Dynamic color for theme */
    transition: all 0.3s ease; /* Smooth transition for hover effects */
}

.navbar-nav .nav-link:hover {
    color: var(--link-hover); /* Change color on hover */
    transform: translateY(-2px); /* Subtle lift effect */
}

.navbar-nav .nav-link.active {
    font-weight: 700; /* Bold for active link */
    color: var(--button-primary) !important; /* Use theme primary color for active state */
    background-color: rgba(13, 110, 253, 0.15) !important; /* Better contrast background highlight */
    border-radius: 4px; /* Rounded corners for active indicator */
    padding: 8px 12px !important; /* Better padding for visibility */
    margin: 2px 4px; /* Better spacing */
    border: 1px solid rgba(13, 110, 253, 0.25) !important; /* Subtle border for definition */
}

/* Dark mode navbar toggler icon */
[data-theme="dark"] .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Light mode navbar toggler icon */
:root:not([data-theme="dark"]) .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(0, 0, 0, 0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Enhanced navbar toggler button styling */
.navbar-toggler {
    border: 2px solid var(--text-primary) !important;
    background-color: transparent !important;
    transition: all 0.3s ease;
}

.navbar-toggler:hover {
    background-color: var(--bg-secondary) !important;
    border-color: var(--link-hover) !important;
    transform: scale(1.05);
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25) !important;
}

/* Compact Modern Theme Toggle Button - Simple Flexbox */
.theme-toggle-btn,
button.theme-toggle-btn,
header button.theme-toggle-btn,
.theme-toggle-btn.btn,
.navbar .theme-toggle-btn {
    background: transparent !important;
    border: 2px solid var(--text-primary) !important;
    border-radius: 50px !important;
    width: 45px !important;
    height: 22px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    opacity: 1 !important;
    margin: 0 10px !important;
    padding: 0 !important;
}

.theme-toggle-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    border-color: var(--link-hover) !important;
}

.theme-toggle-btn:active {
    transform: translateY(0) scale(0.95);
}

.theme-toggle-track {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-thumb {
    position: absolute;
    width: 16px !important;
    height: 16px !important;
    background: var(--text-primary) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: none !important;
}

/* Light mode - thumb on left */
:root:not([data-theme="dark"]) .theme-toggle-thumb {
    transform: translateX(-10px) !important;
}

/* Dark mode - thumb on right */
[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(10px) !important;
}

.theme-icon {
    font-size: 10px !important;
    transition: all 0.3s ease !important;
    position: absolute !important;
    color: var(--bg-primary) !important;
}

/* Light mode icons */
:root:not([data-theme="dark"]) .moon-icon {
    opacity: 1;
    color: var(--bg-primary);
}

:root:not([data-theme="dark"]) .sun-icon {
    opacity: 0;
    color: var(--bg-primary);
}

/* Dark mode icons */
[data-theme="dark"] .moon-icon {
    opacity: 0;
    color: var(--bg-primary);
}

[data-theme="dark"] .sun-icon {
    opacity: 1;
    color: var(--bg-primary);
}

/* Mobile responsiveness for theme toggle */
@media (max-width: 768px) {
    .theme-toggle-btn {
        width: 40px !important;
        height: 20px !important;
    }

    .theme-toggle-thumb {
        width: 14px !important;
        height: 14px !important;
    }

    :root:not([data-theme="dark"]) .theme-toggle-thumb {
        transform: translateX(-9px) !important;
    }

    [data-theme="dark"] .theme-toggle-thumb {
        transform: translateX(9px) !important;
    }

    .theme-icon {
        font-size: 9px !important;
    }
}

/* Chart Container Styling */
.chart-container {
    position: relative;
    height: 400px; /* Explicit height for the chart container */
    min-height: 300px;
    width: 100%;
}


footer {
    margin-top: auto; /* Pushes the footer to the bottom in a flex container */
}

/* Mobile-specific fixes to prevent horizontal scrolling */
@media (max-width: 768px) {
    /* Prevent horizontal scroll on all elements */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Ensure images don't cause overflow */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Fix container widths and ensure proper mobile padding */
    .container, .container-fluid {
        width: 100%;
        padding-left: 15px;
        padding-right: 15px;
        margin-left: auto;
        margin-right: auto;
        max-width: 100%;
    }

    /* Prevent social links from causing overflow */
    .social-links {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 15px;
        width: 100%;
        padding: 0 10px;
    }

    .social-links a {
        margin: 0;
        flex-shrink: 0;
        width: 45px;
        height: 45px;
        line-height: 45px;
        font-size: 1.2rem;
    }

    /* Fix hero section on mobile */
    .hero-section {
        min-height: 90vh;
        width: 100%;
        position: relative;
        padding: 20px 0;
    }

    .hero-section h1 {
        font-size: 2.2em !important;
        word-wrap: break-word;
        margin: 0 10px 20px 10px;
        line-height: 1.2;
    }

    .hero-section .lead {
        font-size: 1.1rem !important;
        margin: 0 10px 30px 10px;
        line-height: 1.4;
    }

    .profile-photo-hero {
        width: 120px;
        height: 120px;
        margin-bottom: 20px;
    }

    /* Fix button layout on mobile */
    .d-grid.gap-2.d-sm-flex {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100%;
        margin: 0 10px;
    }

    .d-grid.gap-2.d-sm-flex .btn {
        width: 100%;
        margin: 0;
        padding: 12px 20px;
        font-size: 1rem;
    }

    /* Fix stats section cards */
    #stats .col-md-4 {
        margin-bottom: 30px;
    }

    #stats .p-4 {
        padding: 30px 20px !important;
    }

    #stats .fas {
        font-size: 2.5rem !important;
    }

    #stats .display-4 {
        font-size: 2.5rem !important;
    }

    section {
        padding: 60px 0;
        width: 100%;
        position: relative;
    }

    /* Ensure all sections stay within bounds */
    section .container {
        max-width: 100%;
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Fix navigation on mobile */
    .navbar-nav .nav-link {
        padding: 10px 15px !important;
        margin: 5px 0 !important;
        text-align: center;
        border-radius: 5px;
    }

    .navbar-nav .nav-link.active {
        margin: 5px 0 !important;
        padding: 10px 15px !important;
    }

    /* Fix modal responsiveness */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
        width: 100% !important;
    }

    .modal-content {
        border-radius: 10px;
    }

    .modal-body {
        padding: 20px 15px;
    }

    /* Fix form elements in modals */
    .modal-body .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .modal-body .btn {
        padding: 12px 20px;
        font-size: 1rem;
    }

    /* Fix about section preview */
    #about-preview img {
        max-height: 300px;
        margin-top: 20px;
    }

    #about-preview .display-4 {
        font-size: 2rem;
    }

    #about-preview .lead {
        font-size: 1rem;
    }
}

/* Badge styling for projects page */
.badge {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    transition: all 0.3s ease !important;
    font-size: 0.8em !important;
    padding: 0.375rem 0.75rem !important;
}

.badge:hover {
    background-color: var(--button-primary) !important;
    color: var(--bg-primary) !important;
    border-color: var(--button-primary) !important;
    transform: translateY(-1px);
}

/* Dark mode badge enhancements */
[data-theme="dark"] .badge {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

[data-theme="dark"] .badge:hover {
    background-color: var(--button-primary) !important;
    color: var(--bg-primary) !important;
    border-color: var(--button-primary) !important;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3) !important;
}

/* Light mode badge enhancements */
:root:not([data-theme="dark"]) .badge {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

:root:not([data-theme="dark"]) .badge:hover {
    background-color: var(--button-primary) !important;
    color: var(--bg-primary) !important;
    border-color: var(--button-primary) !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.25) !important;
}

/* Extra small devices */
@media (max-width: 480px) {
    .hero-section h1 {
        font-size: 1.8em !important;
        margin: 0 5px 15px 5px !important;
    }

    .hero-section .lead {
        font-size: 1rem !important;
        margin: 0 5px 25px 5px !important;
    }

    .profile-photo-hero {
        width: 100px;
        height: 100px;
        margin-bottom: 15px;
    }

    /* Ensure no element can cause horizontal scroll */
    body, html {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Smaller social links for very small screens */
    .social-links a {
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 1rem;
    }

    /* Smaller buttons for very small screens */
    .d-grid.gap-2.d-sm-flex .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    /* Adjust stats section for very small screens */
    #stats .fas {
        font-size: 2rem !important;
    }

    #stats .display-4 {
        font-size: 2rem !important;
    }

    #stats .p-4 {
        padding: 25px 15px !important;
    }

    /* Smaller section padding for very small screens */
    section {
        padding: 40px 0;
    }

    /* Smaller navigation links */
    .navbar-nav .nav-link {
        padding: 8px 12px !important;
        font-size: 0.9rem;
    }

    .navbar-nav .nav-link.active {
        padding: 8px 12px !important;
    }

    /* Fix navbar brand for very small screens */
    .navbar-brand {
        font-size: 1.1rem;
    }

    .navbar-brand img {
        height: 35px;
    }

    /* Fix theme toggle for very small screens */
    .theme-toggle-btn {
        width: 35px !important;
        height: 18px !important;
        margin: 0 5px !important;
    }

    .theme-toggle-thumb {
        width: 12px !important;
        height: 12px !important;
    }

    :root:not([data-theme="dark"]) .theme-toggle-thumb {
        transform: translateX(-8px) !important;
    }

    [data-theme="dark"] .theme-toggle-thumb {
        transform: translateX(8px) !important;
    }

    .theme-icon {
        font-size: 8px !important;
    }
}

/* Safari and Android Browser Compatibility Fixes */
@supports (-webkit-appearance: none) {
    /* Safari-specific fixes */
    .hero-section {
        -webkit-backface-visibility: hidden;
        -webkit-transform: translateZ(0);
    }

    .profile-photo-hero {
        -webkit-user-drag: none;
        -khtml-user-drag: none;
        -moz-user-drag: none;
        -o-user-drag: none;
        user-drag: none;
    }

    /* Fix for Safari button hover states */
    .btn-primary:hover {
        -webkit-transform: translateY(-2px);
        transform: translateY(-2px);
    }

    /* Fix for Safari flexbox issues */
    .social-links {
        -webkit-box-align: center;
        -webkit-box-pack: center;
        display: -webkit-box;
        display: flex;
    }

    /* Fix for Safari theme toggle */
    .theme-toggle-btn {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Android browser specific fixes */
@media screen and (max-width: 768px) {
    /* Fix for Android Chrome input zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
        -webkit-appearance: none;
        border-radius: 0;
    }

    /* Fix for Android button tap highlight */
    .btn,
    .nav-link,
    .theme-toggle-btn {
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Fix for Android navbar collapse */
    .navbar-collapse {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }

    /* Fix for Android modal scrolling */
    .modal {
        -webkit-overflow-scrolling: touch;
    }

    /* Fix for Android theme toggle touch */
    .theme-toggle-btn {
        touch-action: manipulation;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari input fixes */
    input,
    textarea,
    select {
        -webkit-appearance: none;
        -webkit-border-radius: 0;
        border-radius: 0;
    }

    /* iOS Safari viewport height fix */
    .hero-section {
        min-height: -webkit-fill-available;
    }

    /* iOS Safari smooth scrolling */
    body {
        -webkit-overflow-scrolling: touch;
    }

    /* iOS Safari button reset */
    .btn {
        -webkit-appearance: none;
        border-radius: 0;
    }

    /* iOS Safari theme toggle fix */
    .theme-toggle-btn {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
    }
}

/* General mobile browser performance optimizations */
@media (max-width: 768px) {
    /* Force hardware acceleration for smooth animations */
    .hero-section,
    .profile-photo-hero,
    .btn,
    .theme-toggle-btn,
    .social-links a {
        -webkit-transform: translateZ(0);
        -moz-transform: translateZ(0);
        -ms-transform: translateZ(0);
        -o-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        -moz-backface-visibility: hidden;
        -ms-backface-visibility: hidden;
        -o-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    /* Optimize animations for mobile */
    * {
        -webkit-animation-fill-mode: both !important;
        animation-fill-mode: both !important;
    }

    /* Fix for mobile browser text selection */
    .navbar-nav .nav-link,
    .btn,
    .theme-toggle-btn {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* High Priority Code Block Fixes - Placed at end of file to override everything */
pre code,
pre .blog-display-inline-code,
.blog-display-code-block code,
.blog-display-code-block .blog-display-inline-code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    font-family: inherit !important;
    white-space: pre !important;
    display: inline !important;
}

/* Ensure pre itself is styled correctly */
pre, .blog-display-code-block {
    background: #1e1e1e !important;
    color: #d4d4d4 !important;
    padding: 15px !important;
    border-radius: 8px !important;
    overflow-x: auto !important;
    font-family: 'Consolas', 'Monaco', monospace !important;
    line-height: 1.5 !important;
}
