/* ================================================
   COA Manager — Modal / Lightbox
   ================================================ */

/* Desktop fade+scale animation */
@keyframes coa-modal-appear {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* Mobile slide-up animation — declared at root level for browser compat */
@keyframes coa-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* Modal container — covers full viewport */
#coa-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
}

#coa-modal.is-open {
    display: flex;
}

/* Backdrop — absolute so it shares stacking context with panel inside the flex container */
.coa-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    background: var(--coa-modal-overlay, rgba(0, 0, 0, 0.55));
    cursor: pointer;
    z-index: 0;
}

/* Panel sits above the overlay */
.coa-modal__panel {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 12px;
    width: 92vw;
    max-width: 980px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: coa-modal-appear 0.22s ease both;
}

/* Header */
.coa-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.coa-modal__title {
    margin: 0;
    font-size: 1.05em;
    font-weight: 700;
    color: #111;
}

.coa-modal__close {
    background: none;
    border: none;
    font-size: 1.5em;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #555;
    transition: background 0.15s;
}

.coa-modal__close:hover {
    background: #f0f0f0;
    color: #111;
}

/* Body — scrollable */
.coa-modal__body {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.coa-modal__loading {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #475467;
}

.coa-modal__spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(148, 163, 184, 0.26);
    border-top-color: #4f46e5;
    border-radius: 999px;
    animation: coa-modal-spin 0.7s linear infinite;
}

.coa-modal__loading-text {
    font-size: 14px;
    font-weight: 600;
}

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

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

/* ================================================
   Mobile: bottom-sheet
   Panel slides up from bottom; dark area above is the overlay (tap to close)
   ================================================ */
@media ( max-width: 600px ) {

    /* Push panel to bottom of screen */
    #coa-modal {
        align-items: flex-end;
    }

    /* Full-width bottom sheet with slide-up animation */
    .coa-modal__panel {
        width: 100vw;
        max-width: 100vw;
        max-height: 82dvh;
        border-radius: 18px 18px 0 0;
        margin: 0;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
        animation: coa-slide-up 0.32s ease both;
    }

    .coa-modal__body {
        padding: 14px;
    }

    /* Single column grid inside modal body */
    .coa-modal__body .coa-grid,
    .coa-modal__body .coa-cols-2,
    .coa-modal__body .coa-cols-3,
    .coa-modal__body .coa-cols-4 {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}
