/* ============================================================
   Dynamic Search — Estilos
   ============================================================ */

:root {
    --ds-primary:      #2563eb;
    --ds-primary-dark: #1d4ed8;
    --ds-bg:           #ffffff;
    --ds-bg-hover:     #f8faff;
    --ds-border:       #e2e8f0;
    --ds-shadow:       0 8px 32px rgba(37,99,235,0.13), 0 2px 8px rgba(0,0,0,0.07);
    --ds-text:         #1e293b;
    --ds-muted:        #64748b;
    --ds-radius:       12px;
    --ds-input-h:      52px;
}

/* ── Contenedor principal ── */
.ds-search-wrapper {
    position:    relative;
    max-width:   640px;
    width:       100%;
    font-family: inherit;
}

/* ── Versión menú: más compacta ── */
li.ds-menu-item {
    display:     flex !important;
    align-items: center;
    list-style:  none;
}

.ds-menu-item .ds-search-wrapper {
    max-width:  260px;
    width:      260px;
}

.ds-menu-item .ds-input-wrap {
    height:        38px;
    border-radius: 20px;
    padding:       0 12px;
}

.ds-menu-item .ds-input {
    font-size: .875rem !important;
}

.ds-menu-item .ds-icon svg {
    width:  16px;
    height: 16px;
}

.ds-menu-item .ds-results {
    min-width: 320px;
}

/* ── Caja del input ── */
.ds-input-wrap {
    display:     flex;
    align-items: center;
    background:  var(--ds-bg);
    border:      2px solid var(--ds-border);
    border-radius: var(--ds-radius);
    height:      var(--ds-input-h);
    padding:     0 14px;
    transition:  border-color .2s, box-shadow .2s;
    position:    relative;
    z-index:     10;
}

.ds-search-wrapper.ds-active .ds-input-wrap,
.ds-input-wrap:focus-within {
    border-color: var(--ds-primary);
    box-shadow:   0 0 0 3px rgba(37,99,235,.15);
}

/* ── Icono lupa ── */
.ds-icon {
    display:      flex;
    align-items:  center;
    flex-shrink:  0;
    color:        var(--ds-muted);
    margin-right: 8px;
    transition:   color .2s;
}

.ds-icon svg {
    width:  20px;
    height: 20px;
}

.ds-input-wrap:focus-within .ds-icon {
    color: var(--ds-primary);
}

/* ── Input ── */
.ds-input {
    flex:       1;
    border:     none !important;
    outline:    none !important;
    background: transparent !important;
    font-size:  1rem !important;
    color:      var(--ds-text) !important;
    padding:    0 !important;
    margin:     0 !important;
    box-shadow: none !important;
    line-height: 1.5;
}

.ds-input::placeholder {
    color: var(--ds-muted);
}

/* ── Botón limpiar ── */
.ds-clear {
    display:         flex;
    align-items:     center;
    justify-content: center;
    background:      none;
    border:          none;
    cursor:          pointer;
    color:           var(--ds-muted);
    padding:         4px;
    margin-left:     6px;
    border-radius:   50%;
    transition:      background .15s, color .15s;
    flex-shrink:     0;
    width:           28px;
    height:          28px;
}

.ds-clear:hover {
    background: #f1f5f9;
    color:      var(--ds-text);
}

.ds-clear svg {
    width:  14px;
    height: 14px;
}

/* ── Spinner ── */
.ds-spinner {
    display:     flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 8px;
}

.ds-spinner::after {
    content:       '';
    width:         16px;
    height:        16px;
    border:        2px solid var(--ds-border);
    border-top-color: var(--ds-primary);
    border-radius: 50%;
    animation:     ds-spin .6s linear infinite;
}

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

/* ── Panel de resultados ── */
.ds-results {
    position:   absolute;
    top:        calc(100% + 6px);
    left:       0;
    right:      0;
    background: var(--ds-bg);
    border:     1.5px solid var(--ds-border);
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow);
    overflow:   visible;
    z-index:    9999;

    opacity:        0;
    transform:      translateY(-6px) scale(.98);
    pointer-events: none;
    transition:     opacity .18s ease, transform .18s ease;
}

.ds-results.ds-results--visible {
    opacity:        1;
    transform:      translateY(0) scale(1);
    pointer-events: all;
}

/* ── Resultado individual ── */
.ds-result-item {
    display:         flex;
    align-items:     flex-start;
    gap:             12px;
    padding:         12px 16px;
    text-decoration: none !important;
    color:           var(--ds-text) !important;
    border-bottom:   1px solid var(--ds-border);
    transition:      background .12s;
    cursor:          pointer;
    line-height:     1.4;
}

.ds-result-item:last-child {
    border-bottom: none;
}

.ds-result-item:hover,
.ds-result-item:focus {
    background: var(--ds-bg-hover);
    outline:    none;
}

/* Miniatura */
.ds-result-thumb {
    width:         46px;
    height:        46px;
    flex-shrink:   0;
    border-radius: 6px;
    object-fit:    cover;
}

.ds-result-thumb--placeholder {
    display:         flex;
    align-items:     center;
    justify-content: center;
    background:      linear-gradient(135deg, #e0e7ff 0%, #dbeafe 100%);
    color:           var(--ds-primary);
    font-size:       18px;
    border-radius:   6px;
    width:           46px;
    height:          46px;
    flex-shrink:     0;
}

/* Texto */
.ds-result-body {
    flex:      1;
    min-width: 0;
}

.ds-result-title {
    font-size:     .9375rem;
    font-weight:   600;
    color:         var(--ds-text);
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
    display:       block;
    margin-bottom: 2px;
}

.ds-result-title mark {
    background:  rgba(37,99,235,.15);
    color:       var(--ds-primary-dark);
    border-radius: 2px;
    padding:     0 1px;
    font-weight: 700;
}

.ds-result-excerpt {
    font-size:          .8125rem;
    color:              var(--ds-muted);
    overflow:           hidden;
    display:            -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin:             0;
}

/* ── Sin resultados ── */
.ds-no-results {
    padding:    24px 20px;
    text-align: center;
    color:      var(--ds-muted);
    font-size:  .9375rem;
}

.ds-no-results strong {
    display:       block;
    color:         var(--ds-text);
    font-size:     1rem;
    margin-bottom: 4px;
}
