/**
 * Sublocation Map Modal Styles
 */

/* Map button next to dropdown */
.custom-select-field[data-name="dropoff_location"] {
    display: flex;
    align-items: center;
}

.custom-select-field[data-name="dropoff_location"] .custom-select-trigger {
    flex: 1;
    min-width: 0;
}

.subloc-map-btn {
    display: none;
}

/* Map-only dropoff field — clickable, no dropdown behavior */
.custom-select-field[data-map-only="true"] .custom-select-trigger {
    cursor: pointer;
}

.custom-select-field[data-map-only="true"] .custom-select-trigger:hover {
    opacity: 0.8;
}

/* Overlay */
.subloc-map-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
}

.subloc-map-overlay.open {
    display: flex;
}

/* Modal container */
.subloc-map-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 1100px;
    height: 80vh;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: sublocMapSlideUp 0.25s ease-out;
}

@keyframes sublocMapSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.subloc-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
}

.subloc-map-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a237e;
}

.subloc-map-close {
    border: none;
    background: none;
    font-size: 28px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.subloc-map-close:hover {
    color: #333;
}

/* Body: sidebar + map */
.subloc-map-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
.subloc-map-sidebar {
    width: 260px;
    min-width: 260px;
    border-right: 1px solid #e8e8e8;
    display: flex;
    flex-direction: column;
}

.subloc-map-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.subloc-map-group-header {
    padding: 10px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
}

/* Accordion */
.subloc-map-accordion {
    border-bottom: 1px solid #f0f0f0;
}

.subloc-map-accordion:last-child {
    border-bottom: none;
}

/* Mobile group pills (hidden on desktop, shown via media query) */
.subloc-map-mobile-groups {
    display: none;
}

.subloc-map-accordion-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: #f8f9fc;
    text-align: left;
    cursor: pointer;
    gap: 8px;
    transition: background 0.15s;
}

.subloc-map-accordion-header:hover {
    background: #eef1f8;
}

.subloc-map-accordion.open .subloc-map-accordion-header {
    background: #e8ecf8;
}

.subloc-map-accordion-title {
    flex: 1;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #1a237e;
}

.subloc-map-accordion-count {
    font-size: 11px;
    font-weight: 600;
    background: #dde3f7;
    color: #1a237e;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

.subloc-map-accordion-arrow {
    font-size: 10px;
    color: #888;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.subloc-map-accordion.open .subloc-map-accordion-arrow {
    transform: rotate(180deg);
}

.subloc-map-accordion-body {
    display: none;
    padding: 4px 0;
}

.subloc-map-accordion.open .subloc-map-accordion-body {
    display: block;
}

.subloc-map-list-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.15s;
    gap: 3px;
}

.subloc-map-list-item:hover {
    background: #f0f4ff;
}

.subloc-map-list-item.active {
    background: #e3eaff;
    color: #1a237e;
    font-weight: 600;
}

.subloc-map-list-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.subloc-map-list-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.subloc-map-list-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* Delivery fee badge */
.subloc-map-list-fee {
    font-size: 11px;
    font-weight: 700;
    color: #dc2626;
    background: #fef2f2;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid #fecaca;
    flex-shrink: 0;
    white-space: nowrap;
}

.subloc-map-list-fee.free {
    color: #16a34a;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

/* Map container */
.subloc-map-container {
    flex: 1;
    min-height: 400px;
    position: relative;
}

/* Map loading overlay */
.subloc-map-loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.subloc-map-loader.visible {
    opacity: 1;
    pointer-events: auto;
}

.subloc-map-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #dc2626;
    border-radius: 50%;
    animation: sublocSpin 0.7s linear infinite;
}

@keyframes sublocSpin {
    to { transform: rotate(360deg); }
}

/* Footer */
.subloc-map-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid #e8e8e8;
    flex-wrap: wrap;
}

.subloc-map-footer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.subloc-map-footer-info .subloc-map-footer-hint {
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.subloc-map-footer-info .subloc-map-footer-legend {
    font-size: 11px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 6px;
}

.subloc-map-footer-legend .fee-legend-badge {
    display: inline-block;
    background: #fef2f2;
    color: #dc2626;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid #fecaca;
}

.subloc-map-footer-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.subloc-map-cancel {
    padding: 10px 20px;
    border: 1px solid #ddd;
    background: #fff;
    color: #555;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.subloc-map-cancel:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

.subloc-map-confirm {
    padding: 10px 24px;
    border: none;
    background: #dc2626;
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.subloc-map-confirm:hover:not(:disabled) {
    background: #b91c1c;
}

.subloc-map-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Marker styles (Leaflet div icons) */
.subloc-map-marker {
    background: none !important;
    border: none !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .subloc-map-overlay {
        padding: 0;
    }

    .subloc-map-modal {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .subloc-map-header {
        padding: 14px 16px;
    }

    .subloc-map-body {
        flex-direction: column;
    }

    .subloc-map-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid #e8e8e8;
        overflow: visible;
    }

    .subloc-map-sidebar-list {
        padding: 0;
        overflow: visible;
    }

    /* Accordion headers become horizontal tabs on mobile */
    .subloc-map-accordion {
        border-bottom: none;
    }

    .subloc-map-accordion-header {
        display: none;
    }

    /* Show a mobile group selector bar */
    .subloc-map-sidebar-list::before {
        content: '';
        display: block;
    }

    .subloc-map-mobile-groups {
        display: flex;
        gap: 6px;
        padding: 10px 12px;
        overflow-x: auto;
        border-bottom: 1px solid #eee;
        -webkit-overflow-scrolling: touch;
    }

    .subloc-map-mobile-group-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 14px;
        border: 1px solid #ddd;
        background: #f8f9fc;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
        color: #555;
        white-space: nowrap;
        cursor: pointer;
        transition: all 0.15s;
        flex-shrink: 0;
    }

    .subloc-map-mobile-group-btn.active {
        background: #dc2626;
        color: #fff;
        border-color: #dc2626;
    }

    .subloc-map-mobile-group-btn .subloc-map-accordion-count {
        font-size: 10px;
        padding: 1px 5px;
        background: rgba(255,255,255,0.25);
        color: inherit;
    }

    /* Sublocation items become horizontal scrollable chips */
    .subloc-map-accordion-body {
        display: none;
        padding: 8px 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .subloc-map-accordion.open .subloc-map-accordion-body {
        display: flex;
    }

    .subloc-map-list-item {
        white-space: normal;
        padding: 8px 14px;
        border-radius: 20px;
        border: 1px solid #e0e0e0;
        font-size: 13px;
        flex-shrink: 0;
        width: auto;
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }

    .subloc-map-list-item .subloc-map-list-name {
        white-space: nowrap;
    }

    .subloc-map-list-item.active {
        background: #fef2f2;
        border-color: #dc2626;
        color: #dc2626;
    }

    .subloc-map-group-header {
        display: none;
    }

    .subloc-map-container {
        flex: 1;
        min-height: 0;
    }

    .subloc-map-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 10px;
    }

    .subloc-map-footer-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .subloc-map-footer-info {
        width: 100%;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .subloc-map-title {
        font-size: 16px;
    }
}
