/**
 * Modal popup styles
 *
 * @package SVTB_VED
 * @author Alex Kovalev
 * @link https://akovalev.pro
 */

/* Modal Overlay */
.modal {
    position: fixed;
    z-index: 999;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
}

.modal--active {
    opacity: 1;
    visibility: visible;
}

/* Modal Inner Container */
.modal__inner {
    position: relative;
    max-width: 40rem;
    width: 100%;
    margin: 0 1.5rem;
}

/* Modal Content */
.modal__content {
    margin: 0 auto;
    border-radius: 2rem;
    background-color: #fff;
    overflow: hidden;
    padding: 2.25rem 2.5rem 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

@media (max-width: 640px) {
    .modal {
        padding-top: 4rem;
    }

    .modal__inner {
        max-width: 100%;
        margin: 0 0.75rem;
    }

    .modal__content {
        border-radius: 1.5rem;
        padding: 1.5rem 1.25rem 2rem;
    }
}

/* Modal Close Button */
.modal__close {
    cursor: pointer;
    width: 3.4rem;
    height: 3.4rem;
    border-radius: 50%;
    background-color: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 10;
    top: 5px;
    right: 5px;
    color: #333;
    transition: transform 0.2s ease, color 0.2s ease;
    padding: 0;
}

.modal__close:hover {
    transform: scale(1.1);
    color: #1B383C;
}

.modal__close svg {
    width: 2.4rem;
    height: 2.4rem;
}

/* Modal Form */
.modal-form__title {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin: 0 auto 1rem;
    color: #1B383C;
    line-height: 1.3;
}

.modal-form__description {
    font-size: 1.25rem;
    font-weight: 400;
    text-align: center;
    color: #666;
    margin: 0 auto 1.5rem;
    max-width: 28rem;
    line-height: 1.5;
}

@media (max-width: 640px) {
    .modal-form__title {
        font-size: 1.35rem;
        margin-bottom: 0.6rem;
    }

    .modal-form__description {
        font-size: 1.1rem;
        margin: 0 auto 1rem;
    }
}

/* Modal Form Fields */
.modal-form__fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Modal Input */
.modal__input {
    width: 100%;
    padding: 1.5rem 2rem;
    border: 1px solid #ddd;
    border-radius: 1rem;
    font-family: inherit;
    font-size: 1.6rem;
    font-weight: 400;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal__input::placeholder {
    color: #999;
}

.modal__input:focus {
    outline: none;
    border-color: #1B383C;
    box-shadow: 0 0 0 3px rgba(27, 56, 60, 0.1);
}

.modal__input--textarea {
    min-height: 10rem;
    resize: vertical;
}

@media (max-width: 640px) {
    .modal-form__fields {
        gap: 1rem;
    }

    .modal__input {
        padding: 0.9rem 1.25rem;
        font-size: 1.4rem;
    }

    .modal__input--textarea {
        min-height: 7rem;
    }
}

/* Modal Box (checkbox + button) */
.modal__box {
    display: flex;
    flex-direction: row-reverse;
    gap: 2rem;
    margin-top: 1rem;
    align-items: center;
}

@media (max-width: 640px) {
    .modal__box {
        flex-direction: column;
        gap: 1rem;
        margin-top: 0.75rem;
        align-items: stretch;
    }

    .custom-checkbox > span {
        font-size: 1.2rem;
    }
}

/* Custom Checkbox */
.custom-checkbox {
    display: block;
    cursor: pointer;
}

.custom-checkbox input {
    position: absolute;
    z-index: -1;
    opacity: 0;
}

.custom-checkbox > span {
    display: inline-flex;
    align-items: flex-start;
    user-select: none;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1.4;
    color: #666;
}

.custom-checkbox > span::before {
    content: '';
    display: inline-block;
    width: 1.8rem;
    height: 1.8rem;
    flex-shrink: 0;
    flex-grow: 0;
    border: 2px solid #1B383C;
    border-radius: 0.4rem;
    margin-right: 1rem;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 60% 60%;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.custom-checkbox > input:checked + span::before {
    border-color: #1B383C;
    background-color: #1B383C;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
}

.custom-checkbox a {
    color: #1B383C;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.custom-checkbox a:hover {
    text-decoration: none;
}

/* Modal Button */
.modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16rem;
    padding: 1.5rem 3rem;
    background-color: #1B383C;
    color: #fff;
    border: none;
    border-radius: 1rem;
    font-family: inherit;
    font-size: 1.6rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.modal__btn:hover {
    background-color: #2a4f54;
}

.modal__btn:active {
    transform: scale(0.98);
}

.modal__btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .modal__btn {
        width: 100%;
        padding: 1.1rem 1.5rem;
        font-size: 1.45rem;
    }
}

/* Modal Success/Error Messages */
.modal__message {
    text-align: center;
    padding: 2rem;
    border-radius: 1rem;
    margin-top: 1.5rem;
    font-size: 1.5rem;
}

.modal__message--success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.modal__message--error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Loading State */
.modal__btn--loading {
    position: relative;
    color: transparent;
}

.modal__btn--loading::after {
    content: '';
    position: absolute;
    width: 2rem;
    height: 2rem;
    top: 50%;
    left: 50%;
    margin-left: -1rem;
    margin-top: -1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Body scroll lock when modal is open */
body.modal-open {
    overflow: hidden;
}
