* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
    height: 100vh;
    background: #f7fafc;
}

/* Input Screen Styles */
#inputScreen {
    height: 100vh;
    overflow-y: auto;
    background: url("../background.jpg") no-repeat center center / cover;
    padding: 20px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#inputScreen.hidden {
    transform: translateX(-100%);
    position: absolute;
    pointer-events: none;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    padding: 30px 20px;
}

h1 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.about-toggle {
    background: transparent;
    color: #718096;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.9em;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-weight: 600;
    margin-left: auto;
}

.about-toggle:hover {
    border-color: #001f4d;
    color: #001f4d;
    background: transparent;
    transform: none;
    box-shadow: none;
}

.about-section {
    max-height: 0;
    overflow: hidden;
    background: #f7fafc;
    border-radius: 8px;
    margin-bottom: 20px;
}

.about-section.expanded {
    max-height: none;
}

.about-content {
    padding: 20px;
    position: relative;
}

.about-content h3,
.about-content h4 {
    color: #4a5568;
    margin-bottom: 15px;
    margin-top: 20px;
}

.about-content h3 {
    font-size: 1.3em;
    font-weight: 600;
}

.about-content h4 {
    font-size: 1.1em;
    font-weight: 600;
}

.about-content p {
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 15px;
}

.about-content ol {
    color: #4a5568;
    line-height: 1.8;
    padding-left: 25px;
    margin-bottom: 10px;
}

.about-content ol li {
    margin-bottom: 8px;
}

.about-content .footnote {
    font-size: 0.9em;
    color: #718096;
    font-style: italic;
    margin-top: 5px;
    margin-bottom: 20px;
}

.about-content a {
    color: #001f4d;
    text-decoration: none;
    font-weight: 600;
}

.about-content a:hover {
    text-decoration: underline;
}

.privacy-notice {
    font-size: 12px;
}

.section {
    margin-bottom: 30px;
}

.section-title {
    color: #2d3748;
    font-size: 1.2em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.input-group {
    margin-bottom: 15px;
    position: relative;
}

label {
    display: block;
    color: #4a5568;
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.address-input-wrapper {
    position: relative;
    flex-grow: 1;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s;
}

input[type="text"].with-search {
    padding-right: 80px;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #001f4d;
}

.search-button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: #001f4d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
}

.search-button:hover {
    background: #003366;
    transform: translateY(-50%) scale(1.05);
    box-shadow: none;
}

.search-button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #001f4d;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.autocomplete-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.2s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f7fafc;
}

.autocomplete-item.selected {
    background: #edf2f7;
}

.autocomplete-item-name {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 2px;
}

.autocomplete-item-coords {
    font-size: 0.85em;
    color: #718096;
}

.loading-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to { transform: rotate(360deg); }
}

.destination-item {
    background: #f7fafc;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.destination-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.destination-number {
    background: #001f4d;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9em;
}

.coord-inputs {
    display: none;
}

button {
    background: #001f4d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    background: #003366;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 31, 77, 0.4);
}

button.secondary {
    background: #718096;
}

button.secondary:hover {
    background: #4a5568;
}

button.danger {
    background: transparent;
    padding: 0;
    font-size: 1.2em;
    width: auto;
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc2626;
    font-weight: bold;
}

button.danger:hover {
    background: transparent;
    color: #991b1b;
    transform: scale(1.1);
    box-shadow: none;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.calculate-button {
    font-size: 1.1em;
    padding: 15px 30px;
    margin-top: 10px;
}

/* Map Screen Styles */
#mapScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#mapScreen.visible {
    transform: translateX(0);
}

#map {
    width: 100%;
    height: 100vh;
    background: #f0f0f0;
}

/* Map Theme Switcher */
.map-theme-switcher {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 900;
    display: flex;
    flex-direction: row;
    gap: 8px;
}

@media (max-width: 768px) {
    .map-theme-switcher {
        flex-direction: column;
        padding-bottom: 80px;
    }
}

.theme-option {
    width: 40px;
    height: 40px;
    border: 2px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    background: white;
}

.theme-option:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.theme-option.active {
    border-color: #001f4d;
    box-shadow: 0 0 0 2px rgba(0, 31, 77, 0.4);
}

.theme-preview {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.theme-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 7px;
    padding: 1px 2px;
    text-align: center;
    font-weight: 600;
}

#mapControlButtons {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 1000;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mapControlButtons.above-panel {
    bottom: calc(40vh + 20px);
}

#expandButton {
    padding: 10px 15px;
    width: 70px;
    height: 50px;
    border-radius: 25px;
    background: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#expandButton:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

#expandButton svg {
    flex-shrink: 0;
}

.map-control-button {
    padding: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-control-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

#fitRouteButton {
    padding: 10px;
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

#fitRouteButton:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.panel-actions {
    position: relative;
    padding: 15px 15px 10px;
    display: flex;
    gap: 10px;
    z-index: 10;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 20px 20px 0 0;
}

#listPanel.expanded .panel-actions {
    position: sticky;
    top: 0;
}

.home-address-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #001f4d;
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

.home-address-display svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.home-address-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-action-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.panel-action-button {
    padding: 8px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.panel-action-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border-color: #718096;
}

.panel-action-button svg {
    width: 20px;
    height: 20px;
}

#listPanel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    min-height: 20vh;
    max-height: 80vh;
}

#listPanel.resizing {
    transition: none;
}

.resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    cursor: ns-resize;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resize-handle::before {
    content: '';
    width: 40px;
    height: 4px;
    background: #cbd5e0;
    border-radius: 2px;
    transition: background 0.2s;
}

.resize-handle:hover::before,
.resize-handle:active::before {
    background: #718096;
}

#listPanel.expanded {
    transform: translateY(0);
}

#settingsPanel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    max-height: 50vh;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    z-index: 999;
}

#settingsPanel.expanded {
    transform: translateY(0);
}

.settings-close-button {
    width: 40px;
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.settings-close-button:hover {
    background-color: rgba(113, 128, 150, 0.1);
}

.settings-close-button svg {
    display: block;
}

.settings-content {
    padding: 30px 20px;
}

.settings-content h3 {
    color: #2d3748;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    color: #4a5568;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.setting-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.setting-group select:focus {
    outline: none;
    border-color: #001f4d;
}

.setting-description {
    margin-top: 8px;
    color: #718096;
    font-size: 0.85em;
    line-height: 1.4;
}

.list-content {
    padding: 20px;
    padding-bottom: 100px;
    overflow-y: auto;
    flex: 1;
}

.route-step {
    background: #f7fafc;
    padding: 0 15px;
    margin-bottom: 12px;
    border-left: 4px solid #001f4d;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: opacity 0.2s, transform 0.2s;
}

.route-step.draggable {
    cursor: move;
}

.route-step.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.route-step.drag-over {
    border-top: 3px solid #001f4d;
}

.drag-handle {
    cursor: grab;
    padding: 5px;
    color: #001f4d;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none; /* Prevent default touch behaviors like scrolling */
}

.drag-handle:active {
    cursor: grabbing;
}

.route-step.draggable {
    touch-action: none; /* Prevent scrolling while dragging */
}

.drag-handle svg {
    width: 20px;
    height: 20px;
}

.step-number {
    background: #001f4d;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    font-size: 0.9em;
}

.step-details {
    flex-grow: 1;
}

.step-address {
    font-weight: 600;
    color: #2d3748;
}

/* Batch Accordion Styles */
.batch-accordion {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow: hidden;
}

.batch-header {
    background: #718096;
    opacity: 0.60;
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s;
}

.batch-header:hover {
    background: #4a5568;
}

.batch-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.batch-number {
    background: white;
    color: #718096;
    min-width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9em;
    padding: 0 8px;
}

.batch-title {
    font-weight: 600;
    font-size: 1em;
}

.batch-warning {
    background: #f59e0b;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    margin-left: 10px;
}

.batch-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.maps-link-small {
    background-color: #001f4d;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.2s;
    white-space: nowrap;
}

.maps-link-small:hover {
    transform: scale(1.05);
}

.maps-link-small.disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.6;
}

.expand-icon {
    transition: transform 0.3s;
    font-size: 0.9em;
}

.batch-accordion.expanded .expand-icon {
    transform: rotate(180deg);
}

.batch-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: #f7fafc;
}

.batch-accordion.expanded .batch-content {
    max-height: 2000px;
    transition: max-height 0.5s ease-in;
}

.batch-stops {
    padding: 15px;
}

@media (max-width: 768px) {
    #mapControlButtons {
        bottom: 20px;
    }

    #mapControlButtons.above-panel {
        bottom: calc(40vh + 20px);
    }
}

/* Leaflet attribution z-index override to keep it below panels */
.leaflet-control-attribution {
    z-index: 500 !important;
}

@media (max-width: 480px) {
    .container {
        padding: 20px 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    .coord-inputs {
        grid-template-columns: 1fr;
    }
}
