/* Add these at the top of the file */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    max-width: 100%;
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* Container constraints */
.container,
.main-content,
.about-section,
.services-section,
.projects-section,
.contact-section,
.experience-section,
.education-section {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* Base responsive styles */

/* Extra Large Devices (Large Desktops) */
@media screen and (min-width: 1400px) {
    .container {
        max-width: 1320px;
        margin: 0 auto;
    }

    .projects-grid,
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }

    .profile-image {
        width: 500px;
        height: 500px;
    }

    /* Navbar adjustments for large screens */
    nav {
        padding: 1rem 10%;
    }

    .nav-links {
        gap: 3rem;
    }

    .nav-links a {
        font-size: 1.1rem;
    }
}

/* Large Devices (Desktops & Laptops) */
@media screen and (max-width: 1200px) {
    /* Main content sections padding adjustment */
    .main-content,
    .about-section,
    .services-section,
    .projects-section,
    .contact-section {
        padding: 4rem 5%;
    }

    /* Grid adjustments */
    .projects-grid,
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
        max-width: 900px;
        margin: 0 auto;
    }

    /* Contact info grid */
    .contact-info-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    /* Typography adjustments */
    .title {
        font-size: 3.5rem;
    }

    /* Enhanced grid layouts */
    .education-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    /* Adjust section spacing */
    .section {
        padding: 5rem 8%;
    }

    /* Enhance text readability */
    .timeline-description,
    .service-description,
    .project-description {
        font-size: 0.95rem;
        line-height: 1.7;
    }

    /* Navbar adjustments */
    nav {
        padding: 1rem 5%;
    }

    .nav-links {
        gap: 2.5rem;
    }
}

/* Medium Devices (Tablets) */
@media screen and (max-width: 992px) {
    /* Typography */
    .title {
        font-size: 3rem;
    }

    .about-title,
    .services-title,
    .projects-title,
    .contact-title,
    .experience-title {
        font-size: 2.8rem;
    }

    /* Layout adjustments */
    .main-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2rem;
    }

    .about-section {
        grid-template-columns: 1fr;
        
    }

    /* Profile image */
    .profile-image {
        width: 70%;
        margin: 0 auto;
    }

    /* Button alignment */
    .buttons {
        justify-content: center;
    }

    /* Navigation */
    .nav-links {
        gap: 2rem;
    }

    .logo,
    .theme-toggle {
        min-width: 120px;
    }

    /* Enhanced navbar for tablets */
    nav {
        padding: 0.8rem 4%;
    }

    .nav-links a {
        font-size: 0.95rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    /* Improve navigation spacing */
    .nav-links a {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    /* Enhance card layouts */
    .service-card,
    .project-card {
        padding: 1.75rem;
    }

    /* Adjust timeline */
    .timeline-content {
        padding: 0 1.5rem;
    }

    /* Improve form elements */
    .input-group input,
    .input-group textarea {
        font-size: 0.95rem;
    }
}

/* Small Devices (Mobile Landscape & Small Tablets) */
@media screen and (max-width: 768px) {
    /* Enhanced Mobile Navigation */
    nav {
        padding: 0.8rem 1rem;
        background-color: var(--bg-color);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        height: 100vh;
        width: 100%;
        background-color: var(--bg-color);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: all 0.3s ease-in-out;
        z-index: 100;
        gap: 2rem;
        padding: 2rem;
    }

    .nav-links.active {
        right: 0;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    }

    .nav-links a {
        font-size: 1.1rem;
        width: fit-content;
        padding: 0.5rem 1rem;
        opacity: 0;
        transform: translateX(50px);
        transition: all 0.3s ease;
    }

    .nav-links.active a {
        opacity: 1;
        transform: translateX(0);
    }

    .nav-links a:nth-child(1) {
        transition-delay: 0.1s;
    }
    .nav-links a:nth-child(2) {
        transition-delay: 0.2s;
    }
    .nav-links a:nth-child(3) {
        transition-delay: 0.3s;
    }
    .nav-links a:nth-child(4) {
        transition-delay: 0.4s;
    }
    .nav-links a:nth-child(5) {
        transition-delay: 0.5s;
    }

    /* Enhanced Hamburger Menu */
    .hamburger {
        display: block;
        cursor: pointer;
        z-index: 101;
        padding: 0.5rem;
        margin-right: -0.5rem;
    }

    .hamburger span {
        display: block;
        width: 25px;
        height: 2px;
        background-color: var(--text-color);
        margin: 5px 0;
        transition: all 0.3s ease-in-out;
        transform-origin: center;
    }

    /* Hamburger Animation */
    .hamburger.active span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
        transform: translateX(-20px);
    }

    .hamburger.active span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Logo adjustments */
    .logo {
        font-size: 1.1rem;
        z-index: 101;
    }

    /* Theme toggle adjustments */
    .theme-toggle {
        z-index: 101;
    }

    /* Typography */
    .title {
        font-size: 2.5rem;
    }

    .about-title,
    .services-title,
    .projects-title,
    .contact-title,
    .experience-title {
        font-size: 2.2rem;
    }

    /* Grid layouts */
    .services-grid,
    .projects-grid {
        grid-template-columns: 1fr;
        max-width: 500px;
    }

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

    /* Contact form */
    .form-row {
        grid-template-columns: 1fr;
    }

    .contact-container {
        grid-template-columns: 1fr;
    }

    .contact-image-wrapper {
        display: none;
    }

    /* Experience & Education Timeline Fixes */
    .timeline {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    .timeline::after {
        left: 31px;
        margin: 0;
    }

    /* Force all items to left alignment */
    .timeline-item,
    .timeline-item:nth-child(even),
    .timeline-item:nth-child(odd) {
        width: calc(100% - 70px);
        margin: 0 0 2rem 70px !important;
        padding: 0 15px;
        text-align: left;
        position: relative;
        left: 0 !important;
        right: auto !important;
    }

    /* Reset any desktop positioning */
    .timeline-content {
        margin: 0 !important;
        padding: 1.5rem;
        position: relative;
        left: 0 !important;
        right: auto !important;
        transform: none !important;
    }

    /* Consistent icon positioning */
    .timeline-icon {
        left: -54px !important;
        top: 10px;
        position: absolute;
    }

    /* Reset any transforms or positioning */
    .timeline-item::before,
    .timeline-item::after {
        display: none;
    }

    /* Animation adjustments */
    .timeline-item,
    .timeline-item:nth-child(even),
    .timeline-item:nth-child(odd) {
        opacity: 0;
        transform: translateX(-50px);
        animation: slideInLeft 0.5s ease forwards;
    }

    @keyframes slideInLeft {
        from {
            opacity: 0;
            transform: translateX(-50px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    /* Improve mobile layouts */
    .info-grid {
        gap: 1rem;
    }

    .social-mini-grid {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Services section adjustments */
    .services-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 20px !important;
        padding: 0 15px !important;
    }

    .service-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        flex: none !important;
        display: block !important;
        position: relative !important;
        left: 0 !important;
        transform: none !important;
    }

    /* Reset any grid or float properties */
    .services-section {
        display: block !important;
    }

    /* Ensure proper spacing */
    .service-card + .service-card {
        margin-top: 20px !important;
    }

    /* Reset any columns or grid settings */
    .services-grid > * {
        grid-column: 1 !important;
    }
}

/* Extra Small Devices (Mobile Portrait) */
@media screen and (max-width: 576px) {
    /* Section padding */
    .main-content,
    .about-section,
    .services-section,
    .projects-section,
    .contact-section {
        padding: 3rem 4%;
    }

    /* Typography */
    .title {
        font-size: 2rem;
    }

    .about-title,
    .services-title,
    .projects-title,
    .contact-title,
    .experience-title {
        font-size: 1.8rem;
    }

    /* Profile image */
    .profile-image {
        width: 100%;
    }

    /* Buttons */
    .buttons {
        flex-direction: column;
        gap: 1rem;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    /* Cards and grids */
    .service-card,
    .project-card {
        padding: 1.5rem;
    }

    .project-tech {
        display: none;
    }

    /* Contact form */
    .contact-form-wrapper {
        padding: 1.5rem;
    }

    /* Info items */
    .info-item {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 1rem;
    }

    .info-label::after {
        display: none;
    }

    /* Improve mobile typography */
    .hello {
        font-size: 1rem;
    }

    .section-subtitle {
        font-size: 0.9rem;
    }

    /* Enhance mobile buttons */
    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }

    /* Optimize mobile forms */
    .input-group label {
        font-size: 0.9rem;
    }

    .submit-btn {
        width: 100%;
        justify-content: center;
    }

    /* Improve card layouts */
    .service-number {
        font-size: 2.5rem;
    }

    .service-icon-wrapper {
        width: 36px;
        height: 36px;
    }

    /* Further navbar optimizations */
    nav {
        padding: 0.7rem 1rem;
    }

    .nav-links {
        padding: 1.5rem;
    }

    .nav-links a {
        font-size: 1rem;
        padding: 0.4rem 0.8rem;
    }

    .logo {
        font-size: 1rem;
    }

    .hamburger span {
        width: 22px;
    }

    .timeline::after {
        left: 29px;
    }

    .timeline-item,
    .timeline-item:nth-child(even),
    .timeline-item:nth-child(odd) {
        width: calc(100% - 60px);
        margin-left: 60px !important;
        padding: 0 10px;
    }

    .timeline-icon {
        left: -45px !important;
        width: 30px;
        height: 30px;
    }

    .timeline-content {
        padding: 1.2rem;
    }

    /* Further constrain padding */
    .services-grid,
    .projects-grid,
    .timeline-container,
    .contact-container,
    .form-grid {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Further adjust service cards */
    .services-grid {
        padding: 0 10px !important;
        gap: 15px !important;
    }

    .service-card {
        padding: 15px !important;
    }

    .service-icon-wrapper {
        width: 40px;
        height: 40px;
    }

    .service-title {
        font-size: 1.1rem;
    }

    .service-description {
        font-size: 0.85rem;
    }
}

/* Small Height Devices */
@media screen and (max-height: 600px) {
    .nav-links {
        padding: 1rem;
        gap: 1rem;
        overflow-y: auto;
    }

    .nav-links a {
        padding: 0.3rem 0.6rem;
    }

    .section {
        min-height: auto;
        padding: 3rem 5%;
    }

    .profile-image {
        width: 40%;
    }
}

/* Tablet Specific (iPad Mini & Similar) */
@media screen and (min-width: 768px) and (max-width: 820px) {
    /* Header and navigation */
    .header {
        padding: 1rem 2rem;
    }

    .nav-links {
        gap: 1.5rem;
        font-size: 0.9rem;
    }

    /* Grid layouts */
    .projects-grid,
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
        max-width: 700px;
    }

    /* Profile image */
    .profile-image {
        width: 70%;
    }

    /* Improve tablet layouts */
    .about-section {
        gap: 2rem;
    }

    .timeline-item {
        padding: 1rem 2rem;
    }

    /* Enhance tablet forms */
    .contact-form-wrapper {
        padding: 2rem;
    }
}

/* Landscape Orientation Specific */
@media screen and (max-width: 920px) and (orientation: landscape) {
    .nav-links {
        padding: 1rem 2rem;
        justify-content: flex-start;
        padding-top: 4rem;
        overflow-y: auto;
    }

    .nav-links a {
        font-size: 0.9rem;
        padding: 0.3rem 0.6rem;
    }

    /* Adjust vertical spacing */
    .main-content,
    .about-section,
    .services-section,
    .projects-section,
    .contact-section {
        padding: 3rem 5%;
    }

    /* Adjust navigation menu */
    .nav-links {
        gap: 1.5rem;
    }

    /* Profile image */
    .profile-image {
        width: 50%;
    }

    /* Optimize landscape layout */
    .nav-links.active {
        overflow-y: auto;
    }

    .main-content {
        min-height: auto;
    }

    /* Improve landscape navigation */
    .nav-links a {
        padding: 0.3rem 0;
    }
}

/* High DPI Screens */
@media screen and (-webkit-min-device-pixel-ratio: 2),
    screen and (min-resolution: 192dpi) {
    .profile-image img,
    .project-image img {
        transform: translateZ(0);
    }
}

/* Dark Mode Optimization */
@media (prefers-color-scheme: dark) {
    .nav-links.active {
        background-color: var(--bg-color);
    }

    .hamburger span {
        background-color: var(--text-color);
    }

    nav {
        background-color: var(--bg-color);
    }
}

/* Touch Device Optimization */
@media (hover: none) {
    .nav-links a {
        transition: transform 0.3s ease;
    }

    .nav-links a:active {
        transform: scale(0.95);
    }
}

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

/* Print Styles */
@media print {
    nav,
    .hamburger,
    .theme-toggle,
    .buttons,
    .social-links,
    .contact-form-wrapper {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .main-content,
    .about-section,
    .services-section,
    .projects-section,
    .contact-section {
        padding: 1rem !important;
    }

    .profile-image {
        max-width: 300px !important;
    }

    /* Enhanced print optimization */
    @page {
        margin: 2cm;
    }

    a[href^="http"]:after {
        content: " (" attr(href) ")";
    }

    .timeline::after,
    .timeline-icon,
    .service-icon-wrapper {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Hide navbar items above 1000px */
@media screen and (min-width: 1000px) {
    .nav-links {
        display: none;
    }

    .hamburger {
        display: block !important; /* Show hamburger menu */
    }
}

/* Adjust existing media query */
@media screen and (max-width: 1000px) {
    /* Main content sections padding adjustment */
    .main-content,
    .about-section,
    .services-section,
    .projects-section,
    .contact-section {
        padding: 4rem 5%;
    }

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

    .nav-links a {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    /* Remove image size adjustment from 1000px breakpoint */
    .about-section .profile-image {
        display: none;
    }

    .about-section {
        display: block !important;
        text-align: center;
    }

    .about-content {
        max-width: 600px;
        margin: 0 auto;
    }

    .info-grid {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 1rem;
        margin: 0 auto;
        max-width: 400px;
    }

    .info-item {
        text-align: center;
        padding: 0.5rem 0;
    }

    .project-count {
        text-align: center;
        margin: 2rem auto 0;
    }

    .about-title,
    .about-subtitle,
    .info-label,
    .info-value {
        text-align: center !important;
    }
}

/* New breakpoint for image size at 950px */
@media screen and (max-width: 950px) {
    .profile-section img {
        width: 300px;
        height: auto;
        margin: 0 auto;
    }
}
