/* ==========================================================================
   Responsive Design - Mobile First Approach
   ========================================================================== */

/* Extra Large Devices (Large Desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }
    
    .hero-title {
        font-size: 4rem;
    }
    
    .section-title {
        font-size: 3rem;
    }
    
    .solutions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large Devices (Desktops, 992px and up) */
@media (max-width: 1199px) {
    .hero-title {
        font-size: 3rem;
    }
    
    .solutions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium Devices (Tablets, 768px and up) */
@media (max-width: 991px) {
    :root {
        --section-padding: 4rem 0;
        --grid-gap: 1.5rem;
    }
    
    .nav-list {
        gap: 1.5rem;
    }
    
    .hero-section {
        padding: 6rem 0 4rem;
        min-height: 90vh;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-subtitle {
        font-size: 1.125rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }
    
    .hero-buttons .btn {
        width: 220px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .code-animation {
        padding: 2rem;
        font-size: 0.9rem;
        max-width: 500px;
    }
    
    .floating-element {
        display: none;
    }
    
    .features-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    
    .features-text {
        order: 2;
    }
    
    .features-image {
        order: 1;
    }
    
    .contact-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    
    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small Devices (Landscape Phones, 576px and up) */
@media (max-width: 767px) {
    :root {
        --section-padding: 3rem 0;
        --container-padding: 0 1rem;
    }
    
    .nav-container {
        padding: 0 1rem;
    }
    
    .nav-menu {
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        padding: 1rem 0;
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        box-shadow: var(--shadow-lg);
        z-index: 1000;
    }
    
    .nav-menu.active {
        transform: translateY(0);
    }
    
    .nav-list {
        flex-direction: column;
        gap: 0;
    }
    
    .nav-item {
        width: 100%;
    }
    
    .nav-link {
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    .dropdown-menu {
        position: static;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        margin: 0;
        opacity: 1;
        transform: none;
        display: none;
    }
    
    .dropdown-menu.active {
        display: block;
    }
    
    .dropdown-link {
        padding: 0.75rem 2rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .navbar.mobile-active .mobile-menu-toggle span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .navbar.mobile-active .mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
    }
    
    .navbar.mobile-active .mobile-menu-toggle span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    .hero-section {
        padding: 4rem 0 3rem;
        min-height: 80vh;
    }
    
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
    
    .code-animation {
        padding: 1.5rem;
        font-size: 0.85rem;
        max-width: 100%;
        margin: 0 1rem;
    }
    
    .section-title {
        font-size: 2rem;
    }
    
    .section-subtitle {
        font-size: 1rem;
    }
    
    .solutions-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .solution-card {
        padding: 1.5rem;
    }
    
    .solution-card h3 {
        font-size: 1.25rem;
    }
    
    .solution-tech {
        flex-wrap: wrap;
    }
    
    .tech-tag {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .features-text h2 {
        font-size: 1.75rem;
    }
    
    .feature-item {
        padding: 1rem;
    }
    
    .feature-item h4 {
        font-size: 1.125rem;
    }
    
    .stats-card {
        padding: 1.5rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .tech-grid {
        grid-template-columns: 1fr;
    }
    
    .tech-category {
        padding: 1.5rem;
    }
    
    .tech-category h3 {
        font-size: 1.25rem;
    }
    
    .contact-form {
        padding: 1.5rem;
    }
    
    .contact-item {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .contact-icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
    
    .footer {
        padding: 2rem 0 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .footer-legal {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .back-to-top {
        right: 1rem;
        bottom: 1rem;
        width: 3rem;
        height: 3rem;
        font-size: 1rem;
    }
}

/* Extra Small Devices (Portrait Phones, less than 576px) */
@media (max-width: 575px) {
    :root {
        --section-padding: 2.5rem 0;
        --container-padding: 0 0.75rem;
    }
    
    .hero-title {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    .hero-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
    
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .hero-buttons .btn {
        width: 100%;
        max-width: 280px;
    }
    
    .solution-card {
        padding: 1.25rem;
    }
    
    .solution-icon {
        font-size: 2rem;
    }
    
    .feature-item {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .feature-icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
    
    .tech-item {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .code-animation {
        padding: 1.25rem;
        font-size: 0.8rem;
        margin: 0 0.5rem;
    }
    
    .floating-element {
        display: none;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 3rem 0 2rem;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .code-animation {
        display: none;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .solution-card,
    .stats-card,
    .tech-category,
    .contact-form {
        border-width: 0.5px;
    }
}

/* Print styles */
@media print {
    .navbar,
    .back-to-top,
    .contact-form,
    .hero-buttons {
        display: none !important;
    }
    
    .hero-section {
        background: none !important;
        color: #000 !important;
        padding: 2rem 0 !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
        background: #fff;
    }
    
    .container {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        color: #000;
    }
    
    .solution-card,
    .tech-category {
        page-break-inside: avoid;
        border: 1px solid #ddd;
        margin-bottom: 1rem;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .code-line {
        opacity: 1;
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .navbar {
        background-color: rgba(15, 23, 42, 0.95);
    }
    
    .navbar.scrolled {
        background-color: rgba(15, 23, 42, 0.98);
    }
    
    .nav-menu {
        background-color: var(--bg-card);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --border-hover: #000;
        --text-secondary: #000;
    }
    
    .btn-outline {
        border-width: 2px;
    }
    
    .solution-card,
    .stats-card,
    .tech-category,
    .contact-form {
        border-width: 2px;
        border-color: #000;
    }
}

/* Focus styles for accessibility */
.btn:focus,
.nav-link:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.back-to-top:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: var(--text-white);
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
}

.skip-link:focus {
    top: 6px;
}

/* SQL2Excel Mobile Optimization */
@media (max-width: 768px) {
    /* Force hide Excel demo on mobile */
    section.excel-hero .solution-hero-demo,
    section.solution-hero .solution-hero-demo,
    .solution-hero-demo,
    .excel-preview,
    .excel-header,
    .excel-content,
    .excel-tabs,
    .excel-tab,
    .excel-row,
    .excel-cell {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        width: 0 !important;
        overflow: hidden !important;
    }
    
    /* Optimize layout when demo is hidden */
    section.excel-hero .solution-hero-content,
    section.solution-hero .solution-hero-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        grid-template-columns: none !important;
    }
    
    section.excel-hero .solution-hero-text,
    section.solution-hero .solution-hero-text {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 1rem !important;
    }
}