/* Mobile Forms Optimization CSS */

/* Base form styles */
form {
    width: 100%;
    max-width: 100%;
}

/* Input field optimization for mobile */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    min-height: 44px; /* Apple's recommended touch target size */
    padding: 12px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
    line-height: 1.5;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background-color: #fff;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

/* Focus states for better accessibility */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--bordeaux);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
    background-color: #fefefe;
}

/* Textarea specific styles */
textarea {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

/* Select dropdown optimization */
select {
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
}

/* Button optimization for forms */
button[type="submit"],
input[type="submit"],
.form-button {
    width: 100%;
    min-height: 48px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--bordeaux) 0%, var(--rosa) 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button[type="submit"]:hover,
input[type="submit"]:hover,
.form-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.3);
}

button[type="submit"]:active,
input[type="submit"]:active,
.form-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(139, 69, 19, 0.2);
}

/* Form group spacing */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Label optimization */
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

/* Required field indicator */
label.required::after {
    content: " *";
    color: #e74c3c;
}

/* Error states */
.error input,
.error textarea,
.error select {
    border-color: #e74c3c;
    background-color: #fdf2f2;
}

.error-message {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #e74c3c;
}

/* Success states */
.success input,
.success textarea,
.success select {
    border-color: #27ae60;
    background-color: #f2fdf2;
}

/* Checkbox and radio button optimization */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    vertical-align: middle;
}

.checkbox-group,
.radio-group {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    cursor: pointer;
    min-height: 44px;
    padding: 8px 0;
}

.checkbox-group label,
.radio-group label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: normal;
}

/* File input optimization */
input[type="file"] {
    padding: 8px;
    border: 2px dashed #ddd;
    background-color: #f9f9f9;
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: var(--bordeaux);
    background-color: #f5f5f5;
}

/* Mobile specific optimizations */
@media (max-width: 768px) {
    /* Increase touch targets on mobile */
    input, textarea, select, button {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Form spacing adjustments */
    .form-group {
        margin-bottom: 24px;
    }
    
    /* Button full width on mobile */
    button, input[type="submit"] {
        width: 100%;
        margin-top: 16px;
    }
    
    /* Reduce padding on smaller screens */
    input, textarea, select {
        padding: 14px 16px;
    }
}

/* iPhone SE and smaller screens */
@media (max-width: 375px) {
    input, textarea, select {
        padding: 12px 14px;
        font-size: 16px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    label {
        font-size: 13px;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    .form-group {
        margin-bottom: 16px;
    }
    
    input, textarea, select {
        min-height: 40px;
        padding: 10px 14px;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea {
        -webkit-appearance: none;
        border-radius: 8px;
    }
    
    /* Fix for iOS zoom on input focus */
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* Loading state for forms */
.form-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.form-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--bordeaux);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Form validation styles */
.form-valid {
    border-color: #27ae60 !important;
}

.form-invalid {
    border-color: #e74c3c !important;
}

/* Floating label effect */
.floating-label {
    position: relative;
    margin-bottom: 24px;
}

.floating-label input,
.floating-label textarea {
    padding-top: 20px;
    padding-bottom: 8px;
}

.floating-label label {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 16px;
    color: #999;
    transition: all 0.3s ease;
    pointer-events: none;
}

.floating-label input:focus + label,
.floating-label input:not(:placeholder-shown) + label,
.floating-label textarea:focus + label,
.floating-label textarea:not(:placeholder-shown) + label {
    top: 4px;
    font-size: 12px;
    color: var(--bordeaux);
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    input, textarea, select {
        border-width: 3px;
    }
    
    input:focus, textarea:focus, select:focus {
        box-shadow: 0 0 0 4px rgba(139, 69, 19, 0.3);
    }
}