/* ================================================
   SEFAP Buscador — sefap-buscador.css
   Totalmente responsive: desktop centrado, móvil pantalla completa
================================================ */

:root {
    --sb-primary: #1C355E;
    --sb-accent:  #FAB512;
    --sb-bg:      #FFFFFF;
    --sb-muted:   #9A9288;
    --sb-border:  #E8E4DE;
    --sb-hover:   #F5F8FF;
    --sb-radius:  14px;
    --sb-shadow:  0 24px 60px rgba(0,0,0,0.28);
}

/* OVERLAY */
#sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.52);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
#sb-overlay.sb-open {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(56px, 9vh, 110px) 16px 16px;
    animation: sbFadeIn 0.18s ease forwards;
}
@keyframes sbFadeIn { from { opacity:0; } to { opacity:1; } }

/* PANEL */
#sb-panel {
    background: var(--sb-bg);
    border-radius: var(--sb-radius);
    width: 100%;
    max-width: 660px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--sb-shadow);
    overflow: hidden;
    animation: sbSlideIn 0.22s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes sbSlideIn {
    from { opacity:0; transform: translateY(-14px) scale(0.97); }
    to   { opacity:1; transform: translateY(0)     scale(1);    }
}

/* HEADER */
#sb-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sb-border);
    color: var(--sb-primary);
    flex-shrink: 0;
}
#sb-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 17px;
    color: var(--sb-primary);
    background: transparent;
    font-family: inherit;
    line-height: 1.4;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}
#sb-input::placeholder { color: var(--sb-muted); font-weight: 300; }
#sb-input::-webkit-search-cancel-button { display: none; }
#sb-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--sb-muted);
    padding: 0;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}
#sb-close:hover { color: var(--sb-primary); background: var(--sb-hover); }

/* ETIQUETAS — fuera del área scrollable, siempre visibles */
#sb-tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--sb-border);
    overflow-x: auto;
    flex-shrink: 0;
    background: var(--sb-bg);
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#sb-tags::-webkit-scrollbar { display: none; }
#sb-tags:empty { display: none; padding: 0; border: none; }

#sb-tags .sb-tag,
#sb-tags button.sb-tag {
    all: unset;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px !important;
    padding: 2px 7px !important;
    border: none !important;
    border-radius: 3px !important;
    background: #F0F0F0 !important;
    font-size: 10px !important;
    font-weight: 500 !important;
    color: #AAAAAA !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    font-family: inherit !important;
    flex-shrink: 0 !important;
    line-height: 1.5 !important;
    letter-spacing: 0.2px !important;
    transition: background 0.14s, color 0.14s !important;
    outline: none !important;
    box-shadow: none !important;
    text-decoration: none !important;
}
#sb-tags .sb-tag:hover,
#sb-tags button.sb-tag:hover { background: #E4E4E4 !important; color: #777 !important; }
#sb-tags .sb-tag.sb-tag-active,
#sb-tags button.sb-tag.sb-tag-active { background: var(--sb-primary) !important; color: #fff !important; }
#sb-tags .sb-tag-count { opacity: 0.55; }

/* BODY — solo resultados hacen scroll */
#sb-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--sb-border) transparent;
    -webkit-overflow-scrolling: touch;
}
#sb-body::-webkit-scrollbar { width: 4px; }
#sb-body::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 4px; }

/* RESULTADOS */
.sb-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 20px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--sb-border);
    transition: background 0.12s;
    cursor: pointer;
}
.sb-item:last-child { border-bottom: none; }
.sb-item:hover { background: var(--sb-hover); }

.sb-item-thumb {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--sb-border);
    display: block;
    margin-top: 2px;
}
.sb-item-thumb-placeholder {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    background: var(--sb-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--sb-muted);
    margin-top: 2px;
}
.sb-item-info { flex: 1; min-width: 0; }
.sb-item-type {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--sb-accent);
    display: block;
    margin-bottom: 3px;
}
.sb-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--sb-primary);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}
.sb-item-excerpt {
    font-size: 12px;
    color: var(--sb-muted);
    display: block;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sb-item-date {
    font-size: 11px;
    color: var(--sb-muted);
    flex-shrink: 0;
    white-space: nowrap;
    padding-top: 4px;
}

/* BOTONES ACF */
.sb-item-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 7px; }
.sb-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    background: none;
    border: none;
    border-bottom: 1px solid currentColor;
    font-size: 11px;
    font-weight: 600;
    color: var(--sb-primary);
    text-decoration: none;
    letter-spacing: 0.2px;
    transition: color 0.15s;
    white-space: nowrap;
    line-height: 1.6;
    font-family: inherit;
    cursor: pointer;
}
.sb-link-btn:hover { color: var(--sb-accent) !important; }
.sb-link-btn::before { content: '↗'; font-size: 10px; }

/* ESTADOS */
#sb-empty, #sb-loading, #sb-hint {
    padding: 36px 20px;
    text-align: center;
    color: var(--sb-muted);
    font-size: 14px;
    line-height: 1.6;
}
#sb-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--sb-border);
    border-top-color: var(--sb-primary);
    border-radius: 50%;
    animation: sbSpin 0.7s linear infinite;
    vertical-align: middle;
    margin-left: 8px;
}
@keyframes sbSpin { to { transform: rotate(360deg); } }

/* TABLET */
@media (max-width: 768px) {
    #sb-overlay.sb-open { padding: clamp(40px, 7vh, 80px) 12px 12px; }
    #sb-panel { max-height: 88vh; }
    .sb-item-date { display: none; }
    .sb-item-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* MÓVIL — PANTALLA COMPLETA */
@media (max-width: 600px) {
    #sb-overlay.sb-open {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }
    #sb-panel {
        border-radius: 0;
        max-width: 100%;
        width: 100%;
        max-height: 100dvh;
        max-height: 100vh;
        height: 100dvh;
        height: 100vh;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        animation: sbSlideUp 0.25s cubic-bezier(0.32,0.72,0,1) forwards;
    }
    @keyframes sbSlideUp {
        from { transform: translateY(60px); opacity: 0.6; }
        to   { transform: translateY(0);    opacity: 1;   }
    }
    #sb-header {
        padding: 14px 16px;
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }
    #sb-tags  { padding: 8px 16px; }
    #sb-input { font-size: 16px; }
    .sb-item  { padding: 12px 16px; gap: 12px; align-items: flex-start; }
    .sb-item-thumb,
    .sb-item-thumb-placeholder { width: 44px; height: 44px; }
    .sb-item-title {
        font-size: 13px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .sb-item-excerpt { display: none; }
    .sb-item-date    { display: none; }
    .sb-link-btn     { font-size: 12px; }
}
