/**
 * Imagic Directory Interactive Map Styles
 *
 * Comprehensive styling for the Airbnb-style directory map interface
 * including business cards, map layout, and responsive design.
 *
 * @package ImagicDirectory
 * @since   1.0.0
 */

/* Main Container */
.imagic-directory-map-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Directory Layout: Two Columns */
.directory-layout {
    display: flex;
    gap: 20px;
    min-height: 600px;
    position: relative;
}

/* Left Column: Business Cards Sidebar */
.directory-sidebar {
    flex: 0 0 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

/* Right Column: Map */
.directory-map-column {
    flex: 1;
    position: relative;
    min-height: 600px;
}

/* Directory Controls */
.directory-controls {
    padding: 20px;
    border-bottom: 1px solid #e8e8e8;
    background: #fff;
}

.order-by-wrapper {
    position: relative;
}

.order-by-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 16px;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.order-by-toggle:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.order-by-toggle[aria-expanded="true"] {
    background: #fff;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.order-by-toggle .fa-chevron-down {
    transition: transform 0.2s ease;
}

.order-by-toggle[aria-expanded="true"] .fa-chevron-down {
    transform: rotate(180deg);
}

.order-by-text {
    color: #666;
}

.order-by-current {
    color: #333;
    font-weight: 600;
    margin-left: 8px;
}

/* Order By Dropdown */
.order-by-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.order-by-dropdown[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-content {
    padding: 8px;
}

.order-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: background 0.2s ease;
}

.order-option:hover {
    background: #f7f7f7;
}

.order-option[aria-pressed="true"] {
    background: #007cba;
    color: #fff;
}

.order-option i {
    margin-right: 12px;
    width: 16px;
    text-align: center;
}

.order-distance {
    position: relative;
}

.location-status {
    display: block;
    color: #666;
    font-size: 12px;
    margin-top: 2px;
}

.order-option[aria-pressed="true"] .location-status {
    color: rgba(255, 255, 255, 0.8);
}

/* Directory Status */
.directory-status {
    padding: 16px 20px;
    border-bottom: 1px solid #e8e8e8;
    background: #fff;
}

.results-count {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #007cba;
}

.loading-indicator .fa-spinner {
    animation: spin 1s linear infinite;
}

/* Business Cards Container */
.business-cards-container {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.business-cards-container::-webkit-scrollbar {
    width: 6px;
}

.business-cards-container::-webkit-scrollbar-track {
    background: transparent;
}

.business-cards-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.business-cards-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.business-cards-list {
    padding: 0;
}

/* Business Card */
.business-card {
    border-bottom: 1px solid #e8e8e8;
    transition: background 0.2s ease;
    cursor: pointer;
}

.business-card:last-child {
    border-bottom: none;
}

.business-card:hover {
    background: #f9f9f9;
}

.business-card.highlighted {
    background: #f0f8ff;
    border-left: 4px solid #007cba;
}

.business-card-content {
    padding: 20px;
    display: flex;
    gap: 16px;
}

/* Business Logo */
.business-logo {
    flex-shrink: 0;
}

.business-logo-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

/* Business Information */
.business-info {
    flex: 1;
    min-width: 0;
}

.business-header {
    margin-bottom: 12px;
}

.business-name {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.business-name a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.business-name a:hover {
    color: #007cba;
}

.business-category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #f0f8ff;
    color: #007cba;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.business-distance {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #666;
    font-size: 12px;
    margin-left: 12px;
}

.business-distance .fa {
    color: #007cba;
}

.distance-text small {
    color: #999;
    margin-left: 4px;
}

/* Business Location */
.business-location {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 14px;
    margin-bottom: 12px;
}

.business-location .fa {
    color: #007cba;
    width: 14px;
}

/* Business Description */
.business-description {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* Business Actions */
.business-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.business-actions a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.view-business-btn {
    background: #007cba;
    color: #fff;
}

.view-business-btn:hover {
    background: #005a87;
}

.business-website-btn,
.business-phone-btn {
    background: #f7f7f7;
    color: #666;
    border: 1px solid #e0e0e0;
}

.business-website-btn:hover,
.business-phone-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* Load More Button */
.load-more-wrapper {
    padding: 20px;
    text-align: center;
    border-top: 1px solid #e8e8e8;
}

.load-more-btn {
    padding: 12px 24px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    position: relative;
}

.load-more-btn:hover {
    background: #005a87;
}

.load-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.load-more-btn.loading .btn-text {
    opacity: 0;
}

.load-more-btn.loading .btn-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex !important;
    align-items: center;
    gap: 8px;
}

/* No Results Message */
.no-results-message {
    padding: 60px 20px;
    text-align: center;
}

.no-results-content {
    color: #666;
}

.no-results-content .fa {
    color: #ccc;
    margin-bottom: 20px;
}

.no-results-content h3 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 20px;
}

.no-results-content p {
    margin: 0;
    line-height: 1.5;
}

/* Map Container */
.map-container {
    position: relative;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
}

.business-map {
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* Map Loading and Error States */
.map-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.map-loading-content {
    text-align: center;
    color: #666;
}

.map-loading-content .fa-spinner {
    color: #007cba;
    margin-bottom: 16px;
    animation: spin 1s linear infinite;
}

.map-error-message {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.error-content {
    text-align: center;
    color: #666;
    max-width: 300px;
}

.error-content .fa {
    color: #e74c3c;
    margin-bottom: 16px;
}

.error-content h4 {
    margin: 0 0 12px 0;
    color: #333;
}

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

/* Map Popup Styles */
.business-popup {
    max-width: 280px;
    font-family: inherit;
}

.popup-header {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.popup-logo {
    flex-shrink: 0;
}

.popup-logo-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e8e8e8;
}

.popup-info {
    flex: 1;
    min-width: 0;
}

.popup-business-name {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.popup-category {
    font-size: 12px;
    color: #007cba;
    font-weight: 500;
    margin-bottom: 4px;
}

.popup-location,
.popup-distance {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
}

.popup-location .fa,
.popup-distance .fa {
    color: #007cba;
    width: 12px;
}

.popup-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.popup-view-btn {
    flex: 1;
    padding: 8px 12px;
    background: #007cba;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    transition: background 0.2s ease;
}

.popup-view-btn:hover {
    background: #005a87;
}

.popup-phone-btn,
.popup-website-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #f7f7f7;
    color: #666;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.popup-phone-btn:hover,
.popup-website-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* Animations */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .directory-layout {
        flex-direction: column;
        gap: 16px;
    }
    
    .directory-sidebar {
        flex: none;
        max-height: 400px;
        order: 2;
    }
    
    .directory-map-column {
        flex: none;
        height: 400px;
        order: 1;
    }
    
    .business-card-content {
        padding: 16px;
    }
    
    .business-logo-img {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 768px) {
    .imagic-directory-map-container {
        padding: 0 10px;
    }
    
    .directory-layout {
        gap: 12px;
    }
    
    .directory-sidebar {
        border-radius: 8px;
    }
    
    .directory-map-column {
        height: 300px;
    }
    
    .map-container {
        border-radius: 8px;
    }
    
    .business-card-content {
        padding: 12px;
        gap: 12px;
    }
    
    .business-logo-img {
        width: 50px;
        height: 50px;
    }
    
    .business-name {
        font-size: 16px;
    }
    
    .business-actions {
        gap: 6px;
    }
    
    .business-actions a {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .order-by-toggle {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .directory-controls {
        padding: 16px;
    }
    
    .directory-status {
        padding: 12px 16px;
    }
}

@media (max-width: 480px) {
    .business-card-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }
    
    .business-logo {
        align-self: center;
    }
    
    .business-header {
        text-align: center;
    }
    
    .business-location {
        justify-content: center;
    }
    
    .business-actions {
        justify-content: center;
    }
    
    .popup-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .popup-info {
        text-align: center;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .order-by-toggle,
    .order-by-dropdown,
    .business-card,
    .business-actions a,
    .load-more-btn,
    .fade-in {
        transition: none;
        animation: none;
    }
    
    .loading-indicator .fa-spinner,
    .map-loading-content .fa-spinner {
        animation: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .business-card {
        border-width: 2px;
    }
    
    .business-category {
        border: 1px solid #007cba;
    }
    
    .view-business-btn,
    .load-more-btn {
        border: 2px solid #fff;
    }
    
    .business-website-btn,
    .business-phone-btn {
        border-width: 2px;
    }
}

/* Focus States */
.order-by-toggle:focus,
.order-option:focus,
.load-more-btn:focus,
.business-actions a:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .directory-layout {
        flex-direction: column;
    }
    
    .directory-map-column {
        display: none;
    }
    
    .directory-sidebar {
        max-height: none;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .business-card {
        page-break-inside: avoid;
    }
    
    .directory-controls,
    .load-more-wrapper {
        display: none;
    }
}