/**
 * Store Selector Styles
 * All colors and spacing use Design System CSS variables
 * Managed via: Integral Hockey → Design System
 * @package Integral_Hockey_Search
 */

/* =====================================================
   STORE SELECTOR BUTTON (Header)
   ===================================================== */
.ihs-store-selector {
    position: relative;
    display: inline-flex;
}

.ihs-store-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    border-radius: var(--ihs-button-radius, 8px);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 14px;
    color: #fff;
}

.ihs-store-selector-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ihs-store-selector-btn svg:first-child {
    color: #66b3ff;
    flex-shrink: 0;
}

.ihs-store-selector-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.ihs-store-selector-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ihs-store-selector-name {
    font-weight: 600;
    color: #66b3ff;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ihs-store-selector-chevron {
    color: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.ihs-store-selector.open .ihs-store-selector-chevron {
    transform: rotate(180deg);
}

/* Highlight state when no store selected */
.ihs-store-selector-btn.needs-selection {
    background: rgba(255, 193, 7, 0.15);
}

.ihs-store-selector-btn.needs-selection .ihs-store-selector-name {
    color: #ffc107;
}

/* =====================================================
   STORE SELECTOR SIDEBAR OVERLAY
   ===================================================== */
.ihs-store-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Ensure overlay doesn't get clipped on mobile */
    width: 100vw;
    height: 100vh;
}

.ihs-store-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =====================================================
   STORE SELECTOR SIDEBAR
   ===================================================== */
.ihs-store-sidebar {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 440px;
    max-width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
    background: #fff;
    z-index: 9999 !important;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    transform: translateX(calc(100% + 40px));
    transition: transform 0.3s ease;
    overflow: hidden;
}

.ihs-store-sidebar.active {
    transform: translateX(0);
}

/* Sidebar Header */
.ihs-store-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 16px 16px 0 0;
}

.ihs-store-sidebar-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.ihs-store-sidebar-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: var(--ihs-button-radius, 8px);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ihs-store-sidebar-close:hover {
    background: #e9ecef;
    color: #333;
}

/* Sidebar Body */
.ihs-store-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Search Row */
.ihs-store-search-row {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    border-bottom: 1px solid #e9ecef;
    background: #fff;
}

.ihs-store-search-wrapper {
    position: relative;
    flex: 1;
}

.ihs-store-search-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.ihs-store-search {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #dee2e6;
    border-radius: var(--ihs-button-radius, 8px);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ihs-store-search:focus {
    outline: none;
    border-color: var(--ihs-primary);
    box-shadow: var(--ihs-focus-ring);
}

/* Locate Me Button */
.ihs-store-locate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    background: var(--ihs-primary);
    border: none;
    border-radius: var(--ihs-radius);
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.ihs-store-locate-btn:hover {
    background: var(--ihs-primary-hover);
}

.ihs-store-locate-btn.locating {
    background: #28a745;
    animation: ihs-pulse 1.5s ease-in-out infinite;
}

.ihs-store-locate-btn.error {
    background: #dc3545;
}

@keyframes ihs-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Location help text */
.ihs-location-help {
    padding: 12px 24px;
    background: #e7f3ff;
    border-bottom: 1px solid #cce5ff;
    font-size: 13px;
    color: #004085;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ihs-location-help svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.ihs-location-help.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.ihs-location-help.success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

/* Detecting Location */
.ihs-store-detecting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: #666;
    font-size: 14px;
}

.ihs-store-detecting-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top-color: var(--ihs-primary);
    border-radius: 50%;
    animation: ihs-spin 0.8s linear infinite;
}

@keyframes ihs-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Store Section */
.ihs-store-section {
    padding: 0;
}

.ihs-store-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 24px 12px;
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.ihs-store-section-title svg {
    color: var(--ihs-primary);
}

/* Store List */
.ihs-store-list {
    padding: 0;
}

.ihs-store-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    cursor: pointer;
    transition: background-color 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.ihs-store-item:last-child {
    border-bottom: none;
}

.ihs-store-item:hover {
    background: #f8f9fa;
}

.ihs-store-item.selected {
    background: var(--ihs-primary-bg);
}

.ihs-store-item-icon {
    width: 44px;
    height: 44px;
    background: #e9ecef;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #666;
}

.ihs-store-item.selected .ihs-store-item-icon {
    background: var(--ihs-primary);
    color: white;
}

.ihs-store-item.closest .ihs-store-item-icon {
    background: #28a745;
    color: white;
}

.ihs-store-item-info {
    flex: 1;
    min-width: 0;
}

.ihs-store-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ihs-store-remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: transparent;
    color: #666;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    flex-shrink: 0;
}

.ihs-store-remove-btn:hover {
    background: #f8f9fa;
    color: #333;
}

.ihs-store-item-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin: 0 0 4px 0;
}

.ihs-store-item-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background: #28a745;
    color: white;
    margin-left: 8px;
    vertical-align: middle;
}

.ihs-store-item-address {
    font-size: 13px;
    color: #666;
    margin: 0 0 4px 0;
    line-height: 1.4;
    /* Allow text to wrap */
}

.ihs-store-item-description {
    font-size: 12px;
    color: #888;
    margin: 0 0 6px 0;
    font-style: italic;
}

.ihs-store-item-distance {
    font-size: 12px;
    font-weight: 600;
    color: var(--ihs-primary);
}

/* Select Store Button */
.ihs-store-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--ihs-primary);
    color: white;
    border: none;
    border-radius: var(--ihs-radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    margin-left: auto;
}

.ihs-store-select-btn:hover {
    background: var(--ihs-primary-hover);
}

.ihs-store-item.selected .ihs-store-select-btn {
    background: #28a745;
}

.ihs-store-item.selected .ihs-store-select-btn:hover {
    background: #218838;
}

/* No stores found */
.ihs-store-no-results {
    text-align: center;
    padding: 40px 24px;
    color: #666;
}

.ihs-store-no-results svg {
    color: #ccc;
    margin-bottom: 12px;
}

.ihs-store-no-results p {
    margin: 0;
    font-size: 14px;
}

/* Empty state - prompt to use location */
.ihs-store-empty-state {
    text-align: center;
    padding: 40px 24px;
    color: #666;
}

.ihs-store-empty-state svg {
    color: var(--ihs-primary);
    margin-bottom: 16px;
}

.ihs-store-empty-state p {
    margin: 0 0 16px 0;
    font-size: 14px;
    line-height: 1.5;
}

.ihs-store-empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--ihs-primary);
    color: white;
    border: none;
    border-radius: var(--ihs-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.ihs-store-empty-state-btn:hover {
    background: var(--ihs-primary-hover);
}

/* Sidebar Footer */
.ihs-store-sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.ihs-view-all-locations {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: 1px solid #dee2e6;
    border-radius: var(--ihs-radius);
    color: #333;
    font-size: 14px;
    font-weight: var(--ihs-font-weight-semibold);
    text-decoration: none;
    transition: all 0.2s;
    width: 100%;
}

.ihs-view-all-locations:hover {
    background: #e9ecef;
    border-color: #ced4da;
    color: #333;
    text-decoration: none;
}

.ihs-view-all-locations svg {
    color: var(--ihs-primary);
}

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */
@media (max-width: 600px) {
    .ihs-store-selector-btn {
        padding: 6px 10px;
    }

    .ihs-store-selector-label {
        display: none;
    }

    .ihs-store-selector-name {
        max-width: 100px;
    }

    .ihs-store-sidebar {
        top: 10px;
        right: 10px;
        width: calc(100% - 20px);
        max-width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
        border-radius: 12px;
        /* Override transform for mobile — offset matches new margins (10px + 10px = 20px) */
        transform: translateX(calc(100% + 20px));
    }

    .ihs-store-sidebar.active {
        transform: translateX(0);
    }

    .ihs-store-sidebar-header {
        padding: 16px 20px;
        border-radius: 12px 12px 0 0;
    }

    .ihs-store-sidebar-header h3 {
        font-size: 18px;
    }

    .ihs-store-search-row {
        padding: 12px 16px;
    }

    .ihs-store-section-title {
        padding: 12px 16px 10px;
    }

    .ihs-store-item {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .ihs-store-select-btn {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }

    .ihs-store-sidebar-footer {
        padding: 12px 16px;
    }

    .ihs-location-help {
        padding: 10px 16px;
        font-size: 12px;
    }
}

/* =====================================================
   DISTANCE INDICATOR ON SEARCH RESULTS
   ===================================================== */
.ihs-product-store-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
}

.ihs-product-store-info svg {
    color: #0066cc;
    flex-shrink: 0;
}

.ihs-product-store-name {
    font-weight: 600;
    color: #333;
}

.ihs-product-store-distance {
    color: #666;
}

.ihs-find-other-stores {
    color: #0066cc;
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
}

.ihs-find-other-stores:hover {
    text-decoration: underline;
}
