/* Responsive Container Base */
.responsive-container {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0 auto;
    overflow: visible;
}

/* Mobile-Optimized Form */
.mobile-optimized-form {
    width: 100%;
    max-width: 100%;
}

/* iOS Safari zoom prevention - target iOS devices specifically */
@supports (-webkit-touch-callout: none) {
    input,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    textarea,
    select,
    button {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
    }
}

/* Mobile-specific fixes */
@media screen and (max-width: 768px) {
    .responsive-container {
        padding: 0.5rem;
    }
    
    .mobile-optimized-form {
        padding: 0;
    }
    
    input,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px !important;
        -webkit-appearance: none;
        -webkit-text-size-adjust: 100%;
        transform-origin: left top;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Prevent zoom on focus for iOS */
    input:focus,
    textarea:focus,
    select:focus {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
    }
    
    /* Better button sizing on mobile */
    button[type="submit"] {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1rem 1.5rem !important;
        font-size: 1rem !important;
    }
}

/* Tablet responsiveness */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .responsive-container {
        max-width: 600px;
        padding: 1rem;
    }
}

/* Desktop responsiveness */
@media screen and (min-width: 1025px) {
    .responsive-container {
        max-width: 450px;
    }
}

/* Flux UI component override to ensure consistent sizing */
[data-flux-input] input,
[data-flux-select] select {
    font-size: 16px !important;
    width: 100%;
}

.captive-portal-wrapper {
    width: 100%;
    overflow-y: auto;
    position: relative;
}

/* Vertical height responsiveness */
@media screen and (max-height: 700px) {
    .mobile-optimized-form {
        gap: 0.5rem;
    }
    
    .mobile-optimized-form > * {
        margin-bottom: 0.5rem !important;
    }
    
    input, select, textarea {
        padding: 0.5rem !important;
        min-height: 36px !important;
    }
}

@media screen and (max-height: 600px) {
    .responsive-container {
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .mobile-optimized-form {
        gap: 0.25rem;
    }
    
    .mobile-optimized-form > * {
        margin-bottom: 0.25rem !important;
    }
    
    input, select, textarea {
        padding: 0.375rem !important;
        min-height: 32px !important;
        font-size: 14px !important;
    }
    
    button[type="submit"] {
        padding: 0.5rem 1rem !important;
        min-height: 36px !important;
        font-size: 0.875rem !important;
    }
}

@media screen and (max-height: 500px) {
    .captive-portal-wrapper {
        transform: scale(0.9);
        transform-origin: center top;
    }
    
    input, select, textarea {
        padding: 0.25rem !important;
        min-height: 28px !important;
        font-size: 13px !important;
    }
    
    button[type="submit"] {
        padding: 0.375rem 0.75rem !important;
        min-height: 32px !important;
        font-size: 0.8rem !important;
    }
}

@media screen and (max-height: 400px) {
    .captive-portal-wrapper {
        transform: scale(0.8);
        transform-origin: center top;
    }
}

/* Landscape mode on phones */
@media screen and (max-height: 600px) and (orientation: landscape) {
    .responsive-container {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Additional iOS-specific optimizations */
@supports (-webkit-touch-callout: none) {
    .captive-portal-wrapper input,
    .captive-portal-wrapper textarea,
    .captive-portal-wrapper select {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
        -webkit-appearance: none;
    }
}

/* Glassmorphism form responsiveness */
.glassmorphism-form {
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

/* Very small screens */
@media screen and (max-width: 360px) {
    .responsive-container {
        padding: 0;
        width: 100%;
    }
    
    .glassmorphism-form {
        padding: 0;
    }
    
    .mobile-optimized-form {
        gap: 0.5rem;
    }
    
    .mobile-optimized-form > div {
        margin-bottom: 0.5rem !important;
    }
    
    input,
    select,
    textarea {
        padding: 0.625rem !important;
        font-size: 14px !important;
        min-height: 40px !important;
    }
    
    button[type="submit"] {
        padding: 0.625rem 1rem !important;
        font-size: 0.875rem !important;
        min-height: 40px !important;
    }
    
    /* Reduce label and helper text sizes */
    label {
        font-size: 0.75rem !important;
    }
    
    .text-sm {
        font-size: 0.75rem !important;
    }
}

/* Ultra small screens (< 320px) */
@media screen and (max-width: 320px) {
    .responsive-container {
        padding: 0;
    }
    
    input,
    select,
    textarea {
        padding: 0.5rem !important;
        font-size: 13px !important;
        min-height: 36px !important;
    }
    
    button[type="submit"] {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
        min-height: 36px !important;
    }
}

/* Phone Input Specific Styles */
.phone-input-container {
    width: 100%;
}

.phone-input-wrapper {
    display: flex !important;
    align-items: stretch;
    min-height: 44px; /* Apple's minimum touch target */
}

.phone-country-selector {
    flex-shrink: 0;
    flex-grow: 0;
    font-size: 14px !important;
    min-height: 44px !important;
    width: auto !important;
    max-width: none !important;
}

.phone-number-input {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    font-size: 16px !important;
    min-height: 44px !important;
    width: auto !important;
    max-width: 100% !important;
}

/* Override general mobile CSS for phone inputs specifically */
@media screen and (max-width: 768px) {
    .phone-input-wrapper select.phone-country-selector {
        width: 100px !important;
        max-width: 100px !important;
    }
    
    .phone-input-wrapper input.phone-number-input {
        width: auto !important;
        flex: 1 !important;
    }
}

/* Mobile phone input optimizations */
@media screen and (max-width: 480px) {
    .phone-country-selector {
        font-size: 13px !important;
        padding-left: 0.375rem !important;
        padding-right: 1.25rem !important;
    }
    
    .phone-number-input {
        font-size: 16px !important;
        padding-left: 0.625rem !important;
        padding-right: 0.625rem !important;
    }
    
    .phone-country-selector option {
        font-size: 14px !important;
    }
}

/* Very small screens - optimize phone input */
@media screen and (max-width: 360px) {
    .phone-input-wrapper {
        min-height: 40px !important;
        display: flex !important;
    }
    
    .phone-country-selector {
        max-width: 90px !important;
        width: 90px !important;
        flex: 0 0 90px !important;
        font-size: 12px !important;
        padding: 0.375rem 0.25rem !important;
        padding-right: 1rem !important;
    }
    
    .phone-number-input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        padding: 0.5rem !important;
        font-size: 16px !important;
    }
}

/* Ultra small screens - maximum space optimization */
@media screen and (max-width: 320px) {
    .phone-input-wrapper {
        min-height: 36px !important;
        display: flex !important;
    }
    
    .phone-country-selector {
        max-width: 80px !important;
        width: 80px !important;
        flex: 0 0 80px !important;
        font-size: 11px !important;
        padding: 0.25rem !important;
        padding-right: 0.875rem !important;
        background-size: 12px !important;
        background-position: right 0.125rem center !important;
    }
    
    .phone-number-input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        padding: 0.375rem !important;
        font-size: 16px !important;
    }
}

/* iOS-specific fixes for phone input */
@supports (-webkit-touch-callout: none) {
    .phone-number-input,
    .phone-country-selector {
        -webkit-appearance: none;
        -webkit-text-size-adjust: 100%;
    }
    
    .phone-number-input:focus {
        font-size: 16px !important;
    }
}

/* Landscape mode phone input adjustments */
@media screen and (max-height: 600px) and (orientation: landscape) {
    .phone-input-wrapper {
        min-height: 36px !important;
    }
    
    .phone-country-selector,
    .phone-number-input {
        padding-top: 0.375rem !important;
        padding-bottom: 0.375rem !important;
    }
}
