html {
    font-size: 15px; /* Set a slightly smaller base font size for the whole app */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: #f4f4f9;
}

.app-container {
    display: flex;
    flex-direction: column; /* Stack the ad banner and the main content */
    height: 100vh;
}

.controls-panel {
    width: 320px; /* Narrower for a more simplistic design */
    padding: 20px;
    background: #fff;
    height: 100%; /* Make panel fill the available height */
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    overflow-y: auto;
    z-index: 10;
}

.app-logo, .app-logo-panel {
    display: block; /* Allows for margin auto centering */
    max-width: 100%;
    height: auto;
    margin-bottom: 25px;
    border: 2px solid #ced4da; /* A thicker, slightly darker border for more definition */
    padding: 10px; /* Add some space between the logo and the border */
    border-radius: 8px; /* Add rounded corners for a softer look */
    box-sizing: border-box; /* Ensure padding and border are included in the element's total width and height */
}

.app-logo {
    width: 100%; /* Match the width of the input fields below */
}

.app-logo-panel {
    width: 80%; /* A slightly smaller logo for the side panel */
    margin-left: auto;
    margin-right: auto;
}

.mobile-menu-btn {
    display: none; /* Hidden by default on desktop */
    position: fixed;
    top: 15px; /* Position near the top */
    left: 15px;
    z-index: 1002; /* Above everything */
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 40px;
    height: 40px;
    font-size: 1.5em;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

.main-content {
    display: flex;
    flex-grow: 1;
    position: relative; /* Needed for positioning child elements */
}

/* --- Form Controls --- */
.input-group {
    margin-bottom: 15px;
}

.vehicle-type-selector {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.vehicle-type-selector label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-weight: 500;
}

.mpg-group, .travelers-group, .driving-hours-group, .ev-range-group {
    display: grid;
    grid-template-columns: 1fr auto; /* Label takes available space, input is sized to its content */
    align-items: center;
    gap: 15px; /* Creates consistent space between label and input */
}

.mpg-group label, .ev-range-group label, .travelers-group label, .driving-hours-group label {
    font-weight: 500;
}

.mpg-group input[type="number"], .ev-range-group input[type="number"], .travelers-group input[type="number"], .driving-hours-group input[type="number"] {
    width: 80px; /* Give the input a fixed width for a clean look */
}

input[type="text"],
input[type="datetime-local"],
input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.stop-group {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.stop-input-wrapper {
    flex-grow: 1;
}

.remove-stop-btn {
    width: auto; /* Override default button width */
    padding: 5px 12px;
    font-size: 1.5em;
    line-height: 1;
    background-color: #f8f9fa;
    color: #dc3545; /* Red */
    border: 1px solid #ddd;
    flex-shrink: 0;
    height: 40px; /* Adjust to better match input height */
}

.remove-stop-btn:hover {
    background-color: #dc3545;
    color: white;
    border-color: #c82333;
}

.time-controls p {
    font-size: 0.8em;
    color: #666;
    margin: 0 0 5px 0;
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
    font-family: inherit; /* Ensure buttons use the body font */
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

#add-stop-btn {
    background-color: #6c757d;
    margin-bottom: 15px;
}

#add-stop-btn:hover {
    background-color: #5a6268;
}

.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.mini-loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

#routes-panel {
    display: none; /* Hide by default, will be shown by JS when routes are available */
    margin-top: 20px;
}

#routes-list {
    list-style-type: none;
    padding: 0;
}

#routes-list li {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
}

#routes-list li:hover {
    background-color: #e9ecef;
    border-color: #007bff;
}

#routes-list li.selected {
    background-color: #d1e7ff;
    border-left: 5px solid #007bff;
}

.ai-summary-panel {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    background-color: #f8f9fa;
}

.summary-header {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.summary-header h3 {
    margin: 0;
    color: #0056b3;
}

#ai-summary-text {
    line-height: 1.5;
    margin-bottom: 10px;
}

#ai-cost-breakdown {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.cost-item .label {
    color: #495057;
}

.cost-item .value {
    font-weight: 600;
    color: #212529;
}

.cost-item-details {
    font-size: 0.8em;
    color: #6c757d;
    width: 100%;
    text-align: right;
    margin-top: -5px;
    margin-bottom: 10px;
}

.cost-item.total {
    font-weight: bold;
    font-size: 1.1em;
    border-top: 1px solid #dee2e6;
    padding-top: 10px;
}

.route-summary {
    font-weight: normal;
    font-size: 0.9em;
    color: #6c757d;
}

.arrival-info {
    font-weight: bold;
    color: #0056b3;
    font-size: 1em;
    margin-top: 5px;
    display: inline-block;
}

/* --- Right Side Weather Panel --- */

.toggle-btn {
    position: fixed;
    top: calc(70px + 30%); /* Position relative to the main content area */
    right: 0;
    transform: translateY(-50%) rotate(-90deg);
    transform-origin: bottom right;
    z-index: 1000;
    padding: 8px 40px; /* Doubled horizontal padding again to make the button even longer */
    border-radius: 8px 8px 0 0;
    background-color: #007bff;
    color: white;
    font-size: 1em;
    box-shadow: -2px -2px 5px rgba(0,0,0,0.2);
    border: 1px solid #0056b3;
    cursor: pointer;
    display: none; /* Initially hidden */
}

.weather-details-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 240px;
    max-width: 90%;
    height: 100vh;
    background: #fff;
    box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    z-index: 1001;
    transform: translateX(100%); /* Initially off-screen */
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.weather-details-panel.open {
    transform: translateX(0); /* Slide into view */
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2.2em;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: auto;
}

#weather-details-list {
    list-style-type: none;
    padding: 0;
    padding-left: 50px; /* Space for icons and timeline */
    margin-top: 20px;
    position: relative;
}

/* The main timeline bar - created by connecting pseudo-elements on each list item */
#weather-details-list li::before {
    content: '';
    position: absolute;
    left: -31px; /* Aligns the line with the center of the icon in the padded area */
    width: 2px;
    border-left: 2px dashed #ced4da;
    z-index: 0;
    top: 0;
    height: 100%;
}

/* For the first item, the line should start from the center and go down */
#weather-details-list li:first-child::before {
    top: 50%;
    height: 50%;
}

/* For the last item, the line should go from the top to the center */
#weather-details-list li:last-child::before {
    height: 50%;
}

#weather-details-list li {
    position: relative;
    padding: 10px 0;
    min-height: 40px; /* Ensure space for the icon */
}

.weather-icon-column {
    position: absolute;
    left: -50px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 40px;
    z-index: 1;
}

.weather-item-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff; /* White background to sit on top of the line */
    border: 2px solid #adb5bd;
    border-radius: 50%;
    z-index: 1;
}

.weather-item-icon img {
    width: 90%;
    height: 90%;
    border-radius: 50%;
}

.car-icon {
    width: 30px;
    height: 30px;
    fill: #6c757d;
}

.endpoint-icon {
    width: 28px;
    height: 28px;
}

.start-icon {
    fill: #28a745; /* Green */
    border-color: #28a745;
}

.stop-icon {
    fill: #9d34eb; /* Purple */
    border-color: #9d34eb;
}

.destination-icon {
    fill: #dc3545; /* Red */
    border-color: #dc3545;
}

.weather-item-info {
    display: flex;
    flex-direction: column;
}

.weather-item-info strong {
    display: block;
    font-size: 1em;
    font-weight: 600;
    margin-bottom: 4px;
}

.weather-item-info span {
    color: #6c757d;
    font-size: 0.9em;
}

.weather-item-distance {
    /* Remove absolute positioning for stacked layout */
    font-size: 0.8em;
    color: #6c757d;
    font-weight: 600;
    margin-top: 5px;
}

/* --- POI (Points of Interest) Actions --- */

.poi-actions {
    margin-top: 10px;
    display: flex;
    /* flex-wrap is removed to keep buttons in a single row */
    gap: 6px; /* Reduced gap to help buttons fit */
}

.poi-action-btn {
    background-color: transparent;
    border: none;
    /* border-radius is no longer needed without a background */
    padding: 0;
    cursor: pointer;
    font-size: 1.2rem; /* Base size, overridden by JS */
    transition: opacity 0.2s; /* Transition for the new hover effect */
    width: 32px; /* Reduced size to fit in a single row */
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.poi-action-btn:hover {
    /* A subtle opacity change for hover since there's no background */
    opacity: 0.7;
}

.poi-action-btn svg {
    width: 20px;
    height: 20px;
    fill: #495057; /* A neutral dark grey */
    transition: fill 0.2s;
}

.poi-action-btn:hover svg {
    fill: #007bff; /* Blue on hover */
}

.find-place-btn {
    background: #f8f9fa;
    border: 1px solid #ced4da;
    padding: 4px 8px;
    font: inherit;
    font-size: 0.85em;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
}

.find-place-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.info-icon {
    font-weight: bold;
    margin-right: 5px;
    color: #007bff;
}

.resolved-location {
    font-weight: 600;
    font-style: italic;
    color: #212529; /* A dark, prominent color */
}

.direction-info {
    font-style: normal;
    font-size: 0.95em;
    font-weight: 500;
}

.direction-info.ahead {
    color: #28a745; /* Green */
}
.direction-info.nearby {
    color: #6c757d; /* Grey */
}

.disclaimer {
    font-size: 0.8em;
    color: #6c757d;
    font-style: italic;
    border-top: 1px solid #e9ecef;
    padding-top: 10px;
    margin-top: 15px;
    margin-bottom: 0;
}
/* --- Responsive Styles for Mobile & Tablet --- */
@media (max-width: 800px) {
    .main-content {
        flex-direction: column; /* On mobile, map is the only element in main-content */
    }

    .controls-panel {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 280px; /* A narrower panel for mobile screens */
        transform: translateX(-100%); /* Start off-screen */
        transition: transform 0.3s ease-in-out;
    }

    .controls-panel.open {
        transform: translateX(0); /* Slide into view */
    }

    .mobile-menu-btn {
        display: block; /* Show the button on mobile */
    }

    /* On mobile, hide the helper text for the departure time to save space */
    .time-controls p {
        display: none;
    }
}

/* --- Google Maps Customizations --- */

/*
 * Force the InfoWindow to be fully opaque and have consistent padding.
 * This prevents a "faded" look that can occur from conflicting styles
 * or rendering glitches.
 */
.gm-style-iw-c {
    opacity: 1 !important;
    padding: 12px !important;
}

/*
 * Ensure the content container inside the InfoWindow is visible and
 * doesn't show unnecessary scrollbars for short content.
 */
.gm-style-iw-d {
    overflow: visible !important;
}

/* Custom styling for the content we inject into the InfoWindow */
.info-window {
    font-size: 1rem;
    line-height: 1.4;
}
.info-window p {
    margin: 4px 0 0 0;
}
