/* Small Screen Specific Fixes (320px - 400px) */

/* Global box-sizing fix */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Prevent horizontal overflow */
html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Container fixes for 373px */
@media (max-width: 400px) {
    /* Reset all padding and margins */
    body {
        margin: 0;
        padding: 0;
    }
    
    /* Container adjustments */
    .container {
        width: 100%;
        max-width: 100%;
        padding-left: 12px;
        padding-right: 12px;
        margin: 0;
    }
    
    /* Hero section fixes */
    .hero {
        width: 100vw;
        max-width: 100vw;
        overflow: hidden;
    }
    
    .hero-background {
        width: 100%;
        left: 0;
        right: 0;
    }
    
    .hero-content {
        padding: 0 12px;
        max-width: 100%;
    }
    
    .hero-title {
        font-size: calc(1.3rem + 1vw) !important;
        padding: 0 5px;
        margin-bottom: 0.5rem;
        hyphens: auto;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-subtitle {
        font-size: 0.8rem !important;
        padding: 0 5px;
        line-height: 1.3;
    }
    
    /* Button fixes */
    .hero-buttons {
        width: 100%;
        padding: 0;
        margin-top: 1rem;
    }
    
    .btn {
        width: calc(100% - 24px);
        max-width: none;
        margin: 0.25rem auto;
        font-size: 0.8rem;
        padding: 10px 15px;
    }
    
    /* Navigation fixes */
    .navbar {
        width: 100%;
        padding: 0;
    }
    
    .navbar .container {
        padding: 8px 12px;
        justify-content: space-between;
    }
    
    .nav-brand {
        display: flex;
        align-items: center;
        max-width: 60%;
    }
    
    .nav-brand h1 {
        font-size: 0.95rem;
        white-space: nowrap;
    }
    
    .nav-brand .subtitle {
        font-size: 0.55rem;
    }
    
    .logo-svg {
        width: 24px;
        height: 24px;
        margin-right: 6px;
        flex-shrink: 0;
    }
    
    .nav-toggle {
        padding: 5px;
    }
    
    .nav-toggle span {
        width: 20px;
        height: 2px;
        margin: 3px 0;
    }
    
    /* Section adjustments */
    .section {
        padding: 30px 0 !important;
        overflow: hidden;
    }
    
    .section-header {
        margin-bottom: 1.5rem;
        padding: 0 12px;
    }
    
    .section-title {
        font-size: 1.4rem !important;
        line-height: 1.2;
        word-break: break-word;
    }
    
    .section-subtitle {
        font-size: 0.75rem !important;
    }
    
    /* Card and grid fixes */
    .services-grid,
    .feature-grid,
    .stats-grid,
    .industry-grid,
    .testimonial-grid,
    .benefits-grid {
        width: 100%;
        padding: 0;
        margin: 0;
        gap: 0.75rem !important;
    }
    
    .service-card,
    .feature-card,
    .benefit-card,
    .testimonial-card {
        width: calc(100% - 24px);
        margin: 0 auto;
        padding: 1rem !important;
    }
    
    .service-card h3,
    .feature-card h3 {
        font-size: 1.1rem;
    }
    
    .service-card p,
    .feature-card p {
        font-size: 0.8rem;
        line-height: 1.4;
    }
    
    /* Stats section */
    .stats-section {
        padding: 40px 0 !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0 12px;
    }
    
    .stat-item {
        padding: 0.75rem;
    }
    
    .stat-number {
        font-size: 1.3rem !important;
    }
    
    .stat-label {
        font-size: 0.7rem !important;
        line-height: 1.2;
    }
    
    /* Contact form */
    .contact-grid {
        width: 100%;
        padding: 0;
    }
    
    .contact-form {
        width: calc(100% - 24px);
        margin: 0 auto;
        padding: 1rem !important;
    }
    
    .form-group input,
    .form-group textarea {
        width: 100%;
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Footer fixes */
    .footer {
        padding: 30px 0 15px;
    }
    
    .footer-content {
        padding: 0 12px;
    }
    
    .footer-links {
        font-size: 0.8rem;
        gap: 0.5rem 1rem;
    }
    
    .footer-brand h3 {
        font-size: 1.1rem;
    }
    
    .footer-brand p {
        font-size: 0.75rem;
    }
    
    .footer-bottom {
        font-size: 0.7rem;
        padding: 15px 12px 0;
    }
    
    /* CTA section */
    .cta-section {
        padding: 40px 0 !important;
    }
    
    .cta-title {
        font-size: 1.4rem !important;
        padding: 0 12px;
        line-height: 1.2;
    }
    
    .cta-subtitle {
        font-size: 0.85rem !important;
        padding: 0 12px;
    }
    
    /* Page specific fixes */
    .page-header {
        padding: 70px 0 30px !important;
    }
    
    .page-title {
        font-size: 1.4rem !important;
        padding: 0 12px;
    }
    
    .breadcrumb {
        font-size: 0.7rem;
        padding: 0 12px;
        gap: 0.5rem;
    }
    
    /* Table fixes */
    .info-table,
    .legal-table {
        width: calc(100% - 24px);
        margin: 0 auto;
        font-size: 0.75rem;
    }
    
    .info-table th,
    .info-table td,
    .legal-table th,
    .legal-table td {
        padding: 0.75rem !important;
    }
    
    /* Process steps */
    .process-timeline,
    .process-steps {
        padding: 0 12px;
    }
    
    .step {
        padding: 0 10px;
    }
    
    .step-number {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    
    .step h3 {
        font-size: 0.9rem;
    }
    
    .step p {
        font-size: 0.75rem;
    }
    
    /* Tech stack */
    .tech-stack {
        padding: 0 12px;
        gap: 0.75rem !important;
    }
    
    .tech-item {
        padding: 0.75rem;
    }
    
    .tech-icon {
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
    }
    
    .tech-item span {
        font-size: 0.75rem;
    }
    
    /* About page timeline */
    .timeline-item {
        padding-left: 50px !important;
        padding-right: 12px !important;
    }
    
    .timeline-marker {
        width: 16px;
        height: 16px;
        left: 14px !important;
    }
    
    .timeline::before {
        left: 22px;
    }
    
    .timeline-content h3 {
        font-size: 1rem;
    }
    
    .timeline-content p {
        font-size: 0.8rem;
    }
    
    /* Service detail cards */
    .service-detail {
        width: calc(100% - 24px);
        margin: 0 auto 1.5rem;
        padding: 1.5rem !important;
    }
    
    .service-number {
        font-size: 2rem !important;
    }
    
    .service-detail-header h2 {
        font-size: 1.3rem;
    }
    
    .service-description {
        font-size: 0.85rem !important;
    }
    
    /* Case study cards */
    .case-study {
        width: calc(100% - 24px);
        margin: 0 auto 1.5rem;
    }
    
    .case-study-header {
        padding: 1.5rem;
    }
    
    .case-category {
        font-size: 0.75rem;
        padding: 0.2rem 0.75rem;
    }
    
    .case-study-header h3 {
        font-size: 1.2rem;
    }
    
    .case-study-content {
        padding: 1.5rem !important;
    }
    
    /* Position cards */
    .position-card {
        width: calc(100% - 24px);
        margin: 0 auto 1.5rem;
    }
    
    .position-header {
        padding: 1.5rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .position-header h3 {
        font-size: 1.2rem;
    }
    
    .position-content {
        padding: 1.5rem !important;
    }
    
    /* Legal content */
    .legal-content {
        padding: 0 12px;
    }
    
    .policy-section h2 {
        font-size: 1.2rem;
    }
    
    .contact-info-box {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    /* Prevent any element from causing overflow */
    * {
        max-width: 100% !important;
    }
    
    /* Hide horizontal scrollbar if it appears */
    *::-webkit-scrollbar:horizontal {
        display: none;
    }
}

/* iPhone SE and similar devices (375px) */
@media (min-width: 371px) and (max-width: 379px) {
    .hero-title {
        font-size: 1.6rem !important;
    }
    
    .btn {
        width: calc(100% - 30px);
    }
}