/**
 * Frontend CSS for Nite Vault Dealer Locator
 *
 * @package NiteVaultDealerLocator
 */

/* Map Container */
#dealer-locator {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Search Controls - New Design */
.nvdl-search-wrapper {
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.nvdl-search-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Search Input */
.nvdl-search-input {
    flex: 1;
    min-width: 280px;
    height: 42px;
    padding: 0 15px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    background: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.nvdl-search-input:focus {
    border-color: #E1770A;
    outline: none;
    box-shadow: 0 0 0 3px rgba(225, 119, 10, 0.1);
    background: #ffffff;
}

.nvdl-search-input::placeholder {
    color: #6c757d;
    font-size: 14px;
}

/* Button Base Styles */
.nvdl-btn {
    height: 42px;
    padding: 0 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    box-sizing: border-box;
    min-width: 140px;
}

/* Primary Button */
.nvdl-btn-primary {
    background: #E1770A;
    color: #ffffff;
    border: 2px solid #E1770A;
}

.nvdl-btn-primary:hover {
    background: #C5650A;
    border-color: #C5650A;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(225, 119, 10, 0.2);
}

.nvdl-btn-primary:active {
    background: #A85308;
    border-color: #A85308;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(225, 119, 10, 0.2);
}

.nvdl-btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(225, 119, 10, 0.3);
}

/* Secondary Button */
.nvdl-btn-secondary {
    background: #ffffff;
    color: #495057;
    border: 2px solid #dee2e6;
}

.nvdl-btn-secondary:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.nvdl-btn-secondary:active {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.nvdl-btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(173, 181, 189, 0.3);
}

/* Search Status */
#dealer-search-status {
    min-height: 20px;
    margin-bottom: 10px;
}

.nvdl-status {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.nvdl-status-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.nvdl-status-success {
    background-color: #d4edda;
    display: flex;
    width: 100%;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.nvdl-status-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Map Styling */
#map {
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Mapbox Popup Customization */
.mapboxgl-popup-content {
    border-radius: 5px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.nvdl-dealer-popup {
    max-width: 300px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nvdl-dealer-popup h3 {
    margin: 0 0 10px 0;
    color: #E1770A;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 1px solid #000000;
    padding-bottom: 8px;
}

.nvdl-dealer-popup p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
}

.nvdl-dealer-popup a {
    color: #007cba;
    text-decoration: none;
}

.nvdl-dealer-popup a:hover {
    text-decoration: underline;
}

/* Multi-dealer popup styling */
.nvdl-multi-dealer {
    max-width: 350px;
}

.nvdl-multi-dealer h3 {
    margin: 0 0 15px 0;
    color: #E1770A;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid #000000;
    padding-bottom: 10px;
}

.nvdl-dealer-item {
    margin-bottom: 15px;
}

.nvdl-dealer-item h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.nvdl-dealer-item p {
    margin: 5px 0;
    font-size: 14px;
    line-height: 1.4;
}

.nvdl-dealer-item p strong {
    color: #444;
}

/* Error Messages */
.nvdl-dealer-error {
    padding: 15px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
    margin: 20px 0;
}

.nvdl-dealer-error p {
    margin: 0;
}

/* Loading States */
.nvdl-loading {
    display: inline-block;
    position: relative;
}

.nvdl-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: nvdl-spin 1s ease infinite;
}

@keyframes nvdl-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design - Mobile Only (Bootstrap handles column stacking) */
@media (max-width: 576px) {
    /* Mobile Search Controls */
    .nvdl-search-wrapper {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .nvdl-search-container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .nvdl-search-input {
        min-width: auto;
        width: 100%;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .nvdl-btn {
        width: 100%;
        min-width: auto;
        justify-content: center;
    }
    
    /* Adjust map height on mobile */
    #map {
        height: 400px !important;
        min-height: 400px;
    }
    
    /* Adjust sidebar height on mobile */
    .nvdl-dealer-sidebar {
        height: 300px;
        margin-top: 15px;
    }
    
    .nvdl-dealer-popup {
        max-width: 250px;
    }
    
    /* Smaller sidebar padding on mobile */
    .nvdl-sidebar-title {
        padding: 10px 15px 8px;
        font-size: 16px;
    }
    
    .nvdl-dealer-item-sidebar {
        padding: 12px 15px;
    }
}

@media (max-width: 480px) {
    .dealer-search-controls input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    #map {
        height: 350px !important;
        min-height: 350px;
    }
}

/* High DPI / Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #map {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}


/* Bootstrap Grid Adjustments */
.container-fluid .row {
    margin-top: 15px;
}

.container-fluid .row > [class*="col-"] {
    padding-left: 10px;
    padding-right: 10px;
}

/* Dealer Sidebar Styling */
.nvdl-dealer-sidebar {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    height: 600px; /* Match map height */
    overflow-y: auto;
}

.nvdl-sidebar-title {
    margin: 0;
    padding: 15px 20px 10px;
    color: #E1770A;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid #000000;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.nvdl-dealer-list-content {
    padding: 0;
}

.nvdl-loading-text {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Individual Dealer Items */
.nvdl-dealer-item-sidebar {
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    background: #ffffff;
    margin-bottom: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.nvdl-dealer-item-sidebar:hover {
    background: #f0f0f0;
}

.nvdl-dealer-item-sidebar.nvdl-highlighted {
    background: #e3f2fd;
    border-left: 4px solid #E1770A;
}

.nvdl-dealer-item-sidebar h5 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.nvdl-dealer-item-sidebar .nvdl-dealer-city {
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 8px;
}

.nvdl-dealer-item-sidebar .nvdl-dealer-info {
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

.nvdl-dealer-item-sidebar .nvdl-dealer-info p {
    margin: 3px 0;
}

.nvdl-dealer-item-sidebar .nvdl-dealer-info a {
    color: #007cba;
    text-decoration: none;
}

.nvdl-dealer-item-sidebar .nvdl-dealer-info a:hover {
    text-decoration: underline;
}

/* City Group Headers in Sidebar */
.nvdl-city-group {
    background: #e9ecef;
    padding: 10px 20px;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    position: sticky;
    top: 48px; /* Account for main header height (15px + 10px padding + ~22px line height + 1px border) */
    z-index: 9;
}

/* Print Styles */
@media print {
    #dealer-locator {
        display: none;
    }
}

/* Accessibility Improvements */
.dealer-search-controls .button:focus {
    outline: 2px solid #005a87;
    outline-offset: 2px;
}

.dealer-search-controls input:focus {
    outline: 2px solid #005a87;
    outline-offset: 1px;
}

/* Custom Marker Styling (if needed) */
.nvdl-marker {
    background-color: #E1770A;
    border: 2px solid #ffffff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.nvdl-marker:hover {
    background-color: #C5650A;
    transform: scale(1.1);
}

/* Mobile Touch Enhancements */
.nvdl-mobile-marker {
    cursor: pointer !important;
    touch-action: manipulation;
}

/* Mobile Toast Notifications */
.nvdl-mobile-toast {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(33, 37, 41, 0.95);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    transition: all 0.3s ease-out;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nvdl-mobile-toast.nvdl-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.nvdl-mobile-toast.nvdl-toast-hide {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
    transition: all 0.3s ease-in;
}

/* Enhanced Mobile Styles */
@media (max-width: 768px) {
    /* Larger touch targets for mobile */
    .nvdl-dealer-item-sidebar {
        padding: 18px 20px;
        min-height: 44px; /* iOS recommended touch target */
    }
    
    .nvdl-dealer-item-sidebar h5 {
        font-size: 17px;
        line-height: 1.3;
    }
    
    .nvdl-dealer-item-sidebar .nvdl-dealer-city {
        font-size: 15px;
        margin-bottom: 10px;
    }
    
    .nvdl-dealer-item-sidebar .nvdl-dealer-info {
        font-size: 14px;
    }
    
    /* Better mobile toast positioning */
    .nvdl-mobile-toast {
        top: 15px;
        left: 15px;
        right: 15px;
        transform: none;
        max-width: calc(100% - 30px);
        text-align: center;
    }
    
    .nvdl-mobile-toast.nvdl-toast-show {
        transform: translateY(0);
    }
    
    .nvdl-mobile-toast.nvdl-toast-hide {
        transform: translateY(-10px);
    }
    
    /* Improved mobile scrolling */
    .nvdl-dealer-sidebar {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    
    /* Better mobile status messages */
    .nvdl-status {
        font-size: 15px;
        padding: 10px 15px;
        text-align: center;
    }
}

/* High-DPI Mobile Optimizations */
@media only screen and (max-width: 480px) and (-webkit-min-device-pixel-ratio: 2) {
    .nvdl-mobile-toast {
        font-size: 16px;
        padding: 14px 22px;
    }
    
    /* Prevent zoom on input focus */
    .nvdl-search-input {
        font-size: 16px !important;
    }
}

/* Animation for smooth transitions */
.nvdl-dealer-popup,
.mapboxgl-popup-content {
    transition: all 0.2s ease-in-out;
}

/* Ensure proper z-index layering */
.mapboxgl-popup {
    z-index: 1000;
}

.mapboxgl-popup-tip {
    border-top-color: #ffffff;
}
