/**
 * Современная многошаговая форма КНС
 * Стили для адаптивного дизайна
 */

/* ========================================
   ОСНОВНОЙ КОНТЕЙНЕР
   ======================================== */

.kns-modern-form-wrapper {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ========================================
   ПРОГРЕСС-БАР
   ======================================== */

.kns-progress-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    position: relative;
    padding: 0 20px;
}

.kns-progress-bar::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    height: 2px;
    background: #e0e0e0;
    z-index: 0;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.progress-step .step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: #999;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.progress-step .step-label {
    font-size: 12px;
    color: #999;
    text-align: center;
    transition: all 0.3s ease;
}

.progress-step.active .step-number {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-color: #2563eb;
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.progress-step.active .step-label {
    color: #2563eb;
    font-weight: 600;
}

.progress-step.completed .step-number {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.progress-step.completed .step-label {
    color: #10b981;
}

/* ========================================
   КАРТОЧКИ ШАГОВ
   ======================================== */

.form-step {
    display: none;
    animation: fadeInUp 0.4s ease-out;
}

.form-step.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 30px;
}

.step-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 30px;
    border-bottom: 1px solid #e2e8f0;
}

.step-header h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 12px;
}

.step-header h3 i {
    font-size: 28px;
    color: #2563eb;
}

.step-description {
    margin: 0;
    color: #64748b;
    font-size: 14px;
}

.step-content {
    padding: 30px;
}

/* ========================================
   ПОЛЯ ФОРМЫ
   ======================================== */

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

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

.form-group label .required {
    color: #ef4444;
    margin-left: 3px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    color: #1e293b;
    background: #fff;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
    color: #94a3b8;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

select.form-control {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23334155" stroke-width="2"%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: 20px;
    padding-right: 40px;
    cursor: pointer;
    appearance: none;
}

/* ========================================
   ЧЕКБОКСЫ
   ======================================== */

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    transition: background 0.3s ease;
}

.checkbox-label:hover {
    background: #f1f5f9;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    cursor: pointer;
    accent-color: #2563eb;
}

.checkbox-label span {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: #334155;
}

/* ========================================
   ДОПОЛНИТЕЛЬНЫЕ ЭЛЕМЕНТЫ
   ======================================== */

.diagram-section {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: #f8fafc;
    border-radius: 8px;
}

.kns-diagram {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.diagram-caption {
    margin: 15px 0 0 0;
    font-size: 13px;
    color: #64748b;
    font-style: italic;
}

.info-box {
    background: #dbeafe;
    border-left: 4px solid #2563eb;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-box p {
    margin: 0;
    font-size: 14px;
    color: #1e40af;
}

.form-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 30px 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

/* ========================================
   НАВИГАЦИЯ
   ======================================== */

.form-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 30px;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn-secondary {
    background: #fff;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
   СООБЩЕНИЯ
   ======================================== */

.form-messages {
    margin-top: 20px;
}

.message {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.message-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.message-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ========================================
   АДАПТИВНОСТЬ
   ======================================== */

/* Планшеты */
@media (max-width: 768px) {
    .kns-modern-form-wrapper {
        padding: 15px;
        margin: 20px auto;
    }
    
    .kns-progress-bar {
        padding: 0 10px;
    }
    
    .progress-step .step-label {
        font-size: 10px;
    }
    
    .progress-step .step-number {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .step-header {
        padding: 20px;
    }
    
    .step-header h3 {
        font-size: 20px;
    }
    
    .step-content {
        padding: 20px;
    }
    
    .form-navigation {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Мобильные */
@media (max-width: 480px) {
    .kns-modern-form-wrapper {
        padding: 10px;
        margin: 10px auto;
    }
    
    .kns-progress-bar {
        padding: 0 5px;
    }
    
    .progress-step .step-label {
        display: none;
    }
    
    .progress-step .step-number {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    
    .step-header {
        padding: 15px;
    }
    
    .step-header h3 {
        font-size: 18px;
        flex-direction: column;
        gap: 8px;
    }
    
    .step-content {
        padding: 15px;
    }
    
    .form-control {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* ========================================
   СОСТОЯНИЕ ЗАГРУЗКИ
   ======================================== */

.kns-form.loading {
    opacity: 0.6;
    pointer-events: none;
}

.kns-form.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========================================
   ВАЛИДАЦИЯ
   ======================================== */

.form-control.error {
    border-color: #ef4444;
    background: #fef2f2;
}

.form-control.success {
    border-color: #10b981;
}

.error-message {
    color: #ef4444;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.form-control.error + .error-message {
    display: block;
}
