/* RightRoute Styles */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Custom Buttons */
.btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 8px 16px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: transparent;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    color: white;
}

.btn-success {
    background-color: #198754;
    border-color: #198754;
    color: white;
}

.btn-success:hover {
    background-color: #157347;
    border-color: #146c43;
    color: white;
}

.btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5c636a;
    border-color: #565e64;
    color: white;
}

.btn-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #ffca2c;
    border-color: #ffc720;
    color: #212529;
}

.btn-info {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: #000;
}

.btn-info:hover {
    background-color: #31d2f2;
    border-color: #25cff2;
    color: #000;
}

.btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #bb2d3b;
    border-color: #b02a37;
    color: white;
}

.btn-outline-primary {
    background-color: white;
    color: #0d6efd;
    border: 1px solid #0d6efd;
}

.btn-outline-primary:hover {
    background-color: #0d6efd;
    color: white;
}

.btn-outline-secondary {
    background-color: white;
    color: #6c757d;
    border: 1px solid #6c757d;
}

.btn-outline-secondary:hover {
    background-color: #6c757d;
    color: white;
}

/* Custom Inputs */
.form-control {
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-select {
    border-radius: 6px;
    border: 1px solid #ced4da;
    padding: 8px 12px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-select:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Notification Container */
.notification-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    pointer-events: none;
}

.custom-notification {
    background: white;
    border-radius: 8px;
    padding: 14px 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: all;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    border-left: 4px solid #0dcaf0;
}

.custom-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.custom-notification-success {
    border-left-color: #198754;
}

.custom-notification-error {
    border-left-color: #dc3545;
}

.custom-notification-warning {
    border-left-color: #ffc107;
}

.custom-notification-info {
    border-left-color: #0dcaf0;
}

.notification-icon {
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

.custom-notification-success .notification-icon {
    color: #198754;
}

.custom-notification-error .notification-icon {
    color: #dc3545;
}

.custom-notification-warning .notification-icon {
    color: #ffc107;
}

.custom-notification-info .notification-icon {
    color: #0dcaf0;
}

.notification-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
}

.notification-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.notification-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* Top Bar */
.top-bar {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 10px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    z-index: 2000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
}

.top-bar .search-container {
    flex: 1;
}

.top-bar .sidebar-toggle-btn {
    flex-shrink: 0;
    align-self: center;
}

.search-container {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
}

.search-container input {
    flex: 1;
    min-width: 200px;
}

.search-container .btn {
    white-space: nowrap;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: stretch;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
}

.search-input-wrapper:focus-within {
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.2), 0 2px 6px rgba(13, 110, 253, 0.1);
    border-color: #0d6efd;
    transform: translateY(-1px);
}

.custom-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 15px 60px 15px 20px;
    font-size: 15px;
    background: transparent;
    color: #1a1a1a;
    font-weight: 400;
    transition: all 0.2s ease;
    line-height: 1.5;
}

.custom-search-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
    opacity: 0.8;
}

.custom-search-input:focus {
    background: #f8f9fa;
}

.custom-search-input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.custom-search-btn {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 55px;
    border: none;
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 16px;
    padding: 0;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.custom-search-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0b5ed7 0%, #0a58ca 100%);
    transform: scale(1.05);
    box-shadow: -2px 0 12px rgba(13, 110, 253, 0.3);
}

.custom-search-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.custom-search-btn:disabled {
    background: #000000;
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
}

.custom-search-btn .icon-svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.custom-search-btn:hover:not(:disabled) .icon-svg {
    transform: scale(1.1);
}

.btn-icon,
.icon-svg {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
}

.icon-svg {
    filter: brightness(0) invert(1);
}

.btn-secondary .icon-svg {
    filter: brightness(0) invert(1);
}

.btn-info .icon-svg {
    filter: brightness(0) invert(1);
}

.btn-warning .icon-svg {
    filter: brightness(0) invert(0);
}

.custom-search-btn .icon-svg {
    filter: brightness(0) invert(1);
}

.btn-text {
    margin-left: 6px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.map-panel {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: #fff;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 4px rgba(0,0,0,0.1);
    z-index: 500;
    transition: transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.sidebar.hidden {
    transform: translateX(100%);
}

@media (min-width: 769px) {
    .sidebar {
        display: none;
    }
    
    .sidebar.show {
        display: flex;
    }
    
    .sidebar-toggle-btn {
        display: inline-block !important;
    }
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h5 {
    margin: 0;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Bottom Bar */
.bottom-bar {
    background: #fff;
    border-top: 1px solid #ddd;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

/* Modals should be above top and bottom bars */
.modal {
    z-index: 5000 !important;
}

.modal-backdrop {
    z-index: 4999 !important;
}

.stop-counter {
    font-weight: bold;
    color: #333;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Route Round Colors */
.round-color-1 { color: #007bff; }
.round-color-2 { color: #28a745; }
.round-color-3 { color: #ffc107; }
.round-color-4 { color: #dc3545; }
.round-color-5 { color: #6f42c1; }

/* Stop List */
.stop-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stop-item {
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: move;
    background: #f8f9fa;
}

.stop-item:hover {
    background: #e9ecef;
}

.stop-item.dragging {
    opacity: 0.5;
}

.stop-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stop-number {
    font-weight: bold;
    margin-right: 10px;
}

.stop-address {
    margin-top: 5px;
    color: #666;
    font-size: 0.9em;
}

.stop-meta {
    margin-top: 5px;
    font-size: 0.85em;
    color: #999;
}

/* Fulfillment */
.fulfill-item {
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.fulfill-item.checked {
    background: #d4edda;
    border-color: #c3e6cb;
}

.fulfill-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.fulfill-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Route Info */
.route-info {
    margin-bottom: 20px;
}

.route-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.stat-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
}

.stat-label {
    font-size: 0.85em;
    color: #666;
}

.stat-value {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

/* Round Selector */
.round-selector {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.round-btn {
    padding: 5px 15px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.round-btn.active {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

/* Directions */
.directions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.direction-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: start;
}

.direction-number {
    font-weight: bold;
    margin-right: 10px;
    min-width: 30px;
}

.direction-content {
    flex: 1;
}

.direction-address {
    font-weight: 500;
}

.direction-meta {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
}

/* Draggable stops */
.draggable-stop {
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.draggable-stop.dragging {
    opacity: 0.5;
    background: #f0f0f0;
}

.direction-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}

.direction-actions .btn {
    padding: 4px 8px;
    font-size: 0.85em;
}

.icon-svg-small {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: middle;
}

.direction-actions .icon-svg-small {
    filter: brightness(0) invert(0);
}

.direction-actions .btn-outline-secondary .icon-svg-small {
    filter: brightness(0) invert(0);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .top-bar {
        flex-direction: row;
        padding: 8px;
        gap: 8px;
        align-items: center;
    }
    
    .search-container {
        flex: 1;
        min-width: 0;
    }
    
    .search-input-wrapper {
        width: 100%;
    }
    
    #search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .search-btn-inline {
        font-size: 16px;
    }
    
    .top-bar-actions {
        display: flex;
        gap: 8px;
        flex-shrink: 0;
    }
    
    #menu-toggle,
    #sidebar-toggle-mobile {
        min-width: 55px;
        min-height: 54px;
        padding: 8px;
        font-size: 16px;
    }
    
    .menu-buttons {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border: 1px solid #ddd;
        border-top: none;
        padding: 8px;
        display: none !important;
        flex-direction: column;
        gap: 8px;
        z-index: 4000 !important;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        margin-top: 8px;
    }
    
    .menu-buttons.show {
        display: flex !important;
    }
    
    /* Ensure Leaflet controls are below menu on mobile */
    .leaflet-control-container {
        z-index: 1000 !important;
    }
    
    .leaflet-top,
    .leaflet-bottom,
    .leaflet-left,
    .leaflet-right {
        z-index: 1000 !important;
    }
    
    .leaflet-control-zoom {
        z-index: 1000 !important;
    }
    
    .menu-buttons .btn {
        width: 100%;
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
        justify-content: flex-start;
    }
    
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        z-index: 2000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .search-container input,
    .search-container .btn {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .top-bar {
        padding: 8px;
    }
    
    .bottom-bar {
        padding: 12px 8px;
        flex-direction: column;
        gap: 8px;
    }
    
    .stop-counter {
        width: 100%;
        text-align: center;
        font-size: 14px;
        padding-bottom: 8px;
        border-bottom: 1px solid #e0e0e0;
        margin-bottom: 4px;
    }
    
    .action-buttons {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        width: 100%;
    }
    
    .action-buttons .btn {
        min-height: 50px;
        padding: 12px 8px;
        font-size: 14px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        touch-action: manipulation;
    }
    
    .action-buttons .btn .btn-icon {
        font-size: 20px;
    }
    
    .action-buttons .btn .btn-text {
        font-size: 11px;
        margin-left: 0;
        line-height: 1.2;
    }
    
    /* Make map full height on mobile */
    .map-panel {
        height: calc(100vh - 200px);
    }
    
    /* Touch-friendly buttons */
    .btn {
        min-height: 44px; /* iOS touch target */
        touch-action: manipulation;
    }
    
    /* Larger touch targets for stops */
    .direction-item {
        padding: 15px;
        min-height: 60px;
    }
    
    .direction-actions .btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Hide close button on mobile, use swipe or back button */
    .sidebar-header .btn-close {
        font-size: 1.5em;
        padding: 10px;
    }
    
    /* Disable drag on mobile for scrolling */
    .draggable-stop {
        touch-action: pan-y; /* Allow vertical scrolling */
    }
    
    .draggable-stop[draggable="true"] {
        touch-action: none; /* Disable drag on mobile */
    }
    
    /* Mobile reorder buttons */
    .direction-actions {
        flex-direction: column;
        gap: 5px;
    }
    
    .move-up-btn,
    .move-down-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Leaflet Customization */
.leaflet-container {
    font-family: inherit;
}

.marker-home {
    background: #28a745;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.marker-stop {
    background: #007bff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Custom numbered markers */
.custom-marker {
    background: transparent !important;
    border: none !important;
}

.custom-marker div {
    text-align: center;
    line-height: 1;
}

/* Loading Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Route Overview */
.route-overview-summary {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.route-overview-round {
    margin-bottom: 25px;
}

.route-overview-round h6 {
    color: #007bff;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 2px solid #007bff;
}

/* Route Overview Stop Cards */
.route-stop-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    transition: box-shadow 0.2s;
}

.route-stop-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.route-stop-number {
    background: linear-gradient(135deg, #000000 0%, #000000 100%);
    color: white;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.route-stop-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.route-stop-icon img {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.route-stop-content {
    min-width: 0;
}

.route-stop-label {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.route-stop-name {
    font-size: 1.25rem;
    font-weight: bold;
    color: #212529;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.route-stop-address {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.route-stop-arrival {
    color: #17a2b8;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.route-stop-arrival strong {
    font-weight: 600;
}

/* Priority Badge Styles */
.priority-badge {
    display: inline-block;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
}

.priority-badge-overview {
    display: inline-block;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
}

/* Custom Dialog Overlays (non-Bootstrap) */
.custom-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999 !important; /* Much higher than Bootstrap modals (1055) */
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    pointer-events: auto;
}

.custom-dialog-overlay * {
    pointer-events: auto;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.custom-dialog {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.custom-dialog-header {
    padding: 20px 20px 15px;
    border-bottom: 1px solid #dee2e6;
}

.custom-dialog-header h5 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.custom-dialog-body {
    padding: 20px;
}

.custom-dialog-body p {
    margin: 0 0 15px 0;
}

.custom-dialog-body .form-control {
    margin-top: 10px;
}

#custom-prompt-input {
    pointer-events: auto !important;
    z-index: 10001 !important;
    position: relative !important;
    background: white !important;
    cursor: text !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

.custom-dialog-overlay {
    pointer-events: auto;
}

.custom-dialog {
    pointer-events: auto;
    z-index: 10000 !important; /* Higher than overlay */
    position: relative;
}

.custom-dialog-footer {
    padding: 15px 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
