/* Layout and Structure */

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

/* Section Styles */
.section {
    padding: 100px 5%;
    position: relative;
}

.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.section-header h2 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 20px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-line {
    width: 60px;
    height: 4px;
    background: var(--gradient-primary);
    margin: 0 auto 20px;
    border-radius: 2px;
}

.section-header p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Grid Systems */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 30px;
}

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

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

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

/* About Section Layout - Enhanced Mobile */
.about-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.about-visual {
    display: flex;
    justify-content: center;
}

.about-text {
    display: flex;
    flex-direction: column;
}

/* Contact Section Layout - Enhanced Mobile */
.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: start;
}

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

/* Footer Layout */
footer {
    background: var(--background-card);
    border-top: 1px solid var(--border-color);
    padding: 40px 5%;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 20px;
}

/* Flexbox utilities */
.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.flex-wrap {
    flex-wrap: wrap;
}

.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.gap-20 { gap: 20px; }
.gap-30 { gap: 30px; }

/* Mobile Responsive Breakpoints */

/* Tablet and Small Laptop */
@media screen and (max-width: 1024px) {
    .section {
        padding: 80px 4%;
    }

    .about-content {
        gap: 40px;
    }

    .contact-content {
        gap: 40px;
    }

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

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

/* Tablet Portrait - CRITICAL MOBILE BREAKPOINT */
@media screen and (max-width: 768px) {
    .container {
        padding: 0 15px !important;
    }

    .section {
        padding: 60px 20px !important;
    }

    .section-header {
        margin-bottom: 40px;
    }

    .section-header p {
        font-size: 1rem;
    }

    /* About Section - FORCE Mobile Layout */
    #about .about-content {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        gap: 30px !important;
        text-align: center;
    }

    #about .about-visual {
        order: -1 !important;
        margin-bottom: 20px;
    }

    #about .about-text {
        order: 1 !important;
        text-align: left;
    }

    /* Contact Section - FORCE Mobile Layout */
    #contact .contact-content {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        gap: 30px !important;
    }

    #contact .contact-info {
        order: -1 !important;
        gap: 20px;
    }

    #contact .contact-form {
        order: 1 !important;
    }

    /* Grid adjustments for mobile */
    .stats-grid {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: center;
        grid-template-columns: none !important;
        gap: 15px;
        max-width: 400px;
        margin: 20px auto 0 auto;
    }

    .stat-item {
        flex: 1;
        min-width: 120px;
        max-width: 150px;
    }

    .skills-grid {
        grid-template-columns: 1fr !important;
        gap: 25px;
    }

    .projects-grid {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }

    .certificates-grid {
        grid-template-columns: 1fr !important;
        gap: 25px;
    }

    /* Footer mobile adjustments */
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    /* Code snippet mobile adjustments */
    .code-snippet {
        max-width: 100% !important;
        width: 100%;
    }

    .code-content {
        font-size: 0.85rem;
        padding: 15px;
    }
}

/* Mobile Portrait */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 12px !important;
    }

    .section {
        padding: 50px 15px !important;
    }

    .section-header {
        margin-bottom: 30px;
    }

    .section-header h2 {
        font-size: clamp(1.8rem, 8vw, 2.5rem);
        margin-bottom: 15px;
    }

    .section-line {
        width: 40px;
        height: 3px;
        margin: 0 auto 15px;
    }

    .section-header p {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    /* About Section - Extra Small Mobile */
    #about .about-content {
        gap: 25px !important;
        padding: 0 5px;
    }

    #about .about-text p {
        font-size: 0.95rem;
        line-height: 1.6;
        margin-bottom: 20px;
    }

    /* Contact Section - Extra Small Mobile */
    #contact .contact-content {
        gap: 25px !important;
        padding: 0 5px;
    }

    #contact .contact-info {
        gap: 15px;
    }

    /* Stats grid - Stack vertically on small screens */
    .stats-grid {
        display: flex !important;
        flex-direction: column !important;
        align-items: center;
        max-width: 200px !important;
        margin: 20px auto 0 auto !important;
        gap: 12px !important;
    }

    .stat-item {
        width: 100% !important;
        max-width: 180px !important;
        padding: 15px 20px !important;
    }

    .stat-number {
        font-size: 2rem !important;
    }

    .stat-label {
        font-size: 0.85rem !important;
    }

    /* Code snippet adjustments */
    .code-snippet {
        margin: 0 !important;
    }

    .code-content {
        font-size: 0.75rem !important;
        padding: 12px !important;
        line-height: 1.4;
    }

    .code-indent {
        padding-left: 12px !important;
    }

    /* Contact items mobile */
    .contact-item {
        flex-direction: column !important;
        text-align: center !important;
        padding: 20px 15px !important;
    }

    .contact-icon {
        margin-bottom: 10px;
    }

    /* Reduce gaps for small screens */
    .skills-grid,
    .projects-grid,
    .certificates-grid {
        gap: 20px;
    }
}

/* Extra Small Mobile (iPhone SE, etc.) */
@media screen and (max-width: 375px) {
    .container {
        padding: 0 10px !important;
    }

    .section {
        padding: 40px 10px !important;
    }

    .section-header {
        margin-bottom: 25px;
    }

    #about .about-content {
        gap: 20px !important;
    }

    #contact .contact-content {
        gap: 20px !important;
    }

    .stats-grid {
        max-width: 160px !important;
        gap: 10px !important;
    }

    .stat-item {
        padding: 12px 15px !important;
    }

    .stat-number {
        font-size: 1.8rem !important;
    }

    .stat-label {
        font-size: 0.8rem !important;
    }

    .skills-grid,
    .projects-grid,
    .certificates-grid {
        gap: 15px;
    }

    .code-content {
        font-size: 0.7rem !important;
        padding: 10px !important;
    }

    .code-header {
        padding: 8px 10px !important;
    }
}

/* Landscape Mobile - Keep some desktop elements */
@media screen and (max-width: 812px) and (orientation: landscape) and (max-height: 500px) {
    .section {
        padding: 40px 3%;
    }

    #about .about-content {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        flex-direction: row !important;
        gap: 30px;
        align-items: center;
    }

    #about .about-visual {
        order: 1 !important;
    }

    #about .about-text {
        order: -1 !important;
        text-align: left;
    }

    #contact .contact-content {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        flex-direction: row !important;
        gap: 30px;
    }

    #contact .contact-info {
        order: -1 !important;
    }

    .stats-grid {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center;
        gap: 15px;
        margin-top: 15px;
    }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .section-line {
        transform: translateZ(0);
    }
}

/* Print styles */
@media print {
    .section {
        padding: 20px 0;
        break-inside: avoid;
    }

    .about-content,
    .contact-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .stats-grid,
    .skills-grid,
    .projects-grid,
    .certificates-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

/*!* Debug helper - REMOVE AFTER TESTING *!*/
/*@media screen and (max-width: 768px) {*/
/*    !*#about .about-content {*!*/
/*    !*    outline: 2px solid red;*!*/
/*    !*}*!*/

/*    #contact .contact-content {*/
/*        outline: 2px solid blue;*/
/*    }*/
/*}*/

/* Force layout reset for mobile if other CSS is interfering */
@media screen and (max-width: 768px) {
    .about-content,
    .contact-content {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
    }
}