/* Frontend Styles for Branches Map */

.branches-map-wrapper {
    --bm-dot-color: #76787a;
    --bm-pulse-color: #76787a;
    --bm-hover-color: #e5c07b;
    --bm-modal-bg: rgba(255, 255, 255, 0.86);
    --bm-modal-text: #1d1d1f;
    --bm-accent-color: #b48c43;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    gap: 0;
    transition: gap 0.3s ease;
    align-items: flex-start;
    align-content: flex-start;
    flex-direction: row;
}

.branches-map-wrapper.has-active-card {
    gap: 50px;
}

.branches-map-wrapper * {
    box-sizing: border-box;
}

.branches-map-container {
    position: relative;
    flex: 1 0 auto;
    aspect-ratio: 1 / 1;
    user-select: none;
    width: 45%;
}

/* Fallback for browsers that don't support aspect-ratio */
@supports not (aspect-ratio: 1/1) {
    .branches-map-container {
        height: 0;
        padding-bottom: 100%;
    }
}

.branches-map-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    pointer-events: none;
    z-index: 1;
}

/* Pulsing Dots (Gold Brand Theme) */
.branches-map-dot-wrapper {
    position: absolute;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: z-index 0.2s ease;
}

.branches-map-dot-wrapper:hover,
.branches-map-dot-wrapper.is-active {
    z-index: 50;
}

.branches-map-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--bm-dot-color);
    border: 2px solid #ffffff;
    position: relative;
    z-index: 2;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.25s ease;
    z-index: 2;
}

.branches-map-dot-wrapper:hover .branches-map-dot,
.branches-map-dot-wrapper.is-active .branches-map-dot {
    transform: scale(1.35);
    background: var(--bm-hover-color);
    border-color: #ffffff;
}

.branches-map-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--bm-pulse-color);
    opacity: 0.65;
    z-index: 1;
    pointer-events: none;
    transform: scale(1);
    animation: branches-dot-pulse-animation 2.2s infinite cubic-bezier(0.165, 0.84, 0.44, 1);
    transition: background-color 0.25s ease;
    z-index: 0;
}

.branches-map-dot-wrapper:hover .branches-map-pulse,
.branches-map-dot-wrapper.is-active .branches-map-pulse {
    background-color: var(--bm-hover-color);
}

.branches-map-dot-label {
    position: absolute;
    top: 0;
    left: 0;
    transform: translate(calc(-100% + 19px), -1px);
    color: var(--bm-dot-color);
    font-size: 12px;
    font-weight: 500;
    transition: color 0.2s ease;
    background: #fff;
    padding: 2px 16px 2px 4px;
    border-radius: 50px;
    z-index: 1;
    text-wrap: nowrap;
}

@keyframes branches-dot-pulse-animation {
    0% {
        transform: scale(1);
        opacity: 0.75;
    }

    100% {
        transform: scale(3.8);
        opacity: 0;
    }
}

/* Glassmorphic Overlay Card & Mobile Drawer */
.branches-map-overlay-card {
    position: relative;
    width: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0;
    border-width: 0;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.6);
    background: var(--bm-modal-bg);
    backdrop-filter: blur(14px) saturate(190%);
    -webkit-backdrop-filter: blur(14px) saturate(190%);
    border-radius: 16px;
    box-shadow: none;
    pointer-events: none;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1),
        opacity 0.25s ease,
        padding 0.3s ease,
        border-width 0.3s ease;
    display: flex;
    flex-direction: column;
    direction: rtl;
    /* Support for Persian RTL */
    text-align: right;

    /* Match map height */
}

.branches-map-overlay-card.is-active {
    width: 55%;
    opacity: 1;
    padding: 15px;
    border-width: 1px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 1px 8px rgba(0, 0, 0, 0.06);
    pointer-events: auto;
}

.branches-map-overlay-title {
    margin: 0 0 10px 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--bm-modal-text);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.2;
}

.branches-map-overlay-close {
    font-size: 18px;
    font-weight: 400;
    color: #8e8e93;
    cursor: pointer;
    transition: color 0.15s ease;
    line-height: 1;
    padding: 2px 6px;
    margin-left: -4px;
}

.branches-map-overlay-close:hover {
    color: #ff3b30;
}

.branches-map-branches-list {
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    flex: 1;
    max-height: 600px;
    padding-left: 4px;
    /* Scrollbar spacing for RTL */
}

/* Custom Scrollbar for list */
.branches-map-branches-list::-webkit-scrollbar {
    width: 4px;
}

.branches-map-branches-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
}

.branches-map-branches-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.branches-map-branches-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.branches-map-branches-list li {
    margin-bottom: 6px;
}

.branches-map-branches-list li:last-child {
    margin-bottom: 0;
}

.branches-map-branches-list a {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    text-decoration: none;
    color: var(--bm-modal-text);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.branches-map-branches-list a:hover {
    background: rgba(197, 160, 89, 0.1);
    color: var(--bm-accent-color);
    border-color: rgba(197, 160, 89, 0.25);
    transform: translateX(-2px);
    /* Slides to left in RTL */
}

.branches-map-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    margin-right: 0;
    flex-shrink: 0;
    color: var(--bm-accent-color);
    transition: color 0.2s ease;
}

.branches-map-link-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* Mobile responsive fixes */
@media (max-width: 580px) {
    .branches-map-wrapper {
        flex-direction: column;
    }

    .branches-map-overlay-card {
        top: auto;
        bottom: auto;
        right: auto;
        left: auto;
        width: 100%;
        max-height: none;
        border-radius: 16px;
        transform: none;
        border-width: 1px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
        pointer-events: auto;
        margin-top: 10px;
        opacity: 1;
        position: relative;
        transition: none;
    }

    .branches-map-overlay-card.is-active {
        transform: none;
        opacity: 1;
        width: 100%;
        padding: 15px;
    }

    .branches-map-container {
        width: 100%;
    }
}

/* Pan & Zoom Styles */
.branches-map-container {
    cursor: grab;
    overflow: hidden;
}

.branches-map-container.is-grabbing {
    cursor: grabbing;
}

.branches-map-zoomable-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
}

.branches-map-zoom-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 60;
}

.branches-map-zoom-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.45) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.82) !important;
    backdrop-filter: blur(10px) saturate(190%) !important;
    -webkit-backdrop-filter: blur(10px) saturate(190%) !important;
    color: var(--bm-modal-text) !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
    transition: all 0.2s ease !important;
    user-select: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.branches-map-zoom-btn:hover {
    background: #ffffff !important;
    color: var(--bm-accent-color) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12) !important;
}

.branches-map-zoom-btn:active {
    transform: translateY(0) !important;
    background: rgba(255, 255, 255, 0.95) !important;
}

/* Card Template Styles */
.branches-map-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    width: 100%;
    direction: rtl;
    padding: 10px;
    max-height: 550px;
    overflow: auto;
}

.branches-map-card-item {
    background: transparent;
    display: flex;
    flex-direction: column;
}

.branches-map-card-link {
    text-decoration: none;
    display: block;
}

.branches-map-card-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.branches-map-card-link:hover .branches-map-card-image-wrap {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.branches-map-card-image {
    width: 100%;
    height: 100% !important;
    object-fit: cover;
    transition: transform 0.5s ease;
    display: block;
}

.branches-map-card-link:hover .branches-map-card-image {
    transform: scale(1.05);
}

.branches-map-card-image-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f1f5f9 0%, #cbd5e1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.branches-map-fallback-icon {
    font-size: 32px;
}

/* Badge top-right */
.branches-map-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ffffff;
    color: #1d1d1f;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    z-index: 3;
}

/* Button centered/bottom */
.branches-map-card-button {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bm-accent-color);
    color: #ffffff;
    height: 36px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    padding: 0;
    width: 36px;
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.3);
    z-index: 3;
    transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    overflow: hidden;
    justify-content: center;
}

/* Default state: only show icon, make it a circle */
.branches-map-card-btn-text {
    font-size: 12px;
    line-height: normal;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.branches-map-card-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
}

.branches-map-card-btn-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Hover expansion */
.branches-map-card-link:hover .branches-map-card-button {
    padding: 0 6px 0 6px;
    width: auto;
    min-width: 140px;
}

.branches-map-card-link:hover .branches-map-card-btn-text {
    opacity: 1;
    width: auto;
    max-width: 120px;
    margin-right: 10px;
}

/* Meta Text below the card */
.branches-map-card-meta {
    margin-top: 12px;
    text-align: center;
}

.branches-map-card-city-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--bm-accent-color);
    opacity: 0.85;
    display: none;
}

.branches-map-card-title {
    margin: 4px 0 0 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--bm-modal-text);
}