/* Location Picker Component
   Reusable smart-search location selector.
   Mobile-first: bottom sheet on < 768px, dropdown on desktop.
*/

/* --- Trigger field --- */
.lp-field {
    position: relative;
    width: 100%;
}

.lp-trigger {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--pb-border);
    border-radius: var(--radius-md);
    background: var(--pb-surface);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--pb-text);
    transition: border-color var(--transition-fast);
    min-height: 42px;
}

.lp-trigger:hover {
    border-color: var(--pb-gold);
}

.lp-trigger-icon {
    margin-right: 0.5rem;
    color: var(--pb-text-secondary);
    flex-shrink: 0;
}

.lp-trigger-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lp-trigger-text.lp-placeholder {
    color: var(--pb-text-secondary);
}

.lp-trigger-clear {
    margin-left: 0.5rem;
    padding: 2px 6px;
    border: none;
    background: none;
    color: var(--pb-text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.lp-trigger-clear:hover {
    background: var(--pb-bg);
    color: var(--pb-text);
}

/* --- Overlay (mobile) --- */
.lp-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1040;
}

.lp-overlay.lp-open {
    display: block;
}

/* --- Panel (shared structure) --- */
.lp-panel {
    display: none;
    background: var(--pb-surface);
    z-index: 1050;
    overflow: hidden;
}

.lp-panel.lp-open {
    display: flex;
    flex-direction: column;
}

/* Mobile: bottom sheet */
@media (max-width: 767.98px) {
    .lp-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 80vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -4px 20px var(--pb-shadow);
    }

    .lp-panel.lp-open {
        animation: lp-slide-up 0.25s ease-out;
    }

    .lp-handle {
        display: flex;
        justify-content: center;
        padding: 8px 0 4px;
        cursor: grab;
    }

    .lp-handle::after {
        content: '';
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--pb-border);
    }
}

/* Desktop: dropdown */
@media (min-width: 768px) {
    .lp-panel {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        margin-top: 4px;
        max-height: 400px;
        border-radius: var(--radius-md);
        border: 1px solid var(--pb-border);
        box-shadow: 0 4px 16px var(--pb-shadow);
    }

    .lp-handle {
        display: none;
    }

    .lp-overlay {
        display: none !important;
    }
}

@keyframes lp-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* --- Search input --- */
.lp-search-wrap {
    padding: 0.75rem;
    border-bottom: 1px solid var(--pb-border);
    flex-shrink: 0;
    position: relative;
}

.lp-search {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--pb-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: var(--pb-bg);
    color: var(--pb-text);
    outline: none;
    transition: border-color var(--transition-fast);
}

.lp-search:focus {
    border-color: var(--pb-gold);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--pb-gold) 20%, transparent);
}

.lp-search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--pb-text-secondary);
    pointer-events: none;
}

/* --- Breadcrumb (block drill-down) --- */
.lp-breadcrumb {
    display: none;
    align-items: center;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--pb-border);
    font-size: 0.85rem;
    color: var(--pb-gold-dark);
    cursor: pointer;
    flex-shrink: 0;
}

.lp-breadcrumb.lp-visible {
    display: flex;
}

.lp-breadcrumb:hover {
    background: var(--pb-bg);
}

.lp-breadcrumb svg {
    margin-right: 0.4rem;
}

/* --- Results area --- */
.lp-results {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
}

.lp-group-label {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pb-text-secondary);
    font-family: var(--font-body);
}

.lp-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--pb-text);
    transition: background var(--transition-fast);
}

.lp-item:hover,
.lp-item.lp-active {
    background: var(--pb-bg);
}

.lp-item-parent {
    margin-left: 0.4rem;
    font-size: 0.8rem;
    color: var(--pb-text-secondary);
}

/* --- Block grid --- */
.lp-blocks {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.lp-block-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.25rem;
    border: 1px solid var(--pb-border);
    border-radius: var(--radius-md);
    background: var(--pb-surface);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--pb-text);
    transition: all var(--transition-fast);
    text-align: center;
}

.lp-block-btn:hover {
    border-color: var(--pb-gold);
    background: var(--pb-bg);
    color: var(--pb-gold-dark);
}

/* --- Recent chips --- */
.lp-recents {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem 0.5rem;
}

.lp-recent-chip {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--pb-border);
    border-radius: 999px;
    background: var(--pb-bg);
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--pb-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.lp-recent-chip:hover {
    border-color: var(--pb-gold);
    background: var(--pb-gold-light);
    color: var(--pb-gold-dark);
}

/* --- Empty / loading states --- */
.lp-empty {
    padding: 1.5rem 0.75rem;
    text-align: center;
    color: var(--pb-text-secondary);
    font-size: 0.85rem;
}

.lp-loading {
    padding: 1.5rem 0.75rem;
    text-align: center;
    color: var(--pb-text-secondary);
    font-size: 0.85rem;
}

/* --- "Ver todas" link --- */
.lp-show-all {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: var(--pb-gold-dark);
    cursor: pointer;
    font-weight: 500;
}

.lp-show-all:hover {
    text-decoration: underline;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .lp-panel.lp-open {
        animation: none;
    }
}
