/**
 * WebTAI Modals
 * Context selectors, dropdowns, and overlay components
 */

/* ===== CONTEXT MODAL ===== */
.context-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    z-index: 1100;

    &.visible {
        display: flex;
    }
}

.context-modal-content {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.context-modal-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.context-modal-title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-lg);
}

.context-modal-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.context-modal-refresh,
.context-modal-close {
    background: none;
    border: none;
    padding: var(--space-xs);
    cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;

    &:hover {
        background: var(--color-bg);
        color: var(--color-text);
    }
}

.context-modal-refresh.loading svg {
    animation: spin 1s linear infinite;
}

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

.context-modal-search {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border);

    & input {
        width: 100%;
        padding: var(--space-sm) var(--space-md);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        font-size: var(--font-size-base);
    }
}

.context-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
    -webkit-overflow-scrolling: touch;
}

.context-modal-item {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-height: 44px;

    &:hover {
        background: var(--color-bg);
    }

    &.selected {
        background: var(--color-sidebar-active);
    }

    &.highlighted {
        background: var(--color-primary);
        color: white;

        & .context-modal-item-code {
            color: white;
        }
    }
}

.context-modal-item-code {
    font-family: var(--font-family-mono);
    font-weight: var(--font-weight-medium);
    color: var(--color-primary);
    width: 40px;
    flex-shrink: 0;
}

.context-modal-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-modal-loading,
.context-modal-error {
    padding: var(--space-lg);
    text-align: center;
    color: var(--color-text-muted);
}

.context-modal-error {
    color: var(--color-danger);
}
