/*
 * =======================================================================
 * Librerías Geolocalization — Frontend
 * Paleta alineada con events_geolocalization (navy + blue + light bg).
 * =======================================================================
 */

/* -----------------------------------------------------------------------
 * Design tokens
 * --------------------------------------------------------------------- */
.pl-librerias-hub {
    /* Palette — coherente con events plugin */
    --pl-navy:        #132f52;
    --pl-navy-soft:   #1e4478;
    --pl-blue:        #2563eb;
    --pl-blue-soft:   #5b82d9;
    --pl-blue-wash:   rgba(37, 99, 235, 0.08);
    --pl-red:         #e11d48;
    --pl-green:       #16a34a;
    --pl-bg-page:     #e8eef7;
    --pl-surface:     #ffffff;
    --pl-surface-2:   #f8fafc;
    --pl-hairline:    #cbd5e1;
    --pl-hairline-2:  #e2e8f0;
    --pl-text:        #0f172a;
    --pl-text-2:      #334155;
    --pl-text-muted:  #64748b;

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;

    /* Elevation */
    --shadow-xs: 0 1px 2px rgba(19, 47, 82, 0.05);
    --shadow-sm: 0 1px 3px rgba(19, 47, 82, 0.06);
    --shadow-md: 0 4px 14px rgba(19, 47, 82, 0.08);
    --shadow-lg: 0 10px 30px -10px rgba(19, 47, 82, 0.22);

    /* Motion */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    /* Root */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--pl-text);
    background: var(--pl-bg-page);
    box-sizing: border-box;

    height: calc(100vh - 80px);
    height: calc(100dvh - 80px);
    min-height: 620px;
    max-height: 1400px;

    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 1.5rem;
    margin: 12px 0;

    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.pl-librerias-hub *,
.pl-librerias-hub *::before,
.pl-librerias-hub *::after { box-sizing: border-box; }

/* -----------------------------------------------------------------------
 * Top bar — brand + filters
 * --------------------------------------------------------------------- */
.pl-librerias-hub__bar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--pl-hairline-2);
}

.pl-librerias-hub__brand {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 18px;
    min-width: 0;
}

.pl-librerias-hub__eyebrow {
    font-size: clamp(1.4rem, 2.5vw, 1.9rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.025em;
    color: var(--pl-navy);
    margin: 0;
    text-wrap: balance;
}

.pl-librerias-hub__eyebrow em {
    font-style: normal;
    color: var(--pl-blue);
}

.pl-librerias-hub__meta {
    font-size: 0.82rem;
    color: var(--pl-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.pl-librerias-hub .pl-librerias-count {
    font-size: 1rem;
    font-weight: 800;
    color: var(--pl-navy);
    font-variant-numeric: tabular-nums;
    text-shadow: none !important;
    font-style: normal;
}

.pl-librerias-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--pl-blue);
    font-weight: 600;
}
.pl-librerias-loading::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--pl-blue);
    animation: plPulse 1s var(--ease) infinite;
}
@keyframes plPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .4; transform: scale(.7); }
}

/* -----------------------------------------------------------------------
 * Filters
 * --------------------------------------------------------------------- */
.pl-librerias-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    min-width: 0;
}

.pl-librerias-field {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.pl-librerias-field__label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--pl-text-muted);
    padding-left: 2px;
}

.pl-librerias-field--search {
    flex: 2 1 260px;
    min-width: 200px;
}
.pl-librerias-field--provincia,
.pl-librerias-field--localidad {
    flex: 1 1 160px;
    min-width: 140px;
}
.pl-librerias-field--actions {
    flex: 1 1 auto;
    flex-direction: row;
    align-items: stretch;
    align-self: flex-end;
    gap: 8px;
    padding-top: 18px; /* Compensa label (~14px) + gap (4px) para alinear con inputs */
    min-width: 220px;
}
.pl-librerias-field--actions .pl-librerias-btn {
    flex: 1 1 auto;
}

/* Input with inline icon */
.pl-librerias-input {
    position: relative;
    display: flex;
    align-items: center;
}
.pl-librerias-input__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--pl-text-muted);
    pointer-events: none;
    transition: color .2s var(--ease);
}

.pl-librerias-hub input[type="search"],
.pl-librerias-hub select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--pl-text);
    background: var(--pl-surface);
    border: 1px solid var(--pl-hairline);
    border-radius: var(--r-sm);
    outline: none;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
    appearance: none;
    -webkit-appearance: none;
    box-shadow: var(--shadow-xs);
}

.pl-librerias-hub input[type="search"]::placeholder {
    color: var(--pl-text-muted);
    font-style: normal;
    opacity: .85;
}

.pl-librerias-hub .pl-librerias-input input[type="search"] {
    padding-left: 42px;
}

.pl-librerias-hub select {
    padding-right: 40px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%232563eb' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

.pl-librerias-hub input[type="search"]:focus,
.pl-librerias-hub select:focus {
    border-color: var(--pl-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.pl-librerias-hub .pl-librerias-input:focus-within .pl-librerias-input__icon {
    color: var(--pl-blue);
}

.pl-librerias-hub select:disabled {
    opacity: .55;
    cursor: not-allowed;
    background-color: var(--pl-surface-2);
}

/* -----------------------------------------------------------------------
 * Buttons
 * --------------------------------------------------------------------- */
.pl-librerias-hub .pl-librerias-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    cursor: pointer;
    text-decoration: none;
    text-transform: none;
    text-shadow: none;
    transition: all .2s var(--ease);
    position: relative;
    min-width: 0;
    min-height: 0;
}

.pl-librerias-hub .pl-librerias-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
}

.pl-librerias-hub .pl-librerias-btn--primary,
.pl-librerias-hub .pl-librerias-btn--primary:visited {
    background: var(--pl-blue);
    background-image: none;
    color: #fff;
    border: 1px solid var(--pl-blue);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25), 0 4px 10px -4px rgba(37, 99, 235, 0.45);
}
.pl-librerias-hub .pl-librerias-btn--primary:hover,
.pl-librerias-hub .pl-librerias-btn--primary:focus {
    background: #1d4ed8;
    background-image: none;
    color: #fff;
    border-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3), 0 8px 18px -6px rgba(37, 99, 235, 0.5);
}
.pl-librerias-hub .pl-librerias-btn--primary:active { transform: translateY(0); }

.pl-librerias-hub .pl-librerias-btn--ghost,
.pl-librerias-hub .pl-librerias-btn--ghost:visited {
    background: var(--pl-surface);
    background-image: none;
    color: var(--pl-navy);
    border: 1px solid var(--pl-hairline);
    box-shadow: var(--shadow-xs);
}
.pl-librerias-hub .pl-librerias-btn--ghost:hover,
.pl-librerias-hub .pl-librerias-btn--ghost:focus {
    background: var(--pl-surface);
    background-image: none;
    border-color: var(--pl-blue);
    color: var(--pl-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.pl-librerias-hub .pl-librerias-btn:disabled {
    opacity: .55;
    cursor: wait;
}

/* -----------------------------------------------------------------------
 * Body — Map + Sidebar
 * --------------------------------------------------------------------- */
.pl-librerias-hub__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    min-height: 0;
    min-width: 0;
}

@media (min-width: 900px) {
    .pl-librerias-hub__body {
        grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    }
}

.pl-librerias-map-col {
    position: relative;
    min-width: 0;
    min-height: 340px;
    border-radius: var(--r-md);
    overflow: hidden;
    background: #dbe4f1;
    border: 1px solid var(--pl-hairline-2);
    box-shadow: var(--shadow-sm);
}

.pl-librerias-map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Leaflet chrome */
.pl-librerias-hub .leaflet-container {
    background: #dbe4f1;
    font-family: inherit;
}
.pl-librerias-hub .leaflet-control-zoom a {
    background: var(--pl-surface);
    color: var(--pl-navy);
    border: 1px solid var(--pl-hairline);
    font-weight: 700;
    border-radius: 8px !important;
    width: 34px;
    height: 34px;
    line-height: 34px;
}
.pl-librerias-hub .leaflet-control-zoom a + a {
    margin-top: 4px;
}
.pl-librerias-hub .leaflet-control-zoom a:hover {
    background: var(--pl-blue);
    color: #fff;
    border-color: var(--pl-blue);
}
.pl-librerias-hub .leaflet-control-attribution {
    background: rgba(255,255,255,.92);
    color: var(--pl-text-muted);
    font-size: 11px;
    border-top-left-radius: 6px;
    padding: 2px 8px;
}
.pl-librerias-hub .leaflet-control-attribution a {
    color: var(--pl-blue);
}

/* -----------------------------------------------------------------------
 * Sidebar
 * --------------------------------------------------------------------- */
.pl-librerias-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    gap: 12px;
    overflow: hidden;
}

.pl-librerias-sidebar__inner {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    margin-right: -4px;
    scrollbar-width: thin;
    scrollbar-color: var(--pl-hairline) transparent;
}

.pl-librerias-sidebar__inner::-webkit-scrollbar { width: 8px; }
.pl-librerias-sidebar__inner::-webkit-scrollbar-track { background: transparent; }
.pl-librerias-sidebar__inner::-webkit-scrollbar-thumb {
    background: var(--pl-hairline);
    border-radius: var(--r-pill);
}
.pl-librerias-sidebar__inner::-webkit-scrollbar-thumb:hover { background: var(--pl-blue-soft); }

/* Nearest panel */
.pl-librerias-nearest {
    position: relative;
    background: var(--pl-surface);
    border: 1px solid rgba(37, 99, 235, 0.22);
    border-radius: var(--r-md);
    padding: 14px 14px 10px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}
.pl-librerias-nearest[hidden] { display: none; }

.pl-librerias-nearest__heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--pl-hairline-2);
}

.pl-librerias-nearest__title {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--pl-navy);
    margin: 0;
    letter-spacing: -0.01em;
}
.pl-librerias-nearest__title em {
    font-style: normal;
    color: var(--pl-blue);
}

.pl-librerias-nearest__kicker {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--pl-blue);
    font-weight: 800;
    background: var(--pl-blue-wash);
    padding: 3px 8px;
    border-radius: var(--r-pill);
}

.pl-librerias-nearest__list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.pl-librerias-nearest__list .pl-libreria-card {
    background: transparent;
    border: 0;
    border-top: 1px solid var(--pl-hairline-2);
    border-radius: 0;
    padding: 10px 4px;
    box-shadow: none;
}
.pl-librerias-nearest__list .pl-libreria-card:first-child {
    border-top: 0;
    padding-top: 4px;
}
.pl-librerias-nearest__list .pl-libreria-card:hover {
    transform: none;
    background: var(--pl-blue-wash);
    border-top-color: var(--pl-hairline-2);
}

/* -----------------------------------------------------------------------
 * List / Cards
 * --------------------------------------------------------------------- */
.pl-librerias-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pl-libreria-card {
    position: relative;
    background: var(--pl-surface);
    border: 1px solid var(--pl-hairline-2);
    border-radius: var(--r-md);
    padding: 14px 16px;
    cursor: pointer;
    transition:
        border-color .2s var(--ease),
        background .2s var(--ease),
        transform .15s var(--ease),
        box-shadow .2s var(--ease);
    box-shadow: var(--shadow-xs);
}
.pl-libreria-card:hover,
.pl-libreria-card:focus-within {
    border-color: rgba(37, 99, 235, 0.4);
    background: var(--pl-surface);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.pl-libreria-card:active { transform: translateY(0); }

.pl-libreria-card__title {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--pl-navy);
    margin: 0 90px 6px 0;
    letter-spacing: -0.01em;
}

.pl-libreria-card__title .pl-librerias-badge-medal {
    display: inline-block;
    margin-right: 6px;
    font-size: 17px;
    vertical-align: baseline;
}

.pl-libreria-card__addr {
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--pl-text-2);
    margin: 0 0 8px;
}

.pl-libreria-card__distance {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--pl-blue);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    border-radius: var(--r-pill);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.pl-libreria-card__contact {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 0.8rem;
    color: var(--pl-text-2);
    margin-bottom: 6px;
}
.pl-libreria-card__contact a {
    color: var(--pl-text-2);
    text-decoration: none;
    border-bottom: 1px dotted var(--pl-hairline);
    transition: color .15s var(--ease), border-color .15s var(--ease);
}
.pl-libreria-card__contact a:hover {
    color: var(--pl-blue);
    border-bottom-color: var(--pl-blue);
}

.pl-libreria-card__socials {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}
.pl-libreria-card__socials a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    min-width: 36px;
    padding: 0 10px;
    background: var(--pl-surface-2);
    color: var(--pl-text-2);
    border: 1px solid var(--pl-hairline-2);
    border-radius: var(--r-sm);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    transition: all .15s var(--ease);
}
.pl-libreria-card__socials a:hover {
    background: var(--pl-blue-wash);
    color: var(--pl-blue);
    border-color: rgba(37, 99, 235, 0.35);
}

/* Empty state */
.pl-librerias-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--pl-text-muted);
    font-size: 0.9rem;
    background: var(--pl-surface);
    border: 1px dashed var(--pl-hairline);
    border-radius: var(--r-md);
}

/* -----------------------------------------------------------------------
 * Leaflet popup
 * --------------------------------------------------------------------- */
.pl-librerias-hub .leaflet-popup-content-wrapper {
    background: var(--pl-surface);
    border-radius: var(--r-md);
    border: 1px solid rgba(37, 99, 235, 0.22);
    box-shadow: var(--shadow-lg);
    padding: 2px;
}
.pl-librerias-hub .leaflet-popup-tip {
    background: var(--pl-surface);
    border: 1px solid rgba(37, 99, 235, 0.22);
}
.pl-librerias-hub .leaflet-popup-content {
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 12px 14px;
    color: var(--pl-text-2);
}
.pl-librerias-popup {
    min-width: 220px;
    max-width: 280px;
}
.pl-librerias-popup strong {
    display: block;
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.25;
    color: var(--pl-navy);
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}
.pl-librerias-popup a {
    color: var(--pl-blue);
    text-decoration: none;
    font-weight: 600;
}
.pl-librerias-popup a:hover { text-decoration: underline; }
.pl-librerias-popup em {
    display: inline-block;
    margin-top: 6px;
    color: var(--pl-blue);
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    background: var(--pl-blue-wash);
    padding: 2px 8px;
    border-radius: var(--r-pill);
}

/* -----------------------------------------------------------------------
 * Responsive
 * --------------------------------------------------------------------- */
@media (max-width: 899px) {
    .pl-librerias-hub {
        height: auto;
        min-height: 0;
        max-height: none;
        grid-template-rows: auto auto;
    }
    .pl-librerias-hub__body {
        grid-template-rows: 420px auto;
    }
    .pl-librerias-map-col {
        min-height: 420px;
    }
    .pl-librerias-sidebar {
        max-height: 600px;
    }
}

@media (max-width: 600px) {
    .pl-librerias-hub { padding: 1.1rem; margin: 10px 0; }
    .pl-librerias-field--actions {
        flex: 1 1 100%;
        justify-content: stretch;
    }
    .pl-librerias-field--actions .pl-librerias-btn { flex: 1 1 auto; }
}

/* Islas Malvinas Argentinas overlay label */
.pl-malvinas-label {
    font-size: 9px;
    font-weight: 600;
    color: #444;
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.02em;
    pointer-events: none;
    white-space: nowrap;
}
.pl-malvinas-label em {
    font-style: normal;
    font-weight: 400;
}

/* Malvinas overlay: mix-blend-mode multiply makes white pixels transparent */
.pl-malvinas-overlay {
    mix-blend-mode: multiply;
}
