﻿:root {
    --primary: #3182ce;
    --danger: #e53e3e;
    --border: lightgrey;
    --badge-bg: #ebf8ff;
    --badge-text: #2b6cb0;
    --bg-disabled: #f8fafc;
}

/*body {
    font-family: system-ui, -apple-system, sans-serif;
    padding: 40px;
    background: #f1f5f9;
    color: #2d3748;
}*/

.container {
    max-width: 900px;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
/*
h3 {
    margin-bottom: 10px;
    border-bottom: 2px solid #cbd5e0;
    padding-bottom: 5px;
}*/

/* --- ESTILOS DEL COMPONENTE --- */
.ms-container {
    position: relative;
    width: 100%;
}

.ms-trigger {
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: white;
    min-height: 46px;
    align-items: center;
    transition: all 0.2s;
}

    .ms-trigger:hover {
        border-color: #a0aec0;
    }

.ms-badge {
    background: var(--badge-bg);
    color: var(--badge-text);
    padding: 2px 6px 2px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #bee3f8;
    font-weight: 500;
}

.ms-badge-remove {
    cursor: pointer;
    color: #63b3ed;
    font-weight: bold;
    font-size: 1.1rem;
}

    .ms-badge-remove:hover {
        color: var(--danger);
    }

.ms-placeholder {
    /*color: #a0aec0;*/
    padding-left: 5px;
    font-size: 0.9rem;
}

.ms-dropdown {
    position: absolute;
    width: 100%;
    border: 1px solid var(--border);
    background: white;
    z-index: 100;
    margin-top: 6px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ms-inline {
    border: 1px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
}

.ms-container.ms-is-open .ms-dropdown {
    max-height: 600px;
    opacity: 1;
}

.ms-container.ms-inline .ms-dropdown {
    position: relative;
    box-shadow: none;
    border: unset;
/*    border-top: none;
    margin-top: -2px;
    border-radius: 0 0 8px 8px;*/
}

.ms-container.ms-inline .ms-trigger {
    border: unset;
}

.ms-search-container {
    padding: 10px;
    border-bottom: 1px solid #f7fafc;
}

.ms-search-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    box-sizing: border-box;
}

.ms-actions {
    padding: 8px 12px;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    border-bottom: 1px solid #edf2f7;
}

.ms-btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 600;
}

.ms-list {
    max-height: 220px;
    overflow-y: auto;
}

.ms-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

    .ms-item:hover {
        background: #f7fafc;
    }

    .ms-item.is-selected {
        background: #f0f7ff;
        color: var(--primary);
        font-weight: 600;
    }

    .ms-item.is-disabled {
        opacity: 0.4;
        pointer-events: none;
        background: var(--bg-disabled);
        font-style: italic;
    }

    .ms-item input {
        margin-right: 12px;
    }

.ms-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #f7fafc;
}

.ms-btn-accept {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.ms-btn-cancel {
    background: #edf2f7;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.ms-container.is-empty {
    opacity: 0.5;
    pointer-events: none; /* Evita que el usuario haga clic o abra el dropdown */
    filter: grayscale(0.5);
    cursor: not-allowed;
}

/* Contenedor en estado de carga */
.ms-container.is-loading {
    pointer-events: none;
    cursor: wait;
}

    .ms-container.is-loading .ms-trigger {
        background-color: #f7fafc;
        border-color: var(--border);
        color: transparent !important; /* Esconde el placeholder/badges mientras carga */
        position: relative;
    }

        /* Spinner animado */
        .ms-container.is-loading .ms-trigger::after {
            content: "";
            position: absolute;
            width: 18px;
            height: 18px;
            top: calc(50% - 9px);
            left: calc(50% - 9px);
            border: 2px solid #e2e8f0;
            border-top-color: var(--primary);
            border-radius: 50%;
            animation: ms-spin 0.6s linear infinite;
        }

@keyframes ms-spin {
    to {
        transform: rotate(360deg);
    }
}
