/* ============================================
   ACTIVE DRIVE STYLES
   ============================================
   Normal app layout (not fullscreen)
   Integrated with sidebar and header
   ============================================ */

/* Container - full width like other pages (manage-jobs, etc) */
.active-drive-container {
    /* No max-width - let it use full available width like other pages */
    padding-bottom: 20px;
}

/* Page Header - Base styles */
.active-drive-container .page-header-content h1 {
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.active-drive-container .page-header-content p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Page Header - Desktop: match standard page-header-blue exactly */
@media (min-width: 768px) {
    .active-drive-container .page-header-blue {
        background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
        color: white !important;
        padding: 25px 30px !important;
        border-radius: 12px !important;
        margin-bottom: 25px !important;
    }

    .active-drive-container .page-header-content h1 {
        font-size: 1.8rem !important;
    }
}

/* Page Header - Mobile: keep edge-to-edge style */
@media (max-width: 767px) {
    .active-drive-container .page-header-blue {
        background: linear-gradient(135deg, var(--color-secondary) 0%, var(--color-primary) 100%);
        color: white;
        padding: 24px 20px;
        margin: -16px -16px 20px -16px;
        border-radius: 0 0 12px 12px;
        text-align: center;
    }

    .active-drive-container .page-header-content h1 {
        font-size: 1.2rem;
        text-align: center;
    }
}

/* Compact header layout */
.drive-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.drive-header-top .drive-status-badge {
    flex-shrink: 0;
}

.drive-header-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 0.85rem;
    opacity: 0.95;
}

.drive-header-info .header-divider {
    opacity: 0.6;
}

/* Content area */
.active-drive-content {
    padding: 0 4px;
    padding-bottom: 80px; /* Space above footer/bottom nav on mobile */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Job Card */
.drive-job-card {
    background: var(--color-surface, white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.drive-job-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.drive-job-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.drive-job-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--color-text-primary, #2c3e50);
    flex: 1;
}

.drive-status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    /* White background with green text for maximum visibility on blue header */
    background: white;
    color: var(--color-success, #27ae60);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.status-pulse {
    width: 8px;
    height: 8px;
    background: var(--color-success, #4caf50);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

.drive-job-counterparty {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-secondary, #666);
    font-size: 0.95rem;
}

/* Route Card */
.drive-route-card {
    background: var(--color-surface, white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.drive-route-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.route-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border-light, #f0f0f0);
}

.route-card-title {
    font-weight: 600;
    color: var(--color-text-primary, #333);
}

.route-edit-btn {
    background: var(--color-background, #f5f5f5);
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: var(--color-text-muted, #666);
    cursor: pointer;
    transition: all 0.2s;
}

.route-edit-btn:hover {
    background: var(--color-background-dark, #e8e8e8);
    color: var(--color-text-primary, #333);
}

.route-point {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.route-icon {
    font-size: 1.3em;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.route-details {
    flex: 1;
}

.route-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted, #999);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.route-address {
    display: block;
    font-size: 0.95rem;
    color: var(--color-text-primary, #2c3e50);
}

.route-line {
    width: 2px;
    height: 24px;
    background: linear-gradient(to bottom, var(--color-primary), var(--color-success-light));
    margin: 8px 0 8px 15px;
    border-radius: 1px;
}

/* Map Card */
.drive-map-card {
    background: var(--color-surface, white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.drive-map-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border, #e0e0e0);
    font-weight: 500;
    color: var(--color-text-primary, #2c3e50);
}

/* Compact route summary in map header */
.route-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.route-summary-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
}

.route-icon-small {
    font-size: 1rem;
}

.route-text {
    color: var(--color-text-primary, #2c3e50);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-arrow {
    color: var(--color-primary, #3498db);
    font-weight: 600;
}

/* Route action buttons container */
.route-action-buttons {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.route-edit-btn-small {
    background: transparent;
    border: none;
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.route-edit-btn-small:hover {
    background: rgba(0, 0, 0, 0.05);
}

.route-reset-btn-small {
    background: transparent;
    border: none;
    padding: 4px 8px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.7;
}

.route-reset-btn-small:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

.route-reset-btn-small:active {
    transform: rotate(-180deg);
}

.drive-map-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--color-text-muted, #666);
}

.drive-map-stats .stat strong {
    color: var(--color-primary, #3498db);
    font-size: 1.1em;
}

.stat-divider {
    color: var(--color-border-light, #ccc);
}

/* Navigation target indicator */
.navigation-target {
    font-weight: 500;
    color: var(--color-primary, #3498db);
}

/* Navigation leg toggle */
.navigation-leg-toggle {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--color-border-light, #eee);
    border-bottom: 1px solid var(--color-border-light, #eee);
    margin: 8px 0;
}

.leg-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: 2px solid var(--color-border, #e0e0e0);
    border-radius: 10px;
    background: var(--color-background, #f8f9fa);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted, #666);
    min-height: 48px; /* Touch-friendly */
}

.leg-toggle-btn:hover {
    border-color: var(--color-primary, #3498db);
    background: rgba(52, 152, 219, 0.05);
}

.leg-toggle-btn.active {
    border-color: var(--color-primary, #3498db);
    background: linear-gradient(135deg, var(--color-primary, #3498db) 0%, var(--color-primary-dark, #2980b9) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.leg-toggle-btn .leg-icon {
    font-size: 1.2rem;
}

.leg-toggle-btn .leg-label {
    white-space: nowrap;
}

/* Mobile: stack toggle buttons if needed */
@media (max-width: 400px) {
    .navigation-leg-toggle {
        flex-direction: column;
    }

    .leg-toggle-btn {
        width: 100%;
    }
}

.drive-map {
    height: 300px;
    width: 100%;
    /* Ensure Leaflet map receives touch events for drag/pan */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Map markers */
.drive-marker {
    background: transparent !important;
    border: none !important;
}

.drive-marker .marker-content {
    font-size: 28px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pill-style markers (matches LiveTransports) */
.marker-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.marker-pill svg {
    filter: none;
}

/* Pickup marker: green */
.marker-pill-pickup {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    color: #2e7d32;
}

.marker-pill-pickup svg {
    color: #2e7d32;
    stroke: #2e7d32;
}

/* Delivery marker: orange */
.marker-pill-delivery {
    background: #fff3e0;
    border: 2px solid #ff9800;
    color: #e65100;
}

.marker-pill-delivery svg {
    color: #e65100;
    stroke: #e65100;
}

.drive-marker.driver-marker .marker-content {
    font-size: 36px;
    position: relative;
}

/* Driver marker with pulsing effect */
.drive-marker.driver-marker .marker-content::before {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(52, 152, 219, 0.3);
    border-radius: 50%;
    animation: driver-pulse 2s ease-out infinite;
    z-index: -1;
}

@keyframes driver-pulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Quick Contact Row */
.drive-contact-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.drive-contact-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 24px;
    background: var(--color-surface, white);
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: var(--color-text-primary, #2c3e50);
    min-width: 90px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.drive-contact-btn:hover {
    background: var(--color-background, #f8f9fa);
    border-color: var(--color-primary, #3498db);
    transform: translateY(-3px);
    box-shadow: 0 4px 14px rgba(52, 152, 219, 0.15);
}

.drive-contact-btn:active {
    transform: translateY(-1px);
}

.drive-contact-btn .contact-icon {
    font-size: 1.6rem;
    transition: transform 0.2s ease;
}

.drive-contact-btn:hover .contact-icon {
    transform: scale(1.1);
}

.drive-contact-btn .contact-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary, #666);
}

/* Action Buttons */
.drive-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drive-actions-row {
    display: flex;
    gap: 10px;
}

.drive-btn-half {
    flex: 1;
}

.drive-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm, 8px);
    padding: 16px 24px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 56px;
    width: 100%;
    text-align: center;
    line-height: 1.4;
    overflow: hidden;
}

.drive-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.drive-btn:hover::before {
    left: 100%;
}

.drive-btn:active {
    transform: scale(0.98);
}

.drive-btn .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

.drive-btn .btn-icon svg {
    vertical-align: middle;
}

.drive-btn-primary {
    background: linear-gradient(135deg, var(--color-primary, #3498db) 0%, var(--color-primary-dark, #2980b9) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(52, 152, 219, 0.35);
}

.drive-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.45);
    filter: brightness(1.05);
}

.drive-btn-secondary {
    background: var(--color-surface, white);
    color: var(--color-text-primary, #2c3e50);
    border: 1px solid var(--color-border, #e0e0e0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.drive-btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: var(--color-background, #f8f9fa);
    border-color: var(--color-primary, #3498db);
}

.drive-btn-warning {
    background: linear-gradient(135deg, var(--color-warning, #f39c12) 0%, #e67e22 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(243, 156, 18, 0.35);
}

.drive-btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.45);
    filter: brightness(1.05);
}

.drive-btn-success {
    background: linear-gradient(135deg, var(--color-success, #27ae60) 0%, var(--color-success-dark, #229954) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(39, 174, 96, 0.35);
}

.drive-btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.45);
    filter: brightness(1.05);
}

.drive-btn-link {
    background: transparent;
    color: var(--color-primary, #3498db);
    padding: 12px;
    box-shadow: none;
}

.drive-btn-link:hover {
    background: rgba(52, 152, 219, 0.08);
    transform: translateY(-1px);
}

/* Back section */
.drive-back {
    text-align: center;
    margin-top: 8px;
}

/* Responsive */
@media (max-width: 767px) {
    /* Container: remove padding for edge-to-edge header */
    .active-drive-container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    /* Header edge-to-edge with rounded bottom corners */
    .active-drive-container .page-header-blue {
        margin: 0 !important;
        margin-bottom: 16px !important;
        padding: 15px 16px !important;
        border-radius: 0 0 16px 16px !important;
        width: 100% !important;
    }

    /* Content needs padding since container has none */
    .active-drive-content {
        padding: 0 16px !important;
    }

    .drive-map {
        height: 250px;
    }

    .drive-btn {
        padding: 12px 16px;
        min-height: 48px;
    }
}

/* Sidebar menu item for active drive - must override .sidebar-item.active blue styles */
/* Active drive buttons are inside .sidebar-section (NOT .sidebar-items) */
.sidebar-section .sidebar-item.sidebar-active-drive,
.sidebar-section .sidebar-item.sidebar-active-drive.active,
.sidebar-section .sidebar-item.sidebar-active-drive:not(.active) {
    background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-light) 100%) !important;
    color: white !important;
    position: relative;
    animation: sidebar-glow 2s ease-in-out infinite;
    border-right: 3px solid var(--color-success-light) !important;
    border-left: 4px solid var(--color-success-light) !important;
}

.sidebar-section .sidebar-item.sidebar-active-drive .sidebar-icon {
    color: white !important;
}

.sidebar-section .sidebar-item.sidebar-active-drive .sidebar-icon svg {
    fill: white !important;
    stroke: none !important;
}

.sidebar-section .sidebar-item.sidebar-active-drive .sidebar-text {
    color: white !important;
}

.sidebar-section .sidebar-item.sidebar-active-drive:hover {
    background: linear-gradient(135deg, var(--color-success-dark) 0%, var(--color-success) 100%) !important;
}

/* Currently viewed drive in multi-drive mode - slightly brighter */
.sidebar-section .sidebar-item.sidebar-active-drive.sidebar-drive-current {
    background: linear-gradient(135deg, var(--color-success-light) 0%, var(--color-success) 100%) !important;
    border-left: 4px solid white !important;
}

/* Slow pulsing glow effect for active drive sidebar button */
@keyframes sidebar-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(46, 204, 113, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(46, 204, 113, 0.6), 0 0 25px rgba(46, 204, 113, 0.3);
    }
}

/* Pulsing dot indicator */
.sidebar-active-drive .status-pulse {
    animation: status-dot-pulse 2s ease-in-out infinite;
}

@keyframes status-dot-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.3);
    }
}

/* Sidebar menu item for live transports (supplier) */
.sidebar-section .sidebar-item.sidebar-live-transports,
.sidebar-section .sidebar-item.sidebar-live-transports.active,
.sidebar-section .sidebar-item.sidebar-live-transports:not(.active) {
    background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-light) 100%) !important;
    color: white !important;
    position: relative;
    display: flex;
    align-items: center;
    animation: sidebar-glow 2s ease-in-out infinite;
}

.sidebar-section .sidebar-item.sidebar-live-transports:hover {
    background: linear-gradient(135deg, var(--color-success-dark) 0%, var(--color-success) 100%) !important;
}

.sidebar-section .sidebar-item.sidebar-live-transports .sidebar-icon {
    color: white !important;
}

.sidebar-section .sidebar-item.sidebar-live-transports .sidebar-icon svg {
    fill: white !important;
}

.sidebar-section .sidebar-item.sidebar-live-transports .sidebar-text {
    color: white !important;
    flex: 1;
}

/* Live badge (count indicator) */
.sidebar-live-transports .live-badge {
    background: white;
    color: var(--color-success);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
    animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

/* Empty state */
.active-drive-no-contract {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 20px;
}

.active-drive-no-contract .empty-state {
    text-align: center;
    max-width: 400px;
}

.active-drive-no-contract .empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

/* Leaflet controls */
.leaflet-control-zoom a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 10px 12px;
    font-size: 14px;
}

/* Address autocomplete dropdown */
.address-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface, white);
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

.autocomplete-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-light, #f0f0f0);
    transition: background 0.15s;
}

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

.autocomplete-item:hover {
    background: var(--color-primary-bg, #f5f8ff);
}

.autocomplete-icon {
    flex-shrink: 0;
    font-size: 1rem;
    margin-top: 2px;
}

.autocomplete-text {
    font-size: 0.9rem;
    color: var(--color-text-primary, #333);
    line-height: 1.4;
}

.autocomplete-no-results {
    padding: 12px 14px;
    color: var(--color-text-muted, #999);
    font-size: 0.9rem;
    text-align: center;
}

/* Loading and error states for autocomplete */
.autocomplete-loading,
.autocomplete-error {
    padding: 12px 14px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-muted, #999);
}

.autocomplete-error {
    color: var(--color-danger, #e74c3c);
}

/* ============================================
   MOBILE RESPONSIVENESS - Address Autocomplete
   ============================================ */

/* ============================================
   MOBILE: BOTTOM SHEET PATTERN
   ============================================ */

/* Mobile: Bottom sheet slides up from bottom */
@media (max-width: 767px) {
    .address-autocomplete {
        /* CRITICAL: Fixed positioning relative to viewport, NOT input */
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;

        /* Height and spacing */
        max-height: 65vh;       /* 65% of viewport - leaves space for header */
        margin: 0;              /* Reset margins */
        padding-top: 16px;      /* Internal spacing for handle */

        /* Visual styling */
        border-radius: 16px 16px 0 0;  /* Rounded top corners (iOS style) */
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);  /* Elevation shadow */
        background: var(--color-surface, white);
        border: none;           /* Remove default border */

        /* Z-index above modal */
        z-index: 10050;

        /* Animation */
        animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);

        /* Enable scroll within sheet */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;  /* Smooth iOS scrolling */
    }

    /* Handle indicator at top of sheet */
    .address-autocomplete::before {
        content: '';
        position: sticky;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
        display: block;
        margin: 0 auto 12px;
    }

    /* Modal adjustments for bottom sheet interaction */
    #edit-addresses-modal {
        z-index: 10000;  /* Modal stays below sheet (10050) */
    }

    #edit-addresses-modal .modal-content {
        max-width: 95vw;
        margin: 20px auto;
        max-height: 85vh;
        overflow-y: auto;
    }

    #edit-addresses-modal .modal-body {
        padding: 16px;
    }

    #edit-addresses-modal .form-group {
        margin-bottom: 20px;
    }

    #edit-addresses-modal .modal-footer {
        flex-direction: column;
        gap: 10px;
    }

    #edit-addresses-modal .modal-footer button {
        width: 100%;
        min-height: 44px;
    }

    /* Prevent body scroll when sheet is open */
    body.bottom-sheet-open {
        overflow: hidden;
        position: fixed;  /* Prevent scroll-behind on iOS */
        width: 100%;
    }
}

/* Small mobile: Taller sheet for tiny screens */
@media (max-width: 480px) {
    .address-autocomplete {
        max-height: 70vh;  /* Slightly taller on small screens */
    }

    .autocomplete-item {
        padding: 16px 20px; /* Larger touch target (min 44px) */
        font-size: 1rem;    /* Larger text for readability */
    }

    .autocomplete-icon {
        font-size: 1.2rem;  /* Bigger icons */
    }
}

/* Desktop: Keep existing dropdown behavior */
@media (min-width: 768px) {
    .address-autocomplete {
        /* Original dropdown behavior */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: 250px;
        z-index: 1000;
        /* Existing desktop styles remain */
    }
}

/* ============================================
   MAP CONTROLS OVERLAY - Follow Mode Button
   ============================================ */

/* Wrapper for map + overlay */
.drive-map-wrapper {
    position: relative;
}

/* Controls overlay on top of map */
.map-controls-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Map control button base */
.map-control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 2px solid var(--color-border, #e0e0e0);
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary, #666);
}

.map-control-btn:hover {
    background: var(--color-background, #f8f9fa);
    border-color: var(--color-primary, #3498db);
}

.map-control-btn:active {
    transform: scale(0.95);
}

/* Follow mode button - active state */
.map-control-btn.follow-mode-btn.active {
    background: var(--color-primary, #3498db);
    border-color: var(--color-primary, #3498db);
    color: white;
}

.map-control-btn.follow-mode-btn.active:hover {
    background: var(--color-primary-dark, #2980b9);
    border-color: var(--color-primary-dark, #2980b9);
}

/* Pulsing indicator when following */
.map-control-btn.follow-mode-btn.active .control-icon {
    animation: follow-pulse 1.5s ease-in-out infinite;
}

@keyframes follow-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.map-control-btn .control-icon {
    font-size: 1rem;
    line-height: 1;
}

.map-control-btn .control-label {
    white-space: nowrap;
}

/* Mobile: smaller button, icon only when space is tight */
@media (max-width: 480px) {
    .map-controls-overlay {
        top: 8px;
        right: 8px;
    }

    .map-control-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .map-control-btn .control-label {
        /* Keep label visible but smaller */
        font-size: 0.75rem;
    }
}
