<!-- Map and Modal Styles -->
<link rel="stylesheet" href="{{ asset('css/map-styles.css') }}">

<style>
    .sr-only {
        position: absolute;
        top: -30em;
    }

    /* EV-specific styling */
    .ev-brand {
        color: #005a6a;
        font-weight: bold;
    }

    /* Filter summary styling */
    .lead {
        font-size: 1.6rem !important;
        text-align: center !important;
        margin-bottom: 1rem;
        color: #2c3e50 !important;
        font-weight: 500 !important;
    }

    .ev-accent {
        color: #00a86b; /* Green accent for EV theme */
    }

    /* Map container styling */
    #map {
        height: 500px;
        width: 100%;
        border-radius: 8px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }

    /* Custom marker styling */
    .custom-marker {
        background: transparent;
        border: none;
    }

    /* Modal styling for EV project */
    .modal-content {
        border-radius: 10px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    }

    .modal-header {
        background-color: #005a6a;
        color: white;
        border-radius: 10px 10px 0 0;
    }

    .modal-header .close {
        color: white;
        opacity: 0.8;
    }

    .modal-header .close:hover {
        opacity: 1;
    }

    /* Button styling */
    .btn-primary {
        background-color: #005a6a;
        border-color: #005a6a;
    }

    .btn-primary:hover {
        background-color: #004a5a;
        border-color: #004a5a;
    }

    .btn-success {
        background-color: #00a86b;
        border-color: #00a86b;
    }

    .btn-success:hover {
        background-color: #00985b;
        border-color: #00985b;
    }

    /* Histogram styling */
    .histogram-container {
        background: white;
        border-radius: 8px;
        padding: 20px;
        margin: 20px 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    /* Settings modal styling */
    .settings-section {
        margin-bottom: 25px;
        padding-bottom: 20px;
        border-bottom: 1px solid #eee;
    }

    .settings-section:last-child {
        border-bottom: none;
    }

    .settings-section h4 {
        color: #005a6a;
        margin-bottom: 15px;
    }

    /* Form styling */
    .form-control:focus {
        border-color: #005a6a;
        box-shadow: 0 0 0 0.2rem rgba(0, 90, 106, 0.25);
    }

    /* Table styling for EV data */
    table {
        margin: auto;
        border-collapse: separate !important;
        border-spacing: 2px !important;
        *border-collapse: expression('separate', cellSpacing='10px');
    }

    table.sortable td, table.sortable th {
        padding: 0.125em 0.25em;
        width: 25em;
        padding-bottom: 0.5em;
    }

    table.sortable th {
        font-weight: bold;
        border-bottom: thin solid #888;
        position: relative;
        background-color: #005a6a;
        color: white;
    }

    table.sortable th.no-sort {
        padding-top: 0.35em;
    }

    table.sortable th:nth-child(5) {
        width: 10em;
    }

    table.sortable th button {
        position: absolute;
        padding: 4px;
        margin: 1px;
        font-size: 100%;
        font-weight: bold;
        background: transparent;
        border: none;
        display: inline;
        right: 0;
        left: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        text-align: left;
        outline: none;
        cursor: pointer;
        color: white;
    }

    table.sortable th button span {
        position: absolute;
        right: 4px;
    }

    table.sortable th[aria-sort="descending"] span::after {
        content: "▼";
        color: currentcolor;
        font-size: 100%;
        top: 0;
    }

    table.sortable th[aria-sort="ascending"] span::after {
        content: "▲";
        color: currentcolor;
        font-size: 100%;
        top: 0;
    }

    table.show-unsorted-icon th:not([aria-sort]) button span::after {
        content: "♢";
        color: currentcolor;
        font-size: 100%;
        position: relative;
        top: -3px;
        left: -4px;
    }

    table.sortable td.num {
        text-align: right;
    }

    table.sortable tbody tr:nth-child(odd) {
        background-color: #f8f9fa;
    }

    button {
        border-radius: 5px;
    }
        
    /* Focus and hover styling */
    table.sortable th button:focus, table.sortable th button:hover {
        padding: 2px;
        border: 2px solid currentcolor;
        background-color: #004a5a;
    }

    table.sortable th button:focus span, table.sortable th button:hover span {
        right: 2px;
    }

    table.sortable th:not([aria-sort]) button:focus span::after, table.sortable th:not([aria-sort]) button:hover span::after {
        content: "▼";
        color: currentcolor;
        font-size: 100%;
        top: 0;
    }

    /* Enhanced Radio Button Styling */
    .radio-group {
        display: flex;
        gap: 20px;
        margin: 15px 0;
        padding: 15px;
        background: rgba(255, 255, 255, 0.7);
        border-radius: 8px;
        border: 1px solid #e9ecef;
    }
    
    .radio-group label {
        display: flex;
        align-items: center;
        gap: 8px;
        font-weight: 500;
        color: #34495e;
        cursor: pointer;
        padding: 8px 12px;
        border-radius: 6px;
        transition: all 0.3s ease;
    }
    
    .radio-group label:hover {
        background: rgba(52, 152, 219, 0.1);
    }
    
    .radio-group input[type="radio"] {
        accent-color: #3498db;
        transform: scale(1.2);
    }

    /* Results container styling */
    .results-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-top: 20px;
    }

    /* Mobile responsiveness - handled by Blade @mobile directive */
    
    /* Mobile table responsiveness - handled by JavaScript */
    @media (max-width: 768px) {
        /* Show mobile table note */
        .mobile-table-note {
            display: block !important;
        }
        
        /* Make table container more mobile-friendly */
        .stations-table-container {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            width: 100vw;
            max-width: 100vw;
            margin-bottom: 60px;
        }
        
        /* Remove max-width constraint on mobile for data sections */
        .data-section {
            max-width: none;
            width: 100vw;
        }
        
        /* Add extra bottom spacing to the stations table section */
        #stationsTableSection {
            margin-bottom: 80px;
            padding-bottom: 40px;
        }
        
        /* Force all parent containers to full width */
        .container, .row, .col, [class*="col-"] {
            max-width: 100vw !important;
            width: 100vw !important;
        }
        
        /* Ensure table fits mobile screen */
        .stations-table {
            table-layout: fixed;
            width: 100vw;
            max-width: 100vw;
        }
        
        /* Compact table headers for mobile */
        .stations-table th {
            padding: 1px;
            font-size: 8px;
            white-space: normal;
            min-width: auto;
            word-wrap: break-word;
            line-height: 1.0;
        }
        
        /* Compact table cells for mobile */
        .stations-table td {
            padding: 1px;
            font-size: 8px;
            white-space: normal;
            word-wrap: break-word;
            line-height: 1.0;
        }
        
        /* Station name column - allow wrapping and more space */
        .stations-table th:first-child,
        .stations-table td:first-child {
            white-space: normal;
            width: 93%;
            padding-left: 4px;
            padding-right: 1px;
        }
        
        /* Estimated price column */
        .stations-table th:nth-child(2),
        .stations-table td:nth-child(2) {
            width: 3%;
            text-align: center;
            padding-left: 1px;
            padding-right: 1px;
        }
        
        /* Duration column */
        .stations-table th:nth-child(3),
        .stations-table td:nth-child(3) {
            width: 3%;
            text-align: center;
            padding-left: 1px;
            padding-right: 1px;
        }
        
        /* Connector column */
        .stations-table th:last-child,
        .stations-table td:last-child {
            width: 1%;
            text-align: center;
            padding-left: 1px;
            padding-right: 1px;
            white-space: normal;
            word-wrap: break-word;
        }
        
        /* Hide the small text in headers on mobile */
        .stations-table th small {
            display: none;
        }
        
        /* Make station name button more compact */
        .station-name-btn {
            font-size: 11px;
            padding: 4px 6px;
            line-height: 1.2;
            text-align: left;
            word-wrap: break-word;
            white-space: normal;
            width: 100% !important;
            min-width: auto !important;
            max-width: 100% !important;
        }
    }

    /* Map loading overlay */
    .map-loading {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
    }
    
    /* Spinner for map loading */
    .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #f3f3f3;
        border-top: 4px solid #007bff;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    /* Loading spinner */
    .loading-spinner {
        display: inline-block;
        width: 20px;
        height: 20px;
        border: 3px solid #f3f3f3;
        border-top: 3px solid #005a6a;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

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

    /* Island filter button styling */
    .island-filter-btn {
        background: #005a6a;
        color: white;
        border: none;
        border-radius: 8px;
        padding: 10px 8px;
        cursor: pointer;
        font-weight: 600;
        transition: all 0.3s ease;
        font-size: 12px;
        min-width: 200px;
    }
    
    /* Position island button just above last location button */
    .leaflet-control.leaflet-bar:has(.island-filter-btn) {
        position: absolute !important;
        bottom: 50px !important;
        left: 20px !important;
        top: auto !important;
        right: auto !important;
        width: auto !important;
        height: auto !important;
    }
    
    /* Island button at bottom when no last location button */
    .leaflet-control.leaflet-bar:has(.island-filter-btn).at-bottom {
        bottom: 5px !important;
    }
    
    /* Remove Leaflet control container styling for island filter */
    .leaflet-control.leaflet-bar .island-filter-btn {
        border: none !important;
        background: #005a6a !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
    }
    
    /* Override Leaflet control container background and border */
    .leaflet-control.leaflet-bar:has(.island-filter-btn) {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    .island-filter-btn:hover {
        background: #004a5a;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    
    .island-filter-btn.active {
        background: linear-gradient(135deg, #e74c3c, #c0392b);
    }
    
    .island-filter-btn.active:hover {
        background: linear-gradient(135deg, #c0392b, #a93226);
    }

    /* Mobile styling for island filter button - handled by Blade @mobile directive */

    /* Stations table and histogram styling */
    .data-section-container {
        display: flex;
        justify-content: center;
        margin: 20px 0;
    }

    .data-section {
        max-width: 1200px;
        display: none;
    }

    .stations-table-title {
        text-align: center;
        color: #005a6a;
        margin-bottom: 20px;
        font-size: 24px;
        font-weight: 600;
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

    .stations-table-container {
        background: white;
        padding: 0;
        border-radius: 8px;
        overflow-x: auto;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        border: 1px solid #e0e0e0;
    }

    .stations-table {
        width: 100%;
        border-collapse: collapse;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-radius: 8px;
        overflow: hidden;
    }

    .stations-table thead tr {
        background: linear-gradient(135deg, #005a6a, #004a5a);
        color: white;
    }

    .stations-table th {
        padding: 15px 12px;
        text-align: left;
        border: none;
        font-weight: 600;
        font-size: 14px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .stations-table th:not(.no-sort) {
        cursor: pointer;
        transition: background-color 0.3s ease;
    }

    .stations-table th:not(.no-sort):hover {
        background-color: rgba(255,255,255,0.1);
    }

    .stations-table tbody tr {
        transition: background-color 0.2s ease;
    }

    .stations-table tbody tr:nth-child(even) {
        background-color: #e8e8e8;
    }

    .stations-table tbody tr:nth-child(odd) {
        background-color: #ffffff;
    }

    .stations-table tbody tr:hover {
        background-color: #d4edda;
    }

    .stations-table td {
        padding: 12px;
        border-bottom: 1px solid #e0e0e0;
        vertical-align: middle;
    }

    .stations-table tbody tr:last-child td {
        border-bottom: none;
    }

    .histogram-container {
        min-height: 110px;
        border: 1px solid #ddd;
        background: white;
        padding: 10px;
        border-radius: 8px;
    }

    /* Page layout and controls styling */
    .page-header {
        text-align: center;
        position: relative;
        margin-top: 0px !important; /* Override external margin */
    }

    .controls-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 15px;
        flex-wrap: wrap;
        margin-bottom: 20px;
    }

    .controls-left {
        display: flex;
        align-items: center;
        gap: 15px;
        flex-wrap: wrap;
    }

    .controls-right {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    .kwh-input {
        width: 100px;
        min-width: 100px;
    }

    .range-display {
        margin-left: 20px;
        color: #2c3e50;
        font-weight: 500;
        font-size: 1.6rem;
    }

    .range-value {
        color: #27ae60;
        font-weight: bold;
    }

    .btn-primary {
        padding: 10px 20px;
        background: #005a6a;
        color: white;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-size: 1.5rem;
        font-weight: 600;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        transition: all 0.3s ease;
        min-height: 48px;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .btn-settings {
        padding-left: 10px;
        padding-right: 10px;
    }

    .map-container {
        position: relative;
    }

    .color-legend {
        position: absolute;
        bottom: 10px;
        right: 10px;
        background: rgba(255,255,255,0.9);
        padding: 10px;
        border-radius: 5px;
        border: 1px solid #ccc;
        display: none;
    }

    .charging-time-result {
        margin-top: 15px;
        padding: 15px;
        background: rgba(255, 255, 255, 0.8);
        border-radius: 8px;
        display: none;
        border-left: 4px solid #3498db;
        font-size: 1.6rem;
    }

    .charging-time-label {
        color: #2c3e50;
    }

    .charging-time-value {
        color: #27ae60;
        font-weight: bold;
    }

    .location-error {
        display: none;
        margin: 15px 0;
        padding: 15px;
        background-color: #fff3cd;
        border: 1px solid #ffeaa7;
        border-radius: 5px;
        color: #856404;
    }

    .modal-high-z {
        z-index: 99998 !important;
    }

    /* Station name button styling */
    .station-name-btn {
        background: linear-gradient(135deg, #005a6a, #004a5a);
        color: white;
        border: none;
        border-radius: 6px;
        padding: 8px;
        cursor: pointer;
        font-size: 13px;
        font-weight: bold;
        text-decoration: none;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        transition: all 0.3s ease;
        box-shadow: 0 2px 6px rgba(0,90,106,0.3);
        width: 200px;
        min-width: 200px;
        max-width: 200px;
        height: 60px;
        word-wrap: break-word;
        line-height: 1.2;
        border: 1px solid rgba(255,255,255,0.1);
        margin: 0;
    }

    .station-name-btn:hover {
        background: linear-gradient(135deg, #004a5a, #003d4a);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,90,106,0.4);
        color: white;
        text-decoration: none;
        border: 1px solid rgba(255,255,255,0.2);
    }

    .station-name-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 6px rgba(0,90,106,0.3);
    }

    /* Table header styling */
    .station-name-header,
    .centered-header {
        text-align: center !important;
        vertical-align: top !important;
    }

    /* Table data centering */
    .stations-table td {
        text-align: center !important;
    }

    /* Desktop modal styling */
    .modal {
        padding: 20px !important;
    }

    .modal-content {
        margin: 0 auto !important;
        width: 80% !important;
        max-width: 600px !important;
        max-height: 80vh !important;
        border-radius: 8px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        padding: 15px;
        flex-shrink: 0;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .modal-header .close {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        color: white;
        font-size: 24px;
        font-weight: bold;
        cursor: pointer;
        z-index: 10;
    }

    .modal-header h3 {
        margin: 0;
        color: white;
    }

    .modal-body {
        padding: 15px;
        max-height: calc(80vh - 120px);
        overflow-y: auto;
        flex: 1;
    }

    .modal-footer {
        flex-shrink: 0;
        padding: 15px;
    }
</style>
