/**
 * Maptyx Widget Styles - Leaflet Implementation
 *
 * @package Matyx_Central
 */

/* Maptyx Widget Container */
.maptyx-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.maptyx-container {
    position: relative;
    width: 100%;
    height: 400px;
    background-color: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.maptyx-container:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Loading State */
.maptyx-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.maptyx-loading p {
    margin: 0;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.maptyx-loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: maptyx-spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

/* Map Container when loaded */
.maptyx-container.loaded .maptyx-loading {
    display: none;
}

/* Leaflet map container */
.maptyx-container .leaflet-container {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    font-family: inherit;
}

/* Error State */
.maptyx-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #dc3232;
    max-width: 300px;
}

.maptyx-error h4 {
    margin: 0 0 10px 0;
    color: #dc3232;
    font-size: 16px;
    font-weight: 600;
}

.maptyx-error p {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .maptyx-container {
        height: 300px;
        border-radius: 6px;
    }
    
    .maptyx-loading {
        padding: 15px;
    }
    
    .maptyx-loading p {
        font-size: 13px;
    }
    
    .maptyx-error {
        padding: 20px;
        max-width: 250px;
    }
    
    .maptyx-error h4 {
        font-size: 14px;
    }
    
    .maptyx-error p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .maptyx-container {
        height: 250px;
        border-radius: 4px;
    }
    
    .maptyx-loading {
        padding: 12px;
    }
    
    .maptyx-loading::before {
        width: 16px;
        height: 16px;
        margin-right: 8px;
    }
}

/* Filter Effects for Leaflet */
.maptyx-container .leaflet-container[style*="filter: grayscale"] {
    filter: grayscale(100%) !important;
}

.maptyx-container .leaflet-container[style*="filter: sepia"] {
    filter: sepia(100%) !important;
}

.maptyx-container .leaflet-container[style*="filter: invert"] {
    filter: invert(100%) !important;
}

/* Accessibility */
.maptyx-container:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Info Window Styles */
.maptyx-info-window {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 280px;
}

.maptyx-info-window h4 {
    margin: 0 0 8px 0 !important;
    color: #333 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
}

.maptyx-info-window p {
    margin: 0 !important;
    color: #666 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
}

/* Info Window Styles */
.maptyx-info-window-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    padding: 10px;
    line-height: 1.6;
    font-size: 14px;
    max-width: 320px;
    color: #333;
}

.maptyx-info-window-content h4.maptyx-info-window-title {
    margin: 0 0 10px 0 !important;
    color: #1e1e1e !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
}

.maptyx-info-window-content p {
    margin: 0 0 8px 0 !important;
    color: #555 !important;
}

.maptyx-info-window-content p:last-child {
    margin-bottom: 0 !important;
}

.maptyx-info-window-content strong {
    color: #333 !important;
   font-weight: 500 !important;
}

.maptyx-info-window-content a {
    color: #0073aa !important;
    text-decoration: none !important;
    transition: color 0.2s ease !important;
}

.maptyx-info-window-content a:hover {
    color: #005a87 !important;
    text-decoration: underline !important;
}

/* Specific for CPT Info Windows */
.location-cpt-info .maptyx-info-window-address,
.location-cpt-info .maptyx-info-window-phone,
.location-cpt-info .maptyx-info-window-email,
.location-cpt-info .maptyx-info-window-hours {
    font-size: 13px;
}

.location-cpt-info .maptyx-info-window-website a,
.location-cpt-info .maptyx-info-window-permalink a {
    display: inline-block;
    margin-top: 5px;
    padding: 6px 12px;
    background-color: #0073aa;
    color: #fff !important;
    border-radius: 4px;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.location-cpt-info .maptyx-info-window-website a:hover,
.location-cpt-info .maptyx-info-window-permalink a:hover {
    background-color: #005a87;
    color: #fff !important;
    text-decoration: none !important;
}

.maptyx-info-window-permalink a {
    margin-right: 5px; /* Space between buttons if both website and permalink are shown */
}

/* Leaflet Popup Styles */
.leaflet-popup-content-wrapper {
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    padding: 0 !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    line-height: 1.4 !important;
    font-size: 14px !important;
    min-width: 200px;
    max-width: 400px;
}

.leaflet-popup-tip {
    background: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.maptyx-popup .leaflet-popup-content-wrapper {
    background: white;
    color: #333;
}

.maptyx-popup .leaflet-popup-close-button {
    color: #666 !important;
    font-size: 18px !important;
    padding: 8px !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
}

.maptyx-popup .leaflet-popup-close-button:hover {
    color: #333 !important;
    background: rgba(0,0,0,0.1) !important;
    border-radius: 3px;
}

/* Multiple Markers Styles */
.maptyx-container[data-data-source="multiple"],
.maptyx-container[data-data-source="locations"],
.maptyx-container[data-data-source="service_areas"],
.maptyx-container[data-data-source="json"] {
    position: relative;
}

.maptyx-markers-count {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    color: #666;
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Location Info Styles */
.location-info {
    padding: 15px;
    max-width: 300px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.location-info h4 {
    margin: 0 0 10px 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #333 !important;
    line-height: 1.3 !important;
}

.location-info p {
    margin: 0 0 8px 0 !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: #666 !important;
}

.location-info p:last-child {
    margin-bottom: 0 !important;
}

.location-info strong {
    color: #333 !important;
    font-weight: 600 !important;
}

.location-info a {
    color: #0073aa !important;
    text-decoration: none !important;
    transition: color 0.2s ease !important;
}

.location-info a:hover {
    color: #005a87 !important;
    text-decoration: underline !important;
}

/* Marker Clustering Styles */
.cluster {
    background: #007cba;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    text-align: center;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Print Styles */
@media print {
    .maptyx-container {
        background: #f9f9f9;
        border: 1px solid #ddd;
    }
    
    .maptyx-container .leaflet-container {
        display: none;
    }
    
    .maptyx-container::after {
        content: "Map: " attr(data-address);
        display: block;
        padding: 20px;
        text-align: center;
        color: #666;
        font-size: 14px;
    }
    
    .maptyx-markers-count {
        display: none;
    }
}

/* Specific for JSON Info Windows */
.location-json-info .maptyx-info-window-address,
.location-json-info .maptyx-info-window-phone,
.location-json-info .maptyx-info-window-email,
.location-json-info .maptyx-info-window-hours {
    font-size: 13px;
}

.location-json-info .maptyx-info-window-website a,
.location-json-info .maptyx-info-window-permalink a {
    display: inline-block;
    margin-top: 5px;
    padding: 6px 12px;
    background-color: #0073aa;
    color: #fff !important;
    border-radius: 4px;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.location-json-info .maptyx-info-window-website a:hover,
.location-json-info .maptyx-info-window-permalink a:hover {
    background-color: #005a87;
    color: #fff !important;
    text-decoration: none !important;
}

/* Specific for Service Areas CPT and JSON Info Windows */
.service-area-cpt-info .maptyx-info-window-address,
.service-area-cpt-info .maptyx-info-window-phone,
.service-area-cpt-info .maptyx-info-window-email,
.service-area-cpt-info .maptyx-info-window-hours,
.service-area-json-info .maptyx-info-window-address,
.service-area-json-info .maptyx-info-window-phone,
.service-area-json-info .maptyx-info-window-email,
.service-area-json-info .maptyx-info-window-hours {
    font-size: 13px;
}

/* Specific for Work Done CPT Info Windows */
.work-done-cpt-info .maptyx-info-window-address,
.work-done-cpt-info .maptyx-info-window-phone,
.work-done-cpt-info .maptyx-info-window-email,
.work-done-cpt-info .maptyx-info-window-user,
.work-done-cpt-info .maptyx-info-window-company {
    font-size: 13px;
}

/* Leaflet Font Icon Markers */
.maptyx-font-icon {
    background: transparent !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.maptyx-font-icon i {
    display: block;
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* Leaflet Control Styling */
.maptyx-container .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}

.maptyx-container .leaflet-control-zoom a {
    background: white !important;
    color: #333 !important;
    border: none !important;
    font-size: 16px !important;
    line-height: 26px !important;
    text-align: center !important;
    transition: all 0.2s ease !important;
}

.maptyx-container .leaflet-control-zoom a:hover {
    background: #f0f0f0 !important;
    color: #007cba !important;
}

.maptyx-container .leaflet-control-zoom a:first-child {
    border-radius: 4px 4px 0 0 !important;
}

.maptyx-container .leaflet-control-zoom a:last-child {
    border-radius: 0 0 4px 4px !important;
}

/* Fullscreen control styling */
.maptyx-container .leaflet-control-fullscreen {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
    border-radius: 4px !important;
}

.maptyx-container .leaflet-control-fullscreen a {
    background: white !important;
    color: #333 !important;
    border: none !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
}

.maptyx-container .leaflet-control-fullscreen a:hover {
    background: #f0f0f0 !important;
    color: #007cba !important;
}

/* Responsive adjustments for Leaflet controls */
@media (max-width: 768px) {
    .maptyx-container .leaflet-control-zoom {
        margin-right: 5px !important;
        margin-top: 5px !important;
    }
    
    .maptyx-container .leaflet-control-zoom a {
        width: 24px !important;
        height: 24px !important;
        line-height: 22px !important;
        font-size: 14px !important;
    }
}

/* ====================================
   LOCATION SIDEBAR STYLES
   ==================================== */

/* Wrapper with sidebar */
.maptyx-wrapper.has-sidebar {
    display: grid !important;
    gap: 20px;
    align-items: stretch;
}

/* Bottom sidebar should not be constrained by height control */
.maptyx-wrapper.has-sidebar.sidebar-bottom {
    height: auto !important;
}

/* Grid layouts for different positions */
.maptyx-wrapper.has-sidebar.sidebar-left {
    grid-template-columns: 350px 1fr !important;
    grid-template-areas: "sidebar map" !important;
}

.maptyx-wrapper.has-sidebar.sidebar-right {
    grid-template-columns: 1fr 350px !important;
    grid-template-areas: "map sidebar" !important;
}

.maptyx-wrapper.has-sidebar.sidebar-bottom {
    grid-template-rows: 1fr 300px !important;
    grid-template-areas: "map" "sidebar" !important;
}

/* Grid area assignments */
.maptyx-wrapper.has-sidebar .maptyx-map-container {
    grid-area: map !important;
}

.maptyx-wrapper.has-sidebar .maptyx-sidebar {
    grid-area: sidebar !important;
}


/* Map container adjustments for Grid */
.maptyx-wrapper.has-sidebar .maptyx-map-container {
    min-width: 0; /* Prevent grid item from overflowing */
    height: 100%; /* Ensure map container fills the grid area */
    width: 100%;
}

.maptyx-wrapper.has-sidebar.sidebar-bottom .maptyx-map-container {
    height: auto; /* Allow natural height for bottom sidebar layout */
}

/* Ensure the map itself fills the container */
.maptyx-wrapper.has-sidebar:not(.sidebar-bottom) .maptyx-container {
    height: 100% !important; /* Override any inline height for left/right sidebars */
}

/* For bottom sidebar, map should have its default height */
.maptyx-wrapper.has-sidebar.sidebar-bottom .maptyx-container {
    height: 400px !important; /* Default height for bottom sidebar layout */
}

/* Sidebar container */
.maptyx-sidebar {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.maptyx-wrapper.sidebar-left .maptyx-sidebar,
.maptyx-wrapper.sidebar-right .maptyx-sidebar {
    width: 100%; /* Fill the grid area */
    height: 100%; /* Match the wrapper height set by the height control */
}

.maptyx-wrapper.sidebar-bottom .maptyx-sidebar {
    width: 100%;
    height: 100%; /* Fill the grid area */
}

/* Sidebar header */
.maptyx-sidebar-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.maptyx-sidebar-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Sidebar content */
.maptyx-sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    min-height: 0; /* Important for flexbox scrolling */
}

/* Empty sidebar state */
.maptyx-sidebar-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.maptyx-sidebar-empty p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

/* Sidebar item */
.maptyx-sidebar-item {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 15px;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

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

.maptyx-sidebar-item:hover {
    background-color: #f8f9fa;
    box-shadow: inset 3px 0 0 #007cba;
}

.maptyx-sidebar-item.active {
    background-color: #e8f4f8;
    box-shadow: inset 3px 0 0 #007cba;
}

/* Sidebar image */
.maptyx-sidebar-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maptyx-sidebar-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Sidebar details */
.maptyx-sidebar-details {
    flex: 1;
    min-width: 0;
}

.maptyx-sidebar-item-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.maptyx-sidebar-address,
.maptyx-sidebar-phone,
.maptyx-sidebar-email,
.maptyx-sidebar-hours,
.maptyx-sidebar-description {
    margin: 0 0 6px 0;
    font-size: 14px;
    line-height: 1.4;
    color: #666;
}

.maptyx-sidebar-description {
    margin-bottom: 12px;
    color: #555;
}

.maptyx-sidebar-label {
    font-weight: 500;
    color: #333;
    margin-right: 4px;
}

.maptyx-sidebar-phone a,
.maptyx-sidebar-email a {
    color: #007cba;
    text-decoration: none;
    transition: color 0.2s ease;
}

.maptyx-sidebar-phone a:hover,
.maptyx-sidebar-email a:hover {
    color: #005a87;
    text-decoration: underline;
}

/* Sidebar actions */
.maptyx-sidebar-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.maptyx-sidebar-view-details {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    display: inline-block;
    line-height: 1.2;
    background: #007cba;
    color: white;
}

.maptyx-sidebar-view-details:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

/* Bottom sidebar layout adjustments */
.maptyx-wrapper.sidebar-bottom .maptyx-sidebar-content {
    display: flex;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
}

.maptyx-wrapper.sidebar-bottom .maptyx-sidebar-item {
    min-width: 300px;
    flex-shrink: 0;
    border-bottom: none;
    border-right: 1px solid #f0f0f0;
    flex-direction: column;
    gap: 10px;
}

.maptyx-wrapper.sidebar-bottom .maptyx-sidebar-item:last-child {
    border-right: none;
}

.maptyx-wrapper.sidebar-bottom .maptyx-sidebar-image {
    align-self: flex-start;
}

/* Responsive design */
@media (max-width: 1024px) {
    .maptyx-wrapper.has-sidebar:not(.sidebar-bottom) {
        grid-template-columns: 1fr !important;
        grid-template-rows: 400px 400px !important;
        grid-template-areas: "map" "sidebar" !important;
        gap: 15px;
        height: auto !important; /* Allow natural height on mobile */
    }
    
    .maptyx-wrapper.sidebar-left .maptyx-sidebar,
    .maptyx-wrapper.sidebar-right .maptyx-sidebar {
        width: 100%;
        height: 400px; /* Fixed height for mobile */
        max-height: 400px;
    }
    
    .maptyx-wrapper.has-sidebar .maptyx-map-container {
        height: auto; /* Let map use its default height on mobile */
    }
    
    .maptyx-wrapper.has-sidebar .maptyx-container {
        height: 400px !important; /* Fixed map height on mobile */
    }
}

@media (max-width: 768px) {
    .maptyx-sidebar {
        border-radius: 6px;
    }
    
    .maptyx-sidebar-header {
        padding: 12px 15px;
    }
    
    .maptyx-sidebar-title {
        font-size: 15px;
    }
    
    .maptyx-sidebar-item {
        padding: 15px;
        gap: 12px;
    }
    
    .maptyx-sidebar-image {
        width: 50px;
        height: 50px;
    }
    
    .maptyx-sidebar-item-title {
        font-size: 15px;
    }
    
    .maptyx-sidebar-address,
    .maptyx-sidebar-phone,
    .maptyx-sidebar-email,
    .maptyx-sidebar-hours,
    .maptyx-sidebar-description {
        font-size: 13px;
    }
    
    .maptyx-wrapper.sidebar-bottom .maptyx-sidebar-item {
        min-width: 280px;
    }
}

@media (max-width: 480px) {
    .maptyx-wrapper.has-sidebar {
        gap: 10px;
    }
    
    .maptyx-sidebar-item {
        padding: 12px;
        flex-direction: column;
        gap: 10px;
    }
    
    .maptyx-sidebar-image {
        align-self: flex-start;
        width: 60px;
        height: 60px;
    }
    
    .maptyx-wrapper.sidebar-bottom .maptyx-sidebar-item {
        min-width: 250px;
        gap: 8px;
    }
}

/* Loading state for sidebar */
.maptyx-sidebar.loading .maptyx-sidebar-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #666;
    font-size: 14px;
}

/* Print styles */
@media print {
    .maptyx-sidebar {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
} 