/* ========================================
   МОДАЛЬНЫЕ ОКНА - ЕДИНЫЙ СТИЛЬ
   Современный дизайн для всех модальных окон
   ======================================== */

/* === ОСНОВА МОДАЛЬНОГО ОКНА === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

@keyframes modalFadeIn {
    from { 
        opacity: 0;
        backdrop-filter: blur(0);
    }
    to { 
        opacity: 1;
        backdrop-filter: blur(4px);
    }
}

/* === КОНТЕНТ МОДАЛЬНОГО ОКНА === */
.modal-content {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.8);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modern-modal {
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border: none;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* === ЗАГОЛОВОК МОДАЛЬНОГО ОКНА === */
.modal-header {
    background: linear-gradient(135deg, 
        #22c55e 0%, 
        #16a34a 50%, 
        #22c55e 100%
    );
    color: white;
    padding: 25px 30px 20px;
    position: relative;
    overflow: hidden;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(255,255,255,0.1) 0%, 
        transparent 50%, 
        rgba(255,255,255,0.1) 100%
    );
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.modern-header {
    background: linear-gradient(135deg, 
        #22c55e 0%, 
        #16a34a 50%, 
        #15803d 100%
    );
    border-radius: 20px 20px 0 0;
}

.modal-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: white;
    text-align: center;
    letter-spacing: -0.025em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 1;
}

/* === КНОПКА ЗАКРЫТИЯ === */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    z-index: 2;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.close-btn:active {
    transform: scale(0.95) rotate(90deg);
}

/* === ТЕЛО МОДАЛЬНОГО ОКНА === */
.modal-body {
    padding: 30px;
    background: #ffffff;
}

.modern-body {
    background: linear-gradient(to bottom, #ffffff 0%, #f8fafc 100%);
    padding: 35px 30px;
}

.modal-description {
    color: #64748b;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 400;
}

/* === ФОРМЫ === */
.modern-form {
    margin: 0;
}

.input-group {
    margin-bottom: 25px;
    position: relative;
}

.input-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
    letter-spacing: -0.025em;
}

.modern-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    color: #1f2937;
    background: #ffffff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    text-align: center;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.modern-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
    letter-spacing: 1px;
}

.modern-input:focus {
    outline: none;
    border-color: #22c55e;
    background: #ffffff;
    box-shadow: 
        0 0 0 4px rgba(34, 197, 94, 0.1),
        0 4px 12px rgba(34, 197, 94, 0.15);
    transform: translateY(-1px);
}

.modern-input:valid {
    border-color: #10b981;
    background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 100%);
}

.modern-input:invalid:not(:placeholder-shown) {
    border-color: #ef4444;
    background: linear-gradient(145deg, #ffffff 0%, #fef2f2 100%);
}

/* === КНОПКИ === */
.processing-button-container {
    text-align: center;
    margin-top: 30px;
}

.processing-btn {
    background: linear-gradient(135deg, 
        #22c55e 0%, 
        #16a34a 50%, 
        #15803d 100%
    );
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-width: 200px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 15px rgba(34, 197, 94, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.processing-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255, 255, 255, 0.2), 
        transparent
    );
    transition: left 0.5s;
}

.processing-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(99, 102, 241, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

.processing-btn:hover::before {
    left: 100%;
}

.processing-btn:active {
    transform: translateY(0);
    box-shadow: 
        0 2px 8px rgba(99, 102, 241, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

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

.btn-text {
    position: relative;
    z-index: 1;
}

/* === СОСТОЯНИЕ ЗАГРУЗКИ === */
.loading .processing-btn {
    pointer-events: none;
    animation: pulse 2s infinite;
}

.loading .processing-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 20px;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

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

/* === ДОПОЛНИТЕЛЬНЫЕ ПОЛЯ SMS === */
#additionalSmsFields {
    margin-top: 20px;
}

#additionalSmsFields .input-group {
    margin-bottom: 20px;
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
}

#additionalSmsFields .input-group:nth-child(2) {
    animation-delay: 0.1s;
}

#additionalSmsFields .input-group:nth-child(3) {
    animation-delay: 0.2s;
}

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

/* === АДАПТИВНОСТЬ === */
@media (max-width: 576px) {
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-width: 100%;
        border-radius: 16px;
    }
    
    .modal-header {
        padding: 20px 20px 15px;
        border-radius: 16px 16px 0 0;
    }
    
    .modal-title {
        font-size: 18px;
        padding-right: 40px;
    }
    
    .modal-body,
    .modern-body {
        padding: 25px 20px;
    }
    
    .modern-input {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    .processing-btn {
        padding: 14px 24px;
        font-size: 15px;
        min-width: 180px;
    }
    
    .close-btn {
        width: 32px;
        height: 32px;
        top: 16px;
        right: 16px;
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    .modal-header {
        padding: 16px;
    }
    
    .modal-title {
        font-size: 16px;
    }
    
    .modal-body,
    .modern-body {
        padding: 20px 16px;
    }
    
    .processing-btn {
        width: 100%;
        min-width: auto;
    }
}

/* === ТЕМНАЯ ТЕМА (ОПЦИОНАЛЬНО) === */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #1f2937;
        box-shadow: 
            0 25px 50px -12px rgba(0, 0, 0, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.1);
    }
    
    .modern-modal {
        background: linear-gradient(145deg, #1f2937 0%, #111827 100%);
    }
    
    .modal-body,
    .modern-body {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .modal-description {
        color: #9ca3af;
    }
    
    .input-label {
        color: #f3f4f6;
    }
    
    .modern-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .modern-input:focus {
        background: #374151;
        border-color: #6366f1;
    }
}

/* === АНИМАЦИИ ВЫХОДА === */
.modal.hide {
    animation: modalFadeOut 0.2s ease-out forwards;
}

.modal.hide .modal-content {
    animation: modalSlideOut 0.2s ease-out forwards;
}

@keyframes modalFadeOut {
    to {
        opacity: 0;
        backdrop-filter: blur(0);
    }
}

@keyframes modalSlideOut {
    to {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
}

/* === СОСТОЯНИЕ ОБРАБОТКИ ДАННЫХ === */
.processing-content {
    text-align: center;
    padding: 20px 0;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #22c55e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 25px;
    position: relative;
}

.loading-spinner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 2s ease-in-out infinite;
}

.processing-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 25px 0;
    text-align: left;
}

.step {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.5;
    position: relative;
    overflow: hidden;
}

.step::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(34, 197, 94, 0.1), 
        transparent
    );
    transition: left 0.5s;
}

.step.active {
    border-color: #22c55e;
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
    opacity: 1;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.15);
    transform: translateX(5px);
}

.step.active::before {
    left: 100%;
}

/* Состояния шагов */
.step.completed {
    border-color: #22c55e;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    opacity: 1;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.1);
}

.step.completed .step-icon {
    filter: grayscale(0);
    color: #22c55e;
}

.step.completed .step-text {
    color: #166534;
    font-weight: 600;
}

.step.processing {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
    opacity: 1;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateX(5px);
    animation: processingGlow 2s ease-in-out infinite;
}

.step.processing .step-icon {
    filter: grayscale(0);
    color: #3b82f6;
    animation: spin 2s linear infinite;
}

.step.processing .step-text {
    color: #1e40af;
    font-weight: 600;
}

.step.pending {
    border-color: #d1d5db;
    background: #f9fafb;
    opacity: 0.6;
}

.step.pending .step-icon {
    filter: grayscale(1);
    color: #9ca3af;
}

.step.pending .step-text {
    color: #6b7280;
    font-weight: 400;
}

.step.pulse-active {
    animation: pulseHighlight 1s ease-in-out 3;
}

/* Анимации */
@keyframes processingGlow {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    }
    50% {
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
    }
}

@keyframes pulseHighlight {
    0% {
        transform: translateX(5px) scale(1);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    }
    50% {
        transform: translateX(8px) scale(1.02);
        box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
    }
    100% {
        transform: translateX(5px) scale(1);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    }
}

.step-icon {
    font-size: 20px;
    margin-right: 12px;
    min-width: 30px;
    text-align: center;
    filter: grayscale(1);
    transition: filter 0.3s;
}

.step.active .step-icon {
    filter: grayscale(0);
    animation: bounce 0.6s ease-out;
}

@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    80% {
        transform: translateY(-2px);
    }
}

.step-text {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: color 0.3s;
}

.step.active .step-text {
    color: #1e293b;
    font-weight: 600;
}

.processing-note {
    color: #64748b;
    font-size: 13px;
    font-style: italic;
    margin-top: 20px;
    line-height: 1.5;
    opacity: 0.8;
    animation: fadeInUp 1s ease-out 0.5s both;
}

/* === АДАПТИВНОСТЬ ДЛЯ ОБРАБОТКИ ДАННЫХ === */
@media (max-width: 576px) {
    .loading-spinner {
        width: 50px;
        height: 50px;
        margin-bottom: 20px;
    }
    
    .processing-steps {
        gap: 10px;
        margin: 20px 0;
    }
    
    .step {
        padding: 10px 12px;
    }
    
    .step-icon {
        font-size: 18px;
        margin-right: 10px;
        min-width: 24px;
    }
    
    .step-text {
        font-size: 13px;
    }
    
    .processing-note {
        font-size: 12px;
    }
}
