/* Новый дизайн модальных окон */
.modal-overlay {
    position: fixed;
    inset: 0;
    padding: 32px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    animation: modalOverlayIn 0.3s ease forwards;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-content {
    position: relative;
    width: min(100%, 880px);
    max-height: calc(100vh - 40px);
    border-radius: 24px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    color: var(--text-main);
    animation: modalCardIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.modal-side {
    position: relative;
    padding: 52px 44px;
    background: #f5f5f7;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    gap: 32px;
    border-right: 1px solid rgba(0,0,0,0.06);
}

.modal-side::after {
    display: none;
}

.modal-logo {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: #fff;
    color: var(--color-primary);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: none;
}

.modal-side__text, .modal-side__note, .modal-side__list li {
    color: #000000;
}

.modal-side__list li::before {
    background: var(--color-primary);
    box-shadow: none;
}

/* Updated Buttons */
.modal-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 22px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--color-primary);
    color: #ffffff !important; /* Force white text */
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modal-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background: #000;
    color: #ffffff !important;
}

.modal-submit:active:not(:disabled) {
    transform: translateY(0);
}

/* Updated Inputs */
.modal-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #fff;
    box-shadow: none;
    transition: all 0.2s ease;
}

.modal-input-wrapper:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
    transform: none;
}

.modal-input-icon {
    width: 20px;
    height: 20px;
    color: var(--neutral-500, #8490ab);
    flex-shrink: 0;
    /* FIX: Constrain width explicitly */
    min-width: 20px;
    max-width: 20px;
}

/* FIX: Constrain SVG size explicitly */
.modal-input-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.modal-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    color: var(--neutral-800, #1d2538);
    font-family: inherit;
    width: 100%; /* Ensure input takes width */
    min-width: 0; /* Fix flex child sizing */
}

.modal-input::placeholder {
    color: var(--neutral-400, #a2acc3);
    font-weight: 400;
}

.modal-input:focus {
    outline: none;
}

.modal-link {
    color: var(--color-primary);
}

.modal-social-btn {
    border-radius: 8px;
    color: white;
    background: #333;
}

.modal-social-btn--vk {
    background: #0077FF;
    box-shadow: none;
}

.modal-social-btn--telegram {
    background: #24A1DE;
    box-shadow: none;
}

.modal-social-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Mobile adjustments */
@media (max-width: 640px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
        background: rgba(0,0,0,0.5);
    }
    
    .modal-content {
        max-height: 90vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        animation: modalSlideUp 0.3s ease forwards;
        width: 100%;
        /* Fix grid on mobile */
        display: flex;
        flex-direction: column;
    }

    .modal-main {
        padding: 32px 24px 48px;
        flex: 1;
        overflow-y: auto;
    }
    
    .modal-side {
        display: none;
    }
}

@keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalOverlayOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes modalCardIn {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modalCardOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
}

.modal-content--auth {
    grid-template-columns: 340px minmax(0, 1fr);
}

.modal-content--compact {
    width: min(100%, 760px);
}

.modal-content--panel {
    width: min(100%, 640px);
    grid-template-columns: minmax(0, 1fr);
}

.modal-main {
    padding: 52px 56px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.08);
    color: var(--neutral-600, #69758f);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 26px;
    line-height: 1;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(15, 23, 42, 0.12);
    color: var(--neutral-800, #1d2538);
    transform: rotate(90deg);
}

.modal-close:active {
    transform: scale(0.9);
}

.modal-close:focus-visible {
    outline: 2px solid var(--primary-400, #3b82f6);
    outline-offset: 2px;
}

.modal-heading {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-tag {
    align-self: flex-start;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-600, #2563eb);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.modal-title {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: inherit;
}

.modal-subtitle {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--neutral-600, #69758f);
    max-width: 460px;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--neutral-700, #525e78);
}

.modal-divider {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--neutral-500, #8490ab);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.modal-divider::before,
.modal-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.12), rgba(15, 23, 42, 0));
}

.modal-social {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.modal-social-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 18px;
    border: none;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.modal-social-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.modal-social-btn::before {
    content: "";
    position: absolute;
    inset: -30%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0));
    opacity: 0;
    transition: opacity 0.35s ease;
}

.modal-social-btn:hover::before {
    opacity: 1;
}

.modal-social-btn:hover {
    transform: translateY(-2px);
}

.modal-social-btn:active {
    transform: translateY(0);
}

.modal-social-btn--vk {
    background: linear-gradient(135deg, #2787f5 0%, #1141a7 100%);
    box-shadow: 0 12px 28px rgba(39, 135, 245, 0.28);
}

.modal-social-btn--telegram {
    background: linear-gradient(135deg, #2aabee 0%, #1a8cd8 100%);
    box-shadow: 0 12px 28px rgba(42, 171, 238, 0.32);
}

.modal-social-btn.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
}

.modal-social-btn.is-disabled:hover {
    transform: none;
}

.modal-footnote {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 14px;
}

.modal-footnote__item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--neutral-600, #69758f);
}

.modal-footnote__text {
    font-weight: 500;
}

.modal-footnote--center {
    justify-content: center;
}

.modal-link {
    font-weight: 600;
    color: var(--primary-500, #2563eb);
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
}

.modal-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: width 0.25s ease;
}

.modal-link:hover::after {
    width: 100%;
}

.modal-link--accent {
    color: var(--primary-600, #1d4ed8);
}

.modal-link--disabled {
    color: var(--neutral-400, #a2acc3);
    cursor: not-allowed;
}

.modal-link--disabled::after {
    display: none;
}

/* Уведомления внутри модального окна */
.modal-alert {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    margin-top: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: modalAlertSlideDown 0.3s ease-out;
}

@keyframes modalAlertSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-alert__icon {
    font-size: 18px;
    flex-shrink: 0;
}

.modal-alert__text {
    flex: 1;
    font-weight: 500;
}

/* Типы уведомлений */
.modal-alert--info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.modal-alert--error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.1));
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.modal-alert--warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.1));
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.modal-alert--success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.1));
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
}

/* Чекбокс согласия с политикой конфиденциальности */
.modal-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px 0;
    user-select: none;
}

.modal-checkbox__input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.modal-checkbox__checkmark {
    position: relative;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    background: #fff;
    transition: all 0.2s ease;
}

.modal-checkbox:hover .modal-checkbox__checkmark {
    border-color: var(--color-primary);
}

.modal-checkbox__input:checked ~ .modal-checkbox__checkmark {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.modal-checkbox__checkmark::after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.modal-checkbox__input:checked ~ .modal-checkbox__checkmark::after {
    display: block;
}

.modal-checkbox__label {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: var(--neutral-600, #69758f);
}

.modal-checkbox__link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.modal-checkbox__link:hover {
    color: var(--primary-600, #1d4ed8);
    text-decoration: underline;
}

/* Состояние ошибки для невыбранного чекбокса */
.modal-checkbox__input:invalid ~ .modal-checkbox__checkmark {
    border-color: #ef4444;
}

/* Анимация при клике */
.modal-checkbox__input:active ~ .modal-checkbox__checkmark {
    transform: scale(0.95);
}

/* Адаптивность для мобильных устройств */
@media (max-width: 640px) {
    .modal-checkbox {
        padding: 10px 0;
    }
    
    .modal-checkbox__label {
        font-size: 13px;
    }
    
    .modal-checkbox__checkmark {
        width: 18px;
        height: 18px;
    }
    
    .modal-checkbox__checkmark::after {
        left: 5px;
        top: 1px;
        width: 4px;
        height: 9px;
    }
}
