/* ====================================================================
   Sistema de Funcionalidades (buscador de modales)
   - Pestañas del drawer (Funcionalidades / Menú / Mapa)
   - Listas de resultados, esenciales y recientes
   - Pestaña Mapa (árbol por modal)
   - Command palette global (Ctrl+K)
   - Editor del catálogo (solo administrar_todo)
   Tema violeta del sistema (#5B21B6 / #7c3aed).
   ==================================================================== */

/* ------------------ Pestañas del drawer ------------------ */
.fnc-drawer-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px 0 10px;
    background: #faf8ff;
    border-bottom: 1px solid #ede9fe;
    flex-shrink: 0;
}

.fnc-drawer-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 12.5px;
    font-weight: 600;
    padding: 9px 4px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    border-bottom: 2.5px solid transparent;
    white-space: nowrap;
    transition: color .15s, background .15s;
}

.fnc-drawer-tab i {
    font-size: 17px;
}

.fnc-drawer-tab:hover {
    color: #5B21B6;
    background: #f5f3ff;
}

.fnc-drawer-tab-active {
    color: #5B21B6;
    border-bottom-color: #7c3aed;
    background: #f5f3ff;
}

/* ------------------ Panel común ------------------ */
.fnc-panel {
    /* Sin padding superior: el buscador sticky (blanco) pega arriba y tapa
       el contenido que scrollea por debajo (la franja transparente dejaba
       ver el texto pasar). El aire lateral/inferior se mantiene. */
    padding: 0 10px 16px 10px;
}

/* La pestaña Mapa no tiene buscador sticky; recupera el aire superior. */
.fnc-mapa {
    padding-top: 10px;
}

.fnc-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 10.5px;
    color: #9ca3af;
    flex-wrap: wrap;
}

.fnc-hint kbd {
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 4px;
    padding: 0 4px;
    font-size: 10px;
    color: #5B21B6;
}

.fnc-hint-palette {
    cursor: pointer;
}

.fnc-hint-palette:hover {
    color: #7c3aed;
}

/* ------------------ Items (compartidos por las 3 vistas) ------------------ */
.fnc-list {
    margin-top: 10px;
}

.fnc-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #7c3aed;
    margin: 14px 4px 6px 4px;
}

.fnc-section-title i {
    font-size: 15px;
}

.fnc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s;
}

.fnc-item:hover,
.fnc-item-sel {
    background: #f5f3ff;
}

.fnc-item-sel {
    box-shadow: inset 0 0 0 1.5px #ddd6fe;
}

.fnc-item-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
    color: #fff;
    font-size: 19px;
}

.fnc-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.fnc-item-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.25;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fnc-item-title mark {
    background: #ede9fe;
    color: #5B21B6;
    padding: 0 1px;
    border-radius: 3px;
}

.fnc-item-desc {
    font-size: 11.5px;
    color: #6b7280;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.fnc-item-group {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    color: #7c3aed;
    background: #f5f3ff;
    border: 1px solid #ede9fe;
    border-radius: 999px;
    padding: 2px 8px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fnc-item-group mark {
    background: #ddd6fe;
    color: #5B21B6;
    padding: 0;
    border-radius: 2px;
}

.fnc-star {
    font-size: 13px !important;
    color: #f59e0b;
}

.fnc-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 26px 12px;
    color: #9ca3af;
    font-size: 13px;
    text-align: center;
}

.fnc-empty i {
    font-size: 34px;
    color: #ddd6fe;
}

/* ------------------ Pestaña Mapa ------------------ */
.fnc-mapa-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px;
}

.fnc-mapa-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #5B21B6;
}

.fnc-mapa-title i {
    font-size: 18px;
}

.fnc-mapa-gear {
    border: none;
    background: #f5f3ff;
    color: #7c3aed;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}

.fnc-mapa-gear:hover {
    background: #ede9fe;
}

.fnc-mapa-gear i {
    font-size: 18px;
}

.fnc-mapa-grupo {
    margin-bottom: 6px;
    border: 1px solid #ede9fe;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.fnc-mapa-grupo-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    background: #faf8ff;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
    text-align: left;
}

.fnc-mapa-grupo-icon {
    color: #7c3aed;
    font-size: 19px;
}

.fnc-mapa-grupo-count {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 700;
    color: #7c3aed;
    background: #ede9fe;
    border-radius: 999px;
    padding: 1px 8px;
}

.fnc-mapa-chevron {
    color: #9ca3af;
    font-size: 19px;
}

.fnc-mapa-grupo-items {
    padding: 4px 6px 6px 6px;
}

/* ------------------ Command palette (Ctrl+K) ------------------ */
.fnc-pal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 6, 38, 0.55);
    backdrop-filter: blur(2px);
    z-index: 100050;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 9vh 12px 12px 12px;
}

.fnc-pal-panel {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.fnc-pal-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #ede9fe;
    flex-shrink: 0;
}

.fnc-pal-input-row > i {
    color: #7c3aed;
    font-size: 21px;
}

.fnc-pal-input-row input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    color: #1f2937;
    background: transparent;
}

.fnc-pal-input-row input::placeholder {
    color: #9ca3af;
}

.fnc-pal-esc {
    font-size: 10.5px;
    font-weight: 700;
    color: #7c3aed;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 5px;
    padding: 2px 7px;
    cursor: pointer;
}

.fnc-pal-results {
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

/* ------------------ Editor del catálogo ------------------ */
.fnc-ed-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 6, 38, 0.55);
    backdrop-filter: blur(2px);
    z-index: 100060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.fnc-ed-panel {
    width: 100%;
    max-width: 760px;
    max-height: 88vh;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fnc-ed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
    color: #fff;
    flex-shrink: 0;
}

.fnc-ed-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
}

.fnc-ed-close {
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.fnc-ed-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.fnc-ed-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 18px;
}

.fnc-ed-help {
    font-size: 12px;
    color: #6b7280;
    background: #faf8ff;
    border: 1px solid #ede9fe;
    border-radius: 10px;
    padding: 9px 12px;
    margin: 0 0 12px 0;
}

.fnc-ed-help code {
    color: #5B21B6;
    background: #f5f3ff;
    padding: 0 4px;
    border-radius: 4px;
}

.fnc-ed-grupo {
    border: 1px solid #ede9fe;
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
}

.fnc-ed-grupo-head {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #faf8ff;
    padding: 8px 10px;
}

.fnc-ed-expander {
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    padding: 2px;
}

.fnc-ed-grupo-icon {
    color: #7c3aed;
    font-size: 19px;
}

.fnc-ed-grupo-head .fnc-ed-grupo-titulo {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    font-weight: 700;
}

.fnc-ed-grupo-head .fnc-ed-grupo-icono {
    flex: 0 0 110px;
    width: 110px;
}

.fnc-ed-grupo-body {
    padding: 8px 10px 10px 10px;
}

.fnc-ed-item {
    border: 1px solid #f1eefb;
    border-radius: 10px;
    margin-bottom: 6px;
    overflow: hidden;
}

.fnc-ed-item-open {
    border-color: #ddd6fe;
    box-shadow: 0 2px 8px rgba(91, 33, 182, 0.08);
}

.fnc-ed-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: none;
    background: #fff;
    padding: 8px 10px;
    cursor: pointer;
    text-align: left;
}

.fnc-ed-item-row:hover {
    background: #faf8ff;
}

.fnc-ed-item-row > i {
    color: #7c3aed;
    font-size: 18px;
}

.fnc-ed-item-titulo {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

.fnc-ed-item-permiso {
    font-size: 10px;
    font-weight: 700;
    color: #7c3aed;
    background: #f5f3ff;
    border-radius: 999px;
    padding: 1px 8px;
}

.fnc-ed-item-chevron {
    color: #9ca3af;
    font-size: 18px;
}

.fnc-ed-form {
    padding: 10px 12px 12px 12px;
    background: #fcfbff;
    border-top: 1px solid #f1eefb;
}

.fnc-ed-row {
    margin-bottom: 9px;
}

.fnc-ed-row label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #5B21B6;
    margin-bottom: 3px;
}

.fnc-ed-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 575px) {
    .fnc-ed-row-2 {
        grid-template-columns: 1fr;
    }
}

.fnc-ed-input {
    width: 100%;
    border: 1px solid #ddd6fe;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    color: #1f2937;
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.fnc-ed-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.fnc-ed-input-err {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.fnc-ed-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
}

.fnc-ed-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    margin: 0;
    font-weight: 500;
}

.fnc-ed-form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.fnc-ed-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    transition: filter .15s, background .15s;
}

.fnc-ed-btn i {
    font-size: 16px;
}

.fnc-ed-btn:disabled {
    opacity: .6;
    cursor: default;
}

.fnc-ed-btn-primary {
    background: linear-gradient(135deg, #5B21B6 0%, #7c3aed 100%);
    color: #fff;
}

.fnc-ed-btn-primary:hover:not(:disabled) {
    filter: brightness(1.08);
}

.fnc-ed-btn-ghost {
    background: #f5f3ff;
    color: #5B21B6;
}

.fnc-ed-btn-ghost:hover:not(:disabled) {
    background: #ede9fe;
}

.fnc-ed-btn-danger {
    background: #fef2f2;
    color: #dc2626;
}

.fnc-ed-btn-danger:hover {
    background: #fee2e2;
}

.fnc-ed-btn-icon {
    border: none;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: #9ca3af;
}

.fnc-ed-del:hover {
    background: #fef2f2;
    color: #dc2626;
}

.fnc-ed-add-item {
    width: 100%;
    justify-content: center;
    margin-top: 2px;
}

.fnc-ed-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid #ede9fe;
    background: #faf8ff;
    flex-shrink: 0;
}

/* En pantallas chicas el editor ocupa casi todo, respetando el nav inferior */
@media (max-width: 767px) {
    .fnc-ed-overlay {
        padding: 10px 8px calc(10px + var(--bottom-nav-height, 48px) + var(--wf-taskbar-height, 0px)) 8px;
    }

    .fnc-ed-panel {
        max-height: 100%;
    }

    .fnc-pal-overlay {
        padding: 5vh 8px calc(10px + var(--bottom-nav-height, 48px)) 8px;
    }
}
