/**
 * Branch Archive Template Styles
 *
 * Styles for the branches archive page with Leaflet map.
 */

/* Custom Properties for Merida Branding */
:root {
    --merida-primary: var(--global-palette1);
    /* primary accent */
    --merida-primary-dark: var(--global-palette2);
    /* primary accent alt */
    --merida-accent: var(--global-palette3);
    --merida-gray: var(--global-palette5);
    --merida-gray-light: var(--global-palette8);
    --merida-border: var(--global-palette6);
}

.branch-archive {
    padding: 0;
    max-width: none;
}

.branch-archive-container {
    max-width: var(--global-content-width, 1290px);
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

/* -------------------------------------------------------------------------
   Breadcrumbs
   ------------------------------------------------------------------------- */
.branch-archive .branch-breadcrumbs {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--merida-gray);
}

.branch-archive .branch-breadcrumbs a {
    color: inherit;
    text-decoration: none;
}

.branch-archive .branch-breadcrumbs a:hover {
    text-decoration: underline;
}

.branch-archive .branch-breadcrumbs .separator {
    margin: 0 0.5em;
}

.branch-archive .branch-breadcrumbs .current {
    color: #333;
}

/* -------------------------------------------------------------------------
   Page Title
   ------------------------------------------------------------------------- */
.branch-archive-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 2rem;
    color: #000;
}

/* -------------------------------------------------------------------------
   Grid Layout
   ------------------------------------------------------------------------- */
.branch-archive-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 2rem;
    align-items: start;
}

.branch-archive-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* -------------------------------------------------------------------------
   Filter
   ------------------------------------------------------------------------- */
.branch-filter {
    display: flex;
    gap: 0.5rem;
}

.branch-region-select {
    flex: 1;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--merida-border);
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 1rem center;
    background-size: 12px;
    appearance: none;
    cursor: pointer;
    color: #333;
}

.branch-region-select:focus {
    outline: none;
    border-color: var(--merida-primary);
    box-shadow: 0 0 0 2px rgba(0, 48, 135, 0.1);
}

.branch-filter-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 0.5rem;
}

.branch-filter-clear {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--global-palette13, #dc2626);
    font-size: 1.75rem;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.branch-filter-clear:hover {
    opacity: 0.7;
}

.branch-filter-clear.is-visible {
    display: flex;
}

/* -------------------------------------------------------------------------
   Branch List
   ------------------------------------------------------------------------- */
.branch-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 600px;
    overflow-y: auto;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--merida-primary) var(--merida-gray-light);
}

.branch-list::-webkit-scrollbar {
    width: 6px;
}

.branch-list::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

.branch-list::-webkit-scrollbar-thumb {
    background-color: var(--merida-primary);
    border-radius: 4px;
}

.branch-card {
    display: flex;
    gap: 1rem;
    padding: 1rem 0.5rem;
    border-bottom: 1px solid var(--merida-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.branch-card:hover {
    background-color: var(--merida-gray-light);
}

.branch-card.is-hidden {
    display: none;
}

.branch-card.is-active {
    background-color: rgba(0, 48, 135, 0.05);
}

.branch-card-icon {
    flex-shrink: 0;
    width: 32px;
    height: 40px;
    margin-top: 0;
}

.branch-card-icon img {
    width: 100%;
    height: 100%;
}

.branch-card-content {
    flex: 1;
    min-width: 0;
}


.branch-card:hover .branch-card-title a {
    text-decoration: underline;
}

.branch-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: #000;
}

.branch-card-title a {
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

.branch-card-address {
    font-size: 0.875rem;
    color: var(--global-palette3);
    margin: 0 0 0.25rem;
}

.branch-card-phone {
    font-size: 0.875rem;
    color: var(--global-palette5);
    text-decoration: none;
}

.branch-card-phone:hover {
    color: var(--merida-primary);
}

/* -------------------------------------------------------------------------
   Map
   ------------------------------------------------------------------------- */
.branch-archive-map {
    position: relative;
    height: 660px;
    min-height: 600px;
}

.branch-map-canvas {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: var(--merida-gray-light);
}

/* Leaflet Marker Customization */
.leaflet-marker-icon.merida-marker {
    background: none;
    border: none;
}

/* Leaflet Popup Customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 220px;
    font-family: inherit;
}

.branch-popup {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

/* Remove default Google Maps InfoWindow padding and handle it ourselves */
.gm-style .gm-style-iw-c {
    padding: 0 !important;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    margin-top: -40px;
}

.gm-style .gm-ui-hover-effect {
    top: 4px !important;
    right: 4px !important;
}

/* Custom padding for Google Maps content, ensuring space for close button */
.branch-popup.branch-popup--google {
    padding: 1rem;
    padding-right: 2.5rem;
    /* Space for close button */
    padding-top: 1rem;
}

.branch-popup-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: #000;
    line-height: 1.3;
}

.branch-popup-title a {
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Hover effect on modal underlines the title link */
.leaflet-popup-content-wrapper:hover .branch-popup-title a {
    text-decoration: underline;
}

.branch-popup-address {
    font-size: 0.875rem;
    color: var(--merida-gray);
    margin: 0 0 0.75rem;
}

.branch-popup a.branch-popup-phone,
.branch-popup a.branch-popup-navigate {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 1rem;
    /* Increased slightly for better readability */
    font-weight: 700;
    /* Bold as per screenshot/request */
    color: var(--merida-gray) !important;
    text-decoration: none;
    margin-bottom: 0.5rem;
    line-height: 1.2;
    transition: all 0.2s ease;
    text-underline-offset: 3px;
}

.branch-popup a.branch-popup-phone:hover,
.branch-popup a.branch-popup-navigate:hover,
.branch-popup-title a:hover {
    text-decoration: underline !important;
    color: var(--merida-primary) !important;
}


/* Close button */
.leaflet-popup-close-button {
    width: 24px !important;
    height: 24px !important;
    font-size: 18px !important;
    color: #999 !important;
    top: 8px !important;
    right: 8px !important;
}

/* -------------------------------------------------------------------------
   Mobile Responsiveness
   ------------------------------------------------------------------------- */
@media (max-width: 991px) {
    .branch-archive-grid {
        grid-template-columns: 1fr;
    }

    /* Mobile order: map first, then filter, then list */
    .branch-archive-sidebar {
        order: 2;
    }

    .branch-archive-map {
        order: 1;
        position: relative;
        top: 0;
        height: auto;
        min-height: 0;
    }

    .branch-map-canvas {
        height: 100vw;
        max-height: 500px;
        min-height: 0;
        /* Reset desktop min-height */
    }

    .branch-list {
        max-height: none;
    }
}

@media (max-width: 768px) {
    .branch-archive-title {
        font-size: 2rem;
    }

    .branch-map-canvas {
        height: 100vw;
        max-height: 400px;
    }
}