/* Оптимизация форм для мобильных устройств */

/* Базовые стили для мобильных форм */
.mobile-form-container {
    padding: 20px 16px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin: 16px 0;
}

/* Улучшенные поля ввода для мобильных */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 16px;
}

/* Основные поля ввода */
.form-input,
.form-control,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    min-height: 48px;
    padding: 14px 16px;
    font-size: 16px; /* Предотвращает zoom на iOS */
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    background: #fff;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-sizing: border-box;
    font-family: inherit;
}

/* Фокус состояние */
.form-input:focus,
.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #3e6d26;
    box-shadow: 0 0 0 3px rgba(62, 109, 38, 0.15);
    background: #fff;
}

/* Состояние ошибки */
.form-input.error,
.form-control.error,
input.error,
textarea.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

/* Состояние успеха */
.form-input.success,
.form-control.success,
input.success,
textarea.success {
    border-color: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}

/* Textarea специальные стили */
textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

/* Select специальные стили */
select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

/* Мобильные стили */
@media (max-width: 768px) {
    .mobile-form-container {
        padding: 24px 20px;
        margin: 20px 0;
        border-radius: 20px;
    }
    
    .form-input,
    .form-control,
    input,
    textarea,
    select {
        min-height: 56px;
        padding: 16px 20px;
        font-size: 18px;
        border-radius: 16px;
        margin: 8px 0;
    }
    
    .form-label {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    textarea {
        min-height: 140px;
    }
    
    select {
        background-size: 20px;
        padding-right: 48px;
    }
}

/* Особо маленькие экраны */
@media (max-width: 480px) {
    .mobile-form-container {
        padding: 20px 16px;
        margin: 16px 0;
        border-radius: 16px;
    }
    
    .form-input,
    .form-control,
    input,
    textarea,
    select {
        min-height: 52px;
        padding: 14px 18px;
        font-size: 16px;
        border-radius: 14px;
    }
}

/* Чекбоксы и радиокнопки */
.checkbox-group,
.radio-group {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 16px 0;
    cursor: pointer;
    min-height: 48px;
}

.checkbox-input,
.radio-input {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

@media (max-width: 768px) {
    .checkbox-group,
    .radio-group {
        gap: 16px;
        margin: 20px 0;
        min-height: 56px;
    }
    
    .checkbox-input,
    .radio-input {
        width: 24px;
        height: 24px;
        margin-top: 4px;
    }
    
    .checkbox-label,
    .radio-label {
        font-size: 18px;
        line-height: 1.4;
    }
}

/* Кнопки форм */
.form-button,
.submit-btn {
    width: 100%;
    min-height: 52px;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: #3e6d26;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.form-button:hover,
.submit-btn:hover {
    background: #2d4f1a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(62, 109, 38, 0.3);
}

.form-button:active,
.submit-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(62, 109, 38, 0.2);
}

@media (max-width: 768px) {
    .form-button,
    .submit-btn {
        min-height: 60px;
        padding: 18px 28px;
        font-size: 20px;
        border-radius: 16px;
        margin-top: 24px;
    }
}

/* Вторичные кнопки */
.form-button.secondary,
.submit-btn.secondary {
    background: transparent;
    border: 2px solid #3e6d26;
    color: #3e6d26;
}

.form-button.secondary:hover,
.submit-btn.secondary:hover {
    background: #3e6d26;
    color: #fff;
}

/* Группы кнопок */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .button-group {
        flex-direction: column;
        gap: 16px;
        margin-top: 24px;
    }
}

/* Индикатор загрузки */
.form-button.loading,
.submit-btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.form-button.loading::after,
.submit-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Сообщения об ошибках */
.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 6px;
    display: block;
}

@media (max-width: 768px) {
    .error-message {
        font-size: 16px;
        margin-top: 8px;
    }
}

/* Сообщения об успехе */
.success-message {
    color: #27ae60;
    font-size: 14px;
    margin-top: 6px;
    display: block;
}

@media (max-width: 768px) {
    .success-message {
        font-size: 16px;
        margin-top: 8px;
    }
}

/* Плавающие лейблы */
.floating-label {
    position: relative;
}

.floating-label .form-input,
.floating-label .form-control {
    padding-top: 24px;
    padding-bottom: 8px;
}

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

.floating-label .form-input:focus + .form-label,
.floating-label .form-input:not(:placeholder-shown) + .form-label,
.floating-label .form-control:focus + .form-label,
.floating-label .form-control:not(:placeholder-shown) + .form-label {
    top: 8px;
    font-size: 12px;
    color: #3e6d26;
}

@media (max-width: 768px) {
    .floating-label .form-input,
    .floating-label .form-control {
        padding-top: 28px;
        padding-bottom: 12px;
    }
    
    .floating-label .form-label {
        top: 20px;
        left: 20px;
        font-size: 18px;
    }
    
    .floating-label .form-input:focus + .form-label,
    .floating-label .form-input:not(:placeholder-shown) + .form-label,
    .floating-label .form-control:focus + .form-label,
    .floating-label .form-control:not(:placeholder-shown) + .form-label {
        top: 10px;
        font-size: 14px;
    }
}

/* Поля с иконками */
.input-with-icon {
    position: relative;
}

.input-with-icon .form-input,
.input-with-icon .form-control {
    padding-left: 48px;
}

.input-with-icon .input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    width: 20px;
    height: 20px;
}

@media (max-width: 768px) {
    .input-with-icon .form-input,
    .input-with-icon .form-control {
        padding-left: 56px;
    }
    
    .input-with-icon .input-icon {
        left: 20px;
        width: 24px;
        height: 24px;
    }
}

/* Шаги формы */
.form-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
}

.form-step {
    flex: 1;
    text-align: center;
    position: relative;
}

.form-step::after {
    content: '';
    position: absolute;
    top: 15px;
    left: 60%;
    width: 80%;
    height: 2px;
    background: #e1e5e9;
}

.form-step:last-child::after {
    display: none;
}

.form-step.active::after {
    background: #3e6d26;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e1e5e9;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.form-step.active .step-number,
.form-step.completed .step-number {
    background: #3e6d26;
    color: #fff;
}

.step-title {
    font-size: 14px;
    color: #666;
}

.form-step.active .step-title,
.form-step.completed .step-title {
    color: #3e6d26;
    font-weight: 600;
}

@media (max-width: 768px) {
    .form-steps {
        margin-bottom: 40px;
    }
    
    .step-number {
        width: 40px;
        height: 40px;
        margin: 0 auto 12px;
    }
    
    .step-title {
        font-size: 16px;
    }
}

/* Автозаполнение */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #fff inset;
    -webkit-text-fill-color: #333;
    transition: background-color 5000s ease-in-out 0s;
}

/* Скрытие спиннеров для number input */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Файловые поля */
.file-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    margin: 8px 0;
}

.file-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 20px;
    border: 2px dashed #3e6d26;
    border-radius: 12px;
    background: #f8f9fa;
    color: #3e6d26;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.file-input-label:hover {
    background: #e8f5e8;
    border-color: #2d4f1a;
}

@media (max-width: 768px) {
    .file-input-label {
        min-height: 56px;
        padding: 16px 24px;
        font-size: 16px;
        border-radius: 16px;
    }
}