/**
 * This file is part of CommandPalette plugin for FacturaScripts.
 * Copyright (C) 2026 Ernesto Serrano <info@ernesto.es>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 */

.command-palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.command-palette-overlay.open {
    opacity: 1;
    visibility: visible;
}

.command-palette {
    width: 100%;
    max-width: 600px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.95) translateY(-10px);
    transition: transform 0.15s ease;
}

.command-palette-overlay.open .command-palette {
    transform: scale(1) translateY(0);
}

.command-palette-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.command-palette-header .search-icon {
    color: #9ca3af;
    margin-right: 12px;
    font-size: 16px;
}

.command-palette-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    background: transparent;
    color: #111827;
}

.command-palette-input::placeholder {
    color: #9ca3af;
}

.command-palette-header .close-hint {
    color: #9ca3af;
    font-size: 12px;
    padding: 4px 8px;
    background: #f3f4f6;
    border-radius: 4px;
}

.command-palette-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.command-palette-category {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.command-palette-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.command-palette-item:hover,
.command-palette-item.selected {
    background: #f3f4f6;
}

.command-palette-item.selected {
    background: var(--ge-bg, #d7f2ea);
}

.command-palette-item .item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 6px;
    margin-right: 12px;
    color: #6b7280;
    font-size: 14px;
}

.command-palette-item.selected .item-icon {
    background: var(--ge-primary, #16bd95);
    color: #ffffff;
}

.command-palette-item .item-content {
    flex: 1;
    min-width: 0;
}

.command-palette-item .item-title {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.command-palette-item .item-badge {
    font-size: 12px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
}

.command-palette-item.selected .item-badge {
    background: var(--ge-primary, #16bd95);
    color: #ffffff;
}

.command-palette-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 12px;
    color: #6b7280;
}

.command-palette-footer kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #374151;
    border: 1px solid #1f2937;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.command-palette-empty {
    padding: 24px;
    text-align: center;
    color: #6b7280;
}

.command-palette-empty .empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.5;
}

.command-palette-empty .empty-text {
    font-size: 14px;
}

/* Navbar trigger button */
.command-palette-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin: 0 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.command-palette-trigger:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.command-palette-trigger:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.command-palette-trigger i {
    font-size: 12px;
    opacity: 0.8;
}

.command-palette-trigger .trigger-text {
    opacity: 0.9;
}

.command-palette-trigger kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-left: 4px;
}

/* Responsive: con la navbar aún expandida (antes del menú hamburguesa) el buscador
   no debe robar espacio ni cortar los iconos de la barra.
   - 1200–1400px: el trigger se reduce a SOLO el icono (se oculta el texto y la tecla).
   - 992–1200px: el trigger DESAPARECE por completo (Ctrl+K / Cmd+K sigue funcionando).
   - <992px (menú hamburguesa): se mantiene normal dentro del menú desplegado. */
@media (min-width: 992px) and (max-width: 1400px) {
    .command-palette-trigger .trigger-text,
    .command-palette-trigger kbd {
        display: none;
    }
    .command-palette-trigger {
        gap: 0;
        padding: 6px 9px;
        margin: 0 4px;
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .command-palette-trigger {
        display: none !important;
    }
}
