* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f5f5f5;
    color: #333;
}

.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

header {
    background: #EAEFF2;
    color: #2c3e50;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    position: relative;
    z-index: 100;
    margin: -24px -24px 20px -24px; /* Extend to edges of sidebar-content */
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.road-sorties-logo {
    width: 180px;
    height: 180px;
    flex-shrink: 0;
    display: block;
}

.header-brand-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.header-title {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #2C5F7C;
    line-height: 1;
    white-space: nowrap;
}

.header-tagline {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
    letter-spacing: 0.5px;
    color: #666;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 400px;
    min-width: 300px;
    max-width: 800px;
    background: #ffffff;
    box-shadow: 1px 0 3px rgba(0,0,0,0.08);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    border-right: 1px solid #e8e8e8;
    position: relative;
}

.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    cursor: col-resize;
    z-index: 1000;
    transition: background 0.2s ease;
}

.sidebar-resize-handle:hover {
    background: #2C5F7C;
}

.sidebar-resize-handle:active {
    background: #245A73;
}

.sidebar-content {
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

.search-section h2 {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 20px 0;
    color: #2c3e50;
    letter-spacing: -0.3px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: #2c3e50;
}

.tab-btn.active {
    color: #2C5F7C;
    border-bottom-color: #2C5F7C;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Waypoint styling */
.waypoints-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.waypoints-container {
    flex: 1;
}

.flip-waypoints-container {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.flip-waypoints-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #2C5F7C;
    background: white;
    color: #2C5F7C;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.flip-waypoints-btn:hover {
    background: #2C5F7C;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(44, 95, 124, 0.3);
}

.flip-waypoints-btn:active {
    transform: scale(0.95);
}

.flip-icon {
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
}

.waypoint-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    position: relative;
    transition: opacity 0.2s ease;
}

.waypoint-item.dragging {
    opacity: 0.5;
}

.waypoint-item.drag-over {
    border-top: 3px solid #2C5F7C;
}

.waypoint-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.drag-handle {
    cursor: move;
    color: #7f8c8d;
    font-size: 20px;
    font-weight: bold;
    padding: 4px 8px;
    user-select: none;
    display: inline-block !important;
    visibility: visible !important;
    transition: all 0.15s ease;
    line-height: 1;
    min-width: 24px;
    text-align: center;
    letter-spacing: -2px; /* Bring the dots closer together */
}

.drag-handle:hover {
    color: #2C5F7C;
    transform: scale(1.1);
}

.waypoint-label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.remove-waypoint {
    background: transparent;
    color: #bdc3c7;
    border: none;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    position: relative;
}

.remove-waypoint:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Tooltip for remove button */
.remove-waypoint-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    padding: 6px 10px;
    background: #2c3e50;
    color: white;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.remove-waypoint-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 12px;
    border: 5px solid transparent;
    border-top-color: #2c3e50;
}

.remove-waypoint:hover .remove-waypoint-tooltip {
    opacity: 1;
}

.search-box {
    position: relative;
}

.waypoint-input {
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: #fff;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    box-sizing: border-box;
}

.waypoint-input:focus {
    outline: none;
    border-color: #2C5F7C;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.autocomplete-item:hover {
    background: #f5f5f5;
}

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

.autocomplete-item-name {
    font-size: 14px;
    color: #333;
}

.add-waypoint-btn {
    width: 100%;
    padding: 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    transition: all 0.15s ease;
    margin-top: 8px;
}

.add-waypoint-btn:hover {
    background: #f9f9f9;
    border-color: #2C5F7C;
    color: #2C5F7C;
}

.get-directions-btn {
    width: 100%;
    padding: 12px;
    background: #2C5F7C;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: white;
    transition: all 0.15s ease;
    margin-top: 16px;
}

.get-directions-btn:hover {
    background: #245A73;
}

.get-directions-btn:active {
    transform: translateY(1px);
}

/* Route Options Section */
.route-options-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e8e8e8;
}

.route-options-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.route-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.route-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}

.route-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: #2C5F7C;
}

.route-option span {
    font-size: 14px;
    color: #333;
    flex: 1;
}

.route-option:hover span {
    color: #2c3e50;
}

.route-info {
    overflow-y: auto;
    padding: 24px;
}

/* Route information and alternatives */
.route-info h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 16px;
    margin-top: 0;
}

#routesContainer {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.route-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.route-card:hover {
    border-color: #bdbdbd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.route-card.active {
    border-color: #2196F3;
    background: #f5f9ff;
}

.route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    position: relative;
}

.route-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.route-symbols {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.route-symbol {
    font-size: 18px;
    cursor: help;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
    display: inline-block;
}

.route-symbol:hover {
    opacity: 1;
    transform: scale(1.1);
}

.route-details {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.route-info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #555;
}

.route-info-item .icon {
    font-size: 16px;
}

.route-info-item .value {
    font-weight: 500;
    color: #333;
}

.route-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-size: 14px;
    color: #555;
}

.route-toggle-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2196F3;
}

.route-flags {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.route-flag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: #f0f0f0;
    color: #666;
}

.route-flag.highway-flag {
    background: #fff3e0;
    color: #e65100;
}

.route-flag.toll-flag {
    background: #ede7f6;
    color: #512da8;
}

.route-details {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 14px;
}

.route-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #555;
}

.route-icon {
    font-size: 16px;
}

.route-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-left: auto;
}

.route-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.route-flags {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
}

.route-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

.route-details-btn {
    padding: 8px 16px;
    background: #2C5F7C;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
    width: 100%;
}

.route-details-btn:hover {
    background: #245A73;
}

.route-details-btn:active {
    transform: translateY(1px);
}

/* Route Details Modal */
.route-details-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.route-details-content {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.route-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.route-details-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.route-details-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.route-details-close:hover {
    background: #f0f0f0;
}

.route-details-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.route-details-summary {
    margin-bottom: 0;
    padding-bottom: 0;
}

.route-details-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.route-details-stat:last-child {
    margin-bottom: 0;
}

.stat-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.stat-value {
    font-size: 16px;
    color: #2c3e50;
    font-weight: 600;
}

.route-details-maneuvers {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.route-details-maneuvers h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 16px 0;
}

.maneuvers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.maneuver-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 6px;
    border-left: 3px solid #2C5F7C;
    align-items: center;
}

.maneuver-number {
    width: 28px;
    height: 28px;
    background: #2C5F7C;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.maneuver-arrow {
    font-size: 24px;
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2C5F7C;
}

.maneuver-content {
    flex: 1;
}

.maneuver-instruction {
    font-size: 14px;
    color: #2c3e50;
    margin-bottom: 4px;
    line-height: 1.4;
}

.maneuver-distance {
    font-size: 12px;
    color: #666;
}

.route-details-export {
    margin-top: 16px;
    margin-bottom: 0;
    padding: 0;
    border: none;
}

.route-details-export h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 12px 0;
}

.export-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.export-controls select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.export-btn {
    padding: 8px 20px;
    background: #2C5F7C;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.export-btn:hover {
    background: #245A73;
}

.route-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.route-details-btn {
    padding: 8px 16px;
    background: #2C5F7C;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
    width: 100%;
}

.route-details-btn:hover {
    background: #245A73;
}

.route-details-btn:active {
    transform: translateY(1px);
}

.route-btn {
    flex: 1;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s ease;
}

.route-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.paste-section {
    margin-bottom: 16px;
}

.paste-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 8px;
}

.addresses-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: monospace;
    resize: vertical;
    min-height: 120px;
}

.addresses-textarea:focus {
    outline: none;
    border-color: #2C5F7C;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.address-count {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    text-align: right;
}

.address-count.warning {
    color: #e74c3c;
    font-weight: 600;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}


/* Map controls group - unified vertical stack */
.map-controls-group {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.map-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: white;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    font-size: 18px;
    color: #2c3e50;
    transition: all 0.15s ease;
}

.map-control-btn:last-child {
    border-bottom: none;
}

.map-control-btn:hover {
    background: #f5f5f5;
}

.map-control-btn:active {
    background: #e8e8e8;
}

.map-control-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.map-control-btn span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.map-container {
    flex: 1;
    position: relative;
}

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

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}
