/* ============================================
   Modal/Popup Component Styles
   ============================================ */

.modal {
    display: none;
    height: 100%;
    width: 100%;
    position: fixed;
    left: 0;
    top: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    cursor: default;
    animation: fadeIn 0.3s ease-out;
}

.modal--active {
    display: flex;
}

.modal--visible {
    opacity: 1;
}

/* Modal positioning and layout */
.modal__positioner {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal__wrapper {
    width: 50%;
    background: var(--wp--preset--color--white);
    border-radius: 12px;
    border: 1px solid var(--wp--preset--color--border-grey);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.modal--visible .modal__wrapper {
    opacity: 1;
    transform: scale(1);
}

/* Modal size variants */
.modal--small .modal__wrapper {
    width: 30%;
}

.modal--medium .modal__wrapper {
    width: 50%;
}

.modal--large .modal__wrapper {
    width: 70%;
}

/* Modal header */
.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-style: normal;
    font-weight: 500;
    line-height: 30px;
    padding: 16px;
    border-bottom: 1px solid var(--wp--preset--color--border);
    flex-shrink: 0;
}

.modal__header h2,
.modal__header h3,
.modal__header p {
    margin: 0;
    flex-grow: 1;
}

/* Modal close button */
.modal__close-btn {
    background: none;
    border: none;
    color: var(--wp--preset--color--light-grey);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    flex-shrink: 0;
    margin-left: 8px;
    font-size: 18px;
}

.modal__close-btn:hover {
    color: var(--wp--preset--color--primary-text);
}
.modal__close-btn i {
    color: var(--wp--preset--color--primary-text);
}

/* Modal content (body) */
.modal__content {
    padding: 16px 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal__content::-webkit-scrollbar {
    width: 6px;
}

.modal__content::-webkit-scrollbar-track {
    background: var(--wp--preset--color--secondary-background);
}

.modal__content::-webkit-scrollbar-thumb {
    background: var(--wp--preset--color--border);
    border-radius: 3px;
}

.modal__content::-webkit-scrollbar-thumb:hover {
    background: var(--wp--preset--color--grey);
}

/* Modal footer */
.modal__footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--wp--preset--color--border);
    flex-shrink: 0;
}

/* Loading state */
.modal__loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
}

.modal__loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--wp--preset--color--border);
    border-top-color: var(--wp--preset--color--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

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


@media (max-width: 780px) {

    .modal {
        animation: none;
    }

    .modal__positioner {
        align-items: flex-end;
        padding: 0;
    }

    .modal__wrapper {
        width: 100%;
        border-radius: 12px 12px 0 0;
        opacity: 0;
        transform: translateY(100%);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    .modal--visible .modal__wrapper {
        opacity: 1;
        transform: translateY(0);
    }

    .modal--small .modal__wrapper,
    .modal--medium .modal__wrapper,
    .modal--large .modal__wrapper {
        width: 100%;
    }

    .modal__content {
        padding: 16px;
    }
}