/**
 * Enhanced Store Locator CSS
 * Provides modern, responsive styling for the improved store locator
 */

/* ==========================================================================
   Reset and Isolation
   ========================================================================== */

/* Isolate store locator from theme conflicts */
.store-navigator-page {
    /* Create isolated stacking context */
    isolation: isolate;
    /* Ensure it doesn't interfere with site navigation */
    z-index: auto !important;
    /* Reset any inherited transforms */
    transform: none !important;
    /* Ensure proper positioning */
    position: relative !important;
}

/* ==========================================================================
   Base Layout
   ========================================================================== */

/* Ensure store locator doesn't overlap with site header */
.store-navigator-page {
    /* Reset any inherited positioning that might cause overlap */
    transform: none !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
}

/* Prevent conflicts with site's sticky/fixed headers */
body .store-navigator-page {
    position: relative !important;
    z-index: 1 !important;
}

/* Ensure proper document flow and prevent overlap */
.store-navigator-page * {
    box-sizing: border-box;
}

/* Override any theme styles that might cause positioning issues */
.store-navigator-page,
.store-navigator-page * {
    position: static;
}

.store-navigator-page .store-navigator-container,
.store-navigator-page .store-navigator-container::before,
.store-navigator-page .find-store-navegator {
    position: relative;
}

.store-navigator-page {
    position: relative;
    width: 100%;
    min-height: 600px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    z-index: 1; /* Ensure it stays below site header */
    isolation: isolate; /* Create new stacking context */
    margin-top: 0; /* Ensure no negative margins */
    clear: both; /* Clear any floated elements */
}

.store-navigator-container {
    display: flex;
    height: 650px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    background: #fff;
    position: relative;
    z-index: 1; /* Keep within page context */
    max-width: 100%;
    contain: layout style; /* Contain layout to prevent overflow issues */
}

.store-navigator-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #007bff, #0056b3, #004085);
    z-index: 2; /* Above container but below header */
}

/* ==========================================================================
   Map Styles
   ========================================================================== */

.store-map {
    flex: 1;
    min-height: 600px;
    position: relative;
    background: #f8f9fa;
}

#map {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   Store Finder Panel
   ========================================================================== */

.find-store-navegator {
    width: 420px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    border-left: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    position: relative;
}

.store-container {
    padding: 30px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.store-header {
    margin-bottom: 25px;
    text-align: center;
}

.store-header h3 {
    margin: 0 0 8px 0;
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #007bff, #0056b3, #004085);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: #007bff; /* Fallback for browsers that don't support background-clip */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
    letter-spacing: -0.5px;
    position: relative;
}

/* Fallback for browsers that don't support background-clip */
@supports not (-webkit-background-clip: text) {
    .store-header h3 {
        color: #007bff;
        text-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    }
}

.store-header h3 i {
    background: linear-gradient(135deg, #007bff, #0056b3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: #007bff; /* Fallback */
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0, 123, 255, 0.2));
}

/* Enhanced professional styling with animation */
.store-header h3::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 2px;
    animation: slideIn 0.8s ease-out;
}

@keyframes slideIn {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 60px;
        opacity: 1;
    }
}

.store-subtitle {
    margin: 0 0 4px 0;
    font-size: 15px;
    color: #495057;
    font-weight: 500;
    text-align: center;
    opacity: 0.9;
    letter-spacing: 0.3px;
}

/* ==========================================================================
   Navigation Tabs
   ========================================================================== */

.navigation-menu {
    list-style: none;
    padding: 0;
    margin: 0 0 25px 0;
    display: flex;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.navigation-menu li {
    flex: 1;
}

.navigation-menu a {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    text-decoration: none;
    color: #6c757d;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
    border-right: 1px solid #dee2e6;
    position: relative;
    gap: 6px;
}

.navigation-menu a i {
    font-size: 18px;
    margin-bottom: 2px;
}

.navigation-menu a span {
    font-size: 12px;
    font-weight: 600;
}

.navigation-menu li:last-child a {
    border-right: none;
}

.navigation-menu li.active a {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.navigation-menu a:hover:not(.active) {
    background: #e9ecef;
    color: #495057;
    transform: translateY(-1px);
}

.navigation-menu li.active a::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
}

/* ==========================================================================
   Store Count
   ========================================================================== */

.store-count-container {
    margin-bottom: 20px;
}

.store-count {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    padding: 12px 16px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #007bff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Search Form
   ========================================================================== */

.search-form-container {
    margin-bottom: 25px;
}

.store-search-form {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.form-label i {
    color: #007bff;
    width: 16px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    transform: translateY(-1px);
}

.form-control::placeholder {
    color: #adb5bd;
    font-weight: 400;
}

.input-group {
    display: flex;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.input-group-append .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.form-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-text i {
    color: #007bff;
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 40px;
}

.select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.select-wrapper:hover .select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.location-search-container {
    text-align: center;
}

.location-search-container .form-text {
    justify-content: center;
    margin-top: 12px;
}

.filter-group {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.welcome-content i {
    color: #007bff;
    margin-bottom: 16px;
    opacity: 0.7;
}

.welcome-content h5 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #495057;
    font-weight: 600;
}

.welcome-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
    gap: 8px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-color: #007bff;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    border-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.4);
}

.btn-location {
    padding: 16px 24px;
    font-size: 16px;
    border-radius: 12px;
    width: 100%;
    position: relative;
}

.btn-location .btn-loader {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

.btn-secondary {
    background: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #545b62;
    border-color: #545b62;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ==========================================================================
   Search Groups
   ========================================================================== */

.search-group {
    transition: all 0.3s ease;
}

.search-group[aria-hidden="true"] {
    display: none !important;
}

#detect-location-btn {
    position: relative;
    overflow: hidden;
}

#detect-location-btn .fa-location-arrow {
    margin-right: 8px;
}

#detect-location-btn:hover .fa-location-arrow {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ==========================================================================
   Store List
   ========================================================================== */

.results-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.filter-content {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

.filter-content::-webkit-scrollbar {
    width: 6px;
}

.filter-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.filter-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.filter-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.store-item {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    position: relative;
    margin: 8px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.store-item:hover {
    background: linear-gradient(135deg, #f8f9ff, #f0f4ff);
    transform: translateY(-2px);
    border-color: #007bff;
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.15);
}

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

.store-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #007bff;
    border-radius: 0 4px 4px 0;
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.store-item:hover::before {
    transform: scaleY(1);
}

.store-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.store-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #212529;
    flex: 1;
}

.store-distance {
    background: #007bff;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 8px;
}

.store-details {
    margin-bottom: 12px;
}

.store-details p {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: #6c757d;
    display: flex;
    align-items: center;
}

.store-details i {
    width: 16px;
    margin-right: 8px;
    color: #007bff;
}

.store-details a {
    color: #007bff;
    text-decoration: none;
}

.store-details a:hover {
    text-decoration: underline;
}

.store-actions {
    display: flex;
    gap: 8px;
}

/* ==========================================================================
   No Results Message
   ========================================================================== */

.no-results-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.no-results-content i {
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-results-content h5 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #495057;
}

.no-results-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.loading-skeleton-container {
    padding: 16px 0;
}

.store-skeleton {
    animation: fadeIn 0.5s ease-in-out both;
}

.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-skeleton 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading-skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

.loading-dots::after {
    content: '';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ==========================================================================
   Error Handler Styles
   ========================================================================== */

.error-handler-container {
    font-family: inherit;
}

.error-message {
    font-size: 13px;
    line-height: 1.4;
}

.message-header {
    font-size: 14px;
}

.close-btn:hover {
    opacity: 0.7;
}

.action-btn:hover {
    transform: translateY(-1px);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .store-navigator-container {
        flex-direction: column;
        height: auto;
        min-height: 500px;
    }
    
    .store-map {
        height: 300px;
        min-height: 300px;
    }
    
    .find-store-navegator {
        width: 100%;
        border-left: none;
        border-top: 1px solid #e9ecef;
    }
    
    .store-container {
        padding: 16px;
    }
    
    .navigation-menu {
        flex-direction: column;
    }
    
    .navigation-menu a {
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
    
    .navigation-menu li:last-child a {
        border-bottom: none;
    }
    
    .store-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .store-distance {
        margin-left: 0;
        margin-top: 4px;
        align-self: flex-start;
    }
    
    .store-actions {
        flex-direction: column;
    }
    
    .store-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .store-container {
        padding: 12px;
    }
    
    .store-container h3 {
        font-size: 20px;
    }
    
    .navigation-menu a {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .store-item {
        padding: 12px;
    }
    
    .store-name {
        font-size: 15px;
    }
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for keyboard navigation */
.btn:focus,
.form-control:focus,
.navigation-menu a:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.store-item:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .store-navigator-container {
        border: 2px solid #000;
    }
    
    .navigation-menu li.active a {
        border: 2px solid #000;
    }
    
    .store-item:hover {
        border-left: 4px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .store-navigator-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .store-map {
        display: none;
    }
    
    .find-store-navegator {
        width: 100%;
        border-left: none;
    }
    
    .btn {
        display: none;
    }
    
    .navigation-menu {
        display: none;
    }
    
    .store-item {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 8px;
    }
}