/* =============================================================================
   STORE LOCATOR — WCAG 2.2 AAA
   Palette: --Brand-Primary #023E84 | body text #1a1a1a | bg #f5f5f5 / #fff
   ============================================================================= */

/* ---------------------------------------------------------------------------
   0. Design tokens (mirrors css.css vars for standalone use)
   --------------------------------------------------------------------------- */
:root {
    --sl-blue:        #023E84;   /* Brand Primary */
    --sl-blue-light:  #809EC1;   /* Brand Primary Light */
    --sl-blue-dark:   #012960;   /* Brand Primary Dark */
    --sl-text:        #1a1a1a;   /* AAA contrast 18:1 on white */
    --sl-text-muted:  #595959;   /* AAA contrast 7.1:1 on white */
    --sl-bg:          #f5f5f5;
    --sl-white:       #ffffff;
    --sl-border:      #767676;   /* 3:1 contrast on white for non-text */
    --sl-focus-ring:  #023E84;
    --sl-focus-bg:    #ffffff;
    --sl-badge-bg:    #E8EFF7;
    --sl-badge-text:  #012960;
    --sl-card-hover:  #EBF0F8;
    --sl-active-card: #D4E1F5;
    --sl-error:       #C0392B;
    --sl-min-target:  44px;
}

/* ---------------------------------------------------------------------------
   1. Skip links (WCAG 2.4.1)
   --------------------------------------------------------------------------- */
.sl-skip-links {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
}

.sl-skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background: var(--sl-blue);
    color: var(--sl-white);
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 20px;
    text-decoration: none;
    white-space: nowrap;
    border-radius: 0 0 4px 0;
    min-height: var(--sl-min-target);
    display: flex;
    align-items: center;
}

.sl-skip-link:focus {
    position: fixed;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    overflow: visible;
    /* WCAG 2.4.13 focus indicator: high-contrast outline */
    outline: 3px solid var(--sl-white);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--sl-blue);
}

/* ---------------------------------------------------------------------------
   2. Global focus style — WCAG 2.4.13 AAA
      Requirement: enclosed area ≥ perimeter × 2px; contrast ≥ 3:1
   --------------------------------------------------------------------------- */
:focus-visible {
    outline: 3px solid var(--sl-focus-ring);
    outline-offset: 3px;
    border-radius: 3px;
}

/* Remove default browser outline only if we provide our own */
:focus:not(:focus-visible) {
    outline: none;
}

/* ---------------------------------------------------------------------------
   3. Page layout
   --------------------------------------------------------------------------- */
.sl-page {
    color: var(--sl-text);
    background: var(--sl-bg);
    min-height: 100vh;
}

/* hero / title band */
.sl-hero {
    background: var(--sl-blue);
    color: var(--sl-white);
    padding: 32px 24px;
}

.sl-hero h1 {
    font-size: clamp(1.375rem, 3vw, 2rem);
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.25;
}

.sl-hero p {
    margin: 0;
    font-size: 1rem;
    opacity: .9;
}

/* ---------------------------------------------------------------------------
   4. Search / filter bar — WCAG 1.3.5 (identify purpose), 2.5.3
   --------------------------------------------------------------------------- */
.sl-search-bar {
    background: var(--sl-white);
    border-bottom: 1px solid var(--sl-border);
    padding: 16px 24px;
}

.sl-search-bar form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    max-width: 960px;
}

.sl-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sl-field label {
    font-size: .875rem;
    font-weight: 600;
    color: var(--sl-text);
    white-space: nowrap;
}

/* Text input */
.sl-input {
    height: var(--sl-min-target);
    min-width: 220px;
    padding: 0 12px;
    border: 2px solid var(--sl-border);
    border-radius: 4px;
    font-size: 1rem;
    color: var(--sl-text);
    background: var(--sl-white);
    box-sizing: border-box;
}

.sl-input:focus-visible {
    border-color: var(--sl-blue);
    outline: 3px solid var(--sl-blue);
    outline-offset: 2px;
}

/* Select filter */
.sl-select {
    height: var(--sl-min-target);
    min-width: 180px;
    padding: 0 36px 0 12px;
    border: 2px solid var(--sl-border);
    border-radius: 4px;
    font-size: 1rem;
    color: var(--sl-text);
    background: var(--sl-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%23023E84' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 8px center;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    cursor: pointer;
}

.sl-select:focus-visible {
    border-color: var(--sl-blue);
    outline: 3px solid var(--sl-blue);
    outline-offset: 2px;
}

/* Search button */
.sl-btn-search {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: var(--sl-min-target);
    min-width: var(--sl-min-target);
    padding: 0 20px;
    background: var(--sl-blue);
    color: var(--sl-white);
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}

.sl-btn-search:hover {
    background: var(--sl-blue-dark);
}

.sl-btn-search:focus-visible {
    outline: 3px solid var(--sl-blue);
    outline-offset: 3px;
    background: var(--sl-blue-dark);
}

/* Clear button */
.sl-btn-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--sl-min-target);
    min-width: var(--sl-min-target);
    padding: 0 16px;
    background: transparent;
    color: var(--sl-blue);
    border: 2px solid var(--sl-blue);
    border-radius: 4px;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.sl-btn-clear:hover {
    background: var(--sl-badge-bg);
}

.sl-btn-clear:focus-visible {
    outline: 3px solid var(--sl-blue);
    outline-offset: 3px;
}

/* ---------------------------------------------------------------------------
   5. Results counter (aria-live region)
   --------------------------------------------------------------------------- */
.sl-results-count {
    background: var(--sl-white);
    padding: 8px 24px;
    font-size: .9375rem;
    font-weight: 600;
    color: var(--sl-text-muted);
    border-bottom: 1px solid #ddd;
    margin: 0;
}

.sl-results-count strong {
    color: var(--sl-blue);
}

/* ---------------------------------------------------------------------------
   6. Main split layout
   --------------------------------------------------------------------------- */
.sl-layout {
    display: flex;
    height: calc(100vh - 260px);
    min-height: 500px;
}

/* Map panel */
.sl-map-panel {
    flex: 1 1 60%;
    position: relative;
    background: #e0e0e0;
}

#sl-map {
    width: 100%;
    height: 100%;
}

/* No-map fallback message */
.sl-map-fallback {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    padding: 24px;
    text-align: center;
    background: #e8eef5;
    color: var(--sl-text-muted);
    font-size: .9375rem;
}

.sl-map-fallback.is-visible {
    display: flex;
}

/* List panel */
.sl-list-panel {
    flex: 0 0 40%;
    max-width: 460px;
    overflow-y: auto;
    background: var(--sl-white);
    border-left: 1px solid #ddd;
}

/* ---------------------------------------------------------------------------
   7. Store list
   --------------------------------------------------------------------------- */
.sl-store-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Empty state */
.sl-empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--sl-text-muted);
    font-size: .9375rem;
}

/* ---------------------------------------------------------------------------
   8. Store card
   --------------------------------------------------------------------------- */
.sl-store-card {
    border-bottom: 1px solid #e5e5e5;
    padding: 16px 20px;
    transition: background .12s;
}

.sl-store-card:hover {
    background: var(--sl-card-hover);
}

.sl-store-card.is-active {
    background: var(--sl-active-card);
    border-left: 4px solid var(--sl-blue);
}

/* Distance row */
.sl-card-distance {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .8125rem;
    color: var(--sl-text-muted);
    margin-bottom: 6px;
}

/* Badge tipo rivenditore */
.sl-badge {
    display: inline-block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--sl-badge-text);
    background: var(--sl-badge-bg);
    border: 1px solid var(--sl-blue-light);
    border-radius: 12px;
    padding: 2px 10px;
    margin-bottom: 6px;
    line-height: 1.6;
}

/* Store name heading */
.sl-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sl-text);
    margin: 0 0 6px;
    line-height: 1.3;
}

/* Address */
.sl-card-address {
    font-style: normal;
    font-size: .9375rem;
    color: var(--sl-text-muted);
    line-height: 1.5;
    margin: 0 0 12px;
}

/* Action row */
.sl-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* "Mostra sulla mappa" CTA */
.sl-btn-map {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--sl-min-target);
    padding: 0 16px;
    background: var(--sl-blue);
    color: var(--sl-white);
    border: none;
    border-radius: 4px;
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}

.sl-btn-map:hover {
    background: var(--sl-blue-dark);
    color: var(--sl-white);
}

.sl-btn-map:focus-visible {
    outline: 3px solid var(--sl-blue);
    outline-offset: 3px;
    background: var(--sl-blue-dark);
}

/* "Solo in lista" note (no coordinates) */
.sl-no-map-note {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .8125rem;
    color: var(--sl-text-muted);
    padding: 8px 0;
}

/* ---------------------------------------------------------------------------
   9. Loading state
   --------------------------------------------------------------------------- */
.sl-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    height: 200px;
    color: var(--sl-text-muted);
    font-size: .9375rem;
}

/* ---------------------------------------------------------------------------
   10. Error message
   --------------------------------------------------------------------------- */
.sl-error-msg {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 24px;
    color: var(--sl-error);
    font-size: .9375rem;
    background: #fdf3f2;
    border-left: 4px solid var(--sl-error);
    margin: 16px;
    border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   11. Responsive — mobile first
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .sl-layout {
        flex-direction: column;
        height: auto;
    }

    .sl-map-panel {
        flex: none;
        height: 50vw;
        min-height: 240px;
        max-height: 380px;
    }

    .sl-list-panel {
        flex: none;
        max-width: 100%;
        max-height: 60vh;
        border-left: none;
        border-top: 1px solid #ddd;
    }

    .sl-search-bar form {
        flex-direction: column;
        align-items: stretch;
    }

    .sl-input,
    .sl-select,
    .sl-btn-search,
    .sl-btn-clear {
        width: 100%;
    }

    .sl-btn-search,
    .sl-btn-clear {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .sl-hero {
        padding: 24px 16px;
    }

    .sl-search-bar {
        padding: 12px 16px;
    }

    .sl-results-count {
        padding: 8px 16px;
    }
}
