/* ============================================================================
   Customer Route Management System - Stylesheet
   Refactored: 2025-11-09
   ============================================================================ */

/* ============================================================================
   1. CSS VARIABLES & ROOT CONFIGURATION
   ============================================================================ */

:root {
    /* Brand Colors - Primary Gradient */
    --primary-600: #667eea;
    --primary-700: #764ba2;
    --primary: #667eea;
    --secondary: #764ba2;
    
    /* Semantic Colors */
    --success: #667eea;
    --danger: #f56565;
    --dark: #2d3748;
    
    /* Neutrals & Backgrounds */
    --bg: #0f1115;
    --card: #151922;
    --muted: #8b93a7;
    --text: #e6e9f2;
    --border: rgba(255, 255, 255, .08);
    --page: #f7faf9;
    
    /* Ink Scale (for light backgrounds) */
    --ink-900: #0F172A;
    --ink-700: #334155;
    --ink-600: #475569;
    --line: rgba(15, 23, 42, .08);
    
    /* Layout */
    --topbar-height: 60px;
    
    /* Brand Shadow */
    --brand-shadow-rgb: 102, 126, 234;
    
    /* Bootstrap Overrides */
    --bs-primary: var(--primary-600);
    --bs-primary-rgb: 102, 126, 234;
    --bs-link-color: var(--primary-600);
    --bs-link-hover-color: var(--primary-700);
    --bs-success: var(--primary-600);
    --bs-success-rgb: 102, 126, 234;
    --bs-focus-ring-color: rgba(102, 126, 234, 0.25);
    --bs-btn-focus-shadow-rgb: var(--brand-shadow-rgb);
    --bs-pagination-focus-box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .25);
}

/* ============================================================================
   2. GLOBAL RESETS & BASE STYLES
   ============================================================================ */

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

html,
body {
    font-family: 'Prompt', sans-serif !important;
    background: var(--bg);
    color: var(--text);
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0;
    margin: 0;
}

*:focus-visible {
    outline-color: var(--primary-600);
}

/* ============================================================================
   3. LAYOUT STRUCTURE
   ============================================================================ */

/* Main Container */
.main-container {
    background: white;
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
}

.container-narrow {
    max-width: 95% !important;
}

/* Map Container */
.map-container {
    height: calc(100vh - var(--topbar-height));
    position: relative;
}

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

#map {
    height: 400px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
}

/* ============================================================================
   4. TOPBAR NAVIGATION
   ============================================================================ */

.topbar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    height: var(--topbar-height);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 24px;
}

.topbar-fixed {
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* Brand Logo */
.topbar .brand {
    color: white;
    font-weight: 700;
    font-size: 1.4rem;
    margin-right: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.topbar .brand:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.topbar .brand i {
    font-size: 1.6rem;
}

/* Navigation Links */
.topbar .nav-links {
    display: flex;
    gap: 8px;
    flex: 1;
    align-items: center;
}

.topbar .nav-link {
    color: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 10px;
    transition: all 0.3s ease;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.topbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-2px);
}

.topbar .nav-link.active {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.topbar .nav-link i {
    font-size: 1.1rem;
}

/* Mobile Toggle Button */
.topbar .mobile-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
    margin-left: auto;
}

.topbar .mobile-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.topbar .mobile-toggle:active {
    transform: scale(0.95);
}

/* ============================================================================
   5. SIDEBAR
   ============================================================================ */

.sidebar {
    background: #f7fafc;
    padding: 20px;
    height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    border-right: 2px solid #e2e8f0;
    transition: transform 0.3s ease-in-out;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #e5e7eb;
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #e5e7eb;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.sidebar hr {
    border-color: #e5e7eb;
    opacity: 0.5;
}

.sidebar .form-label {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar .form-control,
.sidebar .form-select {
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.sidebar .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1019;
}

.sidebar-backdrop.show {
    display: block;
}

/* Mobile Sidebar Toggle */
.mobile-sidebar-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1010;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ============================================================================
   6. CARDS & CONTAINERS
   ============================================================================ */

.card,
.navbar,
.offcanvas,
.dropdown-menu,
.toast,
.popover {
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 .5rem 1rem rgba(var(--brand-shadow-rgb), .12) !important;
}

.modal-content {
    background: #fff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 .5rem 1rem rgba(var(--brand-shadow-rgb), .12) !important;
}

.toolbar,
.table-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.table-card {
    overflow: hidden;
}

/* Customer Card */
.customer-card {
    background: #f7fafc;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.customer-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.customer-card h5 {
    color: var(--primary);
    margin-bottom: 10px;
    font-weight: 700;
}

.customer-card p {
    margin: 5px 0;
    color: #4a5568;
    font-size: 0.9rem;
}

/* Stats Card */
.stats-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.stats-card h3 {
    font-size: 2rem;
    margin: 5px 0;
    font-weight: 700;
}

.stats-card p {
    margin: 0;
    opacity: 0.95;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ============================================================================
   7. BUTTONS
   ============================================================================ */

.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-sm:hover {
    transform: translateY(-1px);
}

/* Brand Buttons */
.btn-brand,
.btn-primary,
.btn-success,
.btn-primary-custom {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border: none;
    color: #fff;
    font-weight: 500;
    padding: 10px 24px;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.btn-brand:hover,
.btn-primary:hover,
.btn-success:hover,
.btn-primary-custom:hover {
    filter: brightness(1.1);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.btn-primary:focus,
.btn-success:focus,
.btn-brand:focus {
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .35);
}

/* Outline Buttons */
.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-outline-success {
    border: 2px solid var(--success);
    color: var(--success);
    font-weight: 600;
}

.btn-outline-success:hover {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-outline-danger:hover {
    transform: translateY(-1px);
}

/* Custom Button Styles */
.btn-custom {
    padding: 12px 30px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
}

.btn-success-custom {
    background: var(--success);
    color: white;
}

.btn-danger-custom {
    background: var(--danger);
    color: white;
}

/* Close Button */
.btn-close {
    width: 1em !important;
    height: 1em !important;
    padding: 0.25em !important;
    background: transparent !important;
    border: none !important;
    opacity: 1 !important;
    position: relative;
}

.btn-close::before,
.btn-close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1em;
    height: 2px;
    background-color: #000;
    transition: background-color 0.2s ease;
}

.btn-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.btn-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.btn-close:hover {
    background-color: rgba(0, 0, 0, 0.08) !important;
    border-radius: 4px;
}

.btn-close:hover::before,
.btn-close:hover::after {
    background-color: #000;
}

/* Close Button White */
.btn-close-white::before,
.btn-close-white::after,
.modal-header.bg-dark .btn-close::before,
.modal-header.bg-dark .btn-close::after,
.modal-header.bg-primary .btn-close::before,
.modal-header.bg-primary .btn-close::after,
.modal-header.bg-brand .btn-close::before,
.modal-header.bg-brand .btn-close::after,
.modal-header.bg-gradient .btn-close::before,
.modal-header.bg-gradient .btn-close::after {
    background-color: #fff !important;
}

.btn-close-white:hover,
.modal-header.bg-dark .btn-close:hover,
.modal-header.bg-primary .btn-close:hover,
.modal-header.bg-brand .btn-close:hover,
.modal-header.bg-gradient .btn-close:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
}

.btn-close-white:hover::before,
.btn-close-white:hover::after,
.modal-header.bg-dark .btn-close:hover::before,
.modal-header.bg-dark .btn-close:hover::after,
.modal-header.bg-primary .btn-close:hover::before,
.modal-header.bg-primary .btn-close:hover::after,
.modal-header.bg-brand .btn-close:hover::before,
.modal-header.bg-brand .btn-close:hover::after,
.modal-header.bg-gradient .btn-close:hover::before,
.modal-header.bg-gradient .btn-close:hover::after {
    background-color: #fff !important;
}

/* ============================================================================
   8. FORMS
   ============================================================================ */

.form-label {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-label.required::after {
    content: " *";
    color: #dc3545;
    font-weight: 700;
}

.form-control,
.form-select {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    transition: all 0.3s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-check-input:checked {
    background-color: var(--primary-600);
    border-color: var(--primary-600);
}

.form-check-input:focus {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .25);
}

/* Input Groups */
.input-group-text {
    background-color: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-right: 0 !important;
    color: var(--ink-600);
}

.input-group .form-control {
    border-left: 0;
    border-radius: 0 10px 10px 0;
}

.input-group:focus-within .input-group-text {
    border-color: var(--primary-600);
    background-color: #f0f9f4;
}

/* Color Input */
input[type="color"].form-control {
    max-width: 75px;
    padding: 0px !important;
    height: 52px;
    border-radius: 10px 0 0 10px;
}

input[type="color"].form-control::-webkit-color-swatch {
    border: none;
    border-radius: 8px 0 0 8px;
}

input[type="color"].form-control::-moz-color-swatch {
    border: none;
    border-radius: 8px 0 0 8px;
}

/* ============================================================================
   9. TABLES
   ============================================================================ */

.table {
    width: 100% !important;
    margin-bottom: 0;
    table-layout: fixed;
}

.table thead th {
    font-weight: 600;
    color: var(--ink-900);
    position: sticky;
    top: 0;
    z-index: 2;
    vertical-align: middle;
    text-align: left;
    white-space: nowrap;
    padding: 16px 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, .08), rgba(118, 75, 162, .08)) !important;
    border-bottom: 2px solid #667eea !important;
}

.table tbody td {
    vertical-align: middle;
    text-align: left;
    padding: 14px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

.table tbody tr:hover {
    background-color: #f8fffe;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.08);
}

.truncate-cell {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* Table Column Widths (Desktop) */
@media (min-width: 993px) {
    .table th:nth-child(1), .table td:nth-child(1) { width: 50px; text-align: center; }
    .table th:nth-child(2), .table td:nth-child(2) { width: 180px; }
    .table th:nth-child(3), .table td:nth-child(3) { width: 250px; }
    .table th:nth-child(4), .table td:nth-child(4) { width: 120px; }
    .table th:nth-child(5), .table td:nth-child(5) { width: 120px; }
    .table th:nth-child(6), .table td:nth-child(6) { width: 130px; }
    .table th:nth-child(7), .table td:nth-child(7) { width: 100px; text-align: center; }
    .table th:nth-child(8), .table td:nth-child(8) { width: 130px; text-align: center; }
}

/* ============================================================================
   10. BADGES
   ============================================================================ */

.badge {
    padding: 6px 14px;
    font-weight: 500;
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.badge-custom {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge.bg-info {
    background-color: #3b82f6 !important;
}

.badge.bg-success,
.badge.text-bg-success {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    background-color: var(--primary-600) !important;
}

/* ============================================================================
   11. PAGINATION
   ============================================================================ */

.pagination {
    gap: 4px;
    --bs-pagination-color: var(--primary-600);
    --bs-pagination-hover-color: var(--primary-700);
    --bs-pagination-focus-color: var(--primary-700);
    --bs-pagination-active-bg: var(--primary-600);
    --bs-pagination-active-border-color: var(--primary-600);
}

.pagination .page-link {
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    min-width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-700);
    font-weight: 500;
    transition: all 0.2s ease;
    background-color: transparent;
}

.pagination .page-link:hover {
    background-image: linear-gradient(135deg, #667eea, #764ba2) !important;
    color: #fff !important;
    border-color: transparent !important;
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .25);
}

.pagination .page-item.active .page-link {
    background-image: linear-gradient(135deg, #667eea, #764ba2) !important;
    border-color: transparent !important;
    color: #fff !important;
}

/* ============================================================================
   12. MODALS
   ============================================================================ */

.modal {
    z-index: 1050;
}

.modal-backdrop {
    z-index: 1040;
}

.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid #e5e7eb;
    padding: 20px 24px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 16px 24px;
}

/* ============================================================================
   13. ROUTES PAGE SPECIFIC
   ============================================================================ */

/* Route Points */
.route-point {
    background: white;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    border: 2px solid #e2e8f0;
    cursor: move;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.route-point:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateX(5px);
}

.route-point .point-number {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

/* Saved Routes */
.saved-route {
    background: white;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.3s ease;
}

.saved-route:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.color-preview {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    display: inline-block;
    margin-right: 12px;
    flex-shrink: 0;
}

/* Nearby Suggestions */
.nearby-suggestion {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    padding: 12px;
    margin: 12px 0;
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.1);
}

.nearby-customer {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    margin: 8px 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nearby-customer:hover {
    border-color: var(--success);
    background: #f0fdf4;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.15);
}

/* Market Analysis */
.market-analysis-panel {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

.filter-chip {
    display: inline-block;
    padding: 6px 14px;
    margin: 4px 2px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e5e7eb;
    background: white;
    font-weight: 500;
    color: #000;
}

.filter-chip:hover {
    border-color: var(--primary);
    background: #f7fafc;
    transform: translateY(-2px);
}

.filter-chip.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Collapsible Sections */
.collapsible-section {
    margin-bottom: 16px;
}

.collapsible-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.collapsible-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.collapsible-header i.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 1.1rem;
}

.collapsible-header.collapsed i.toggle-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    padding: 16px 8px;
    display: none;
    animation: slideDown 0.3s ease;
}

.collapsible-content.show {
    display: block;
}

/* Edit Mode Banner */
.edit-mode-banner {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-weight: 600;
    text-align: center;
    animation: pulse 2s infinite;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

/* Route Summary */
#myRouteSummary {
    max-width: 320px;
}

#myRouteSummary ul.list-unstyled.mb-0 {
    font-size: 0.95rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #f0f0f0;
}

#myRouteSummary ul.list-unstyled.mb-0::-webkit-scrollbar {
    width: 6px;
}

#myRouteSummary ul.list-unstyled.mb-0::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

#myRouteSummary ul.list-unstyled.mb-0::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

#myRouteSummary li.mb-2 {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 12px;
    transition: all 0.2s ease;
}

#myRouteSummary li.mb-2:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

/* ============================================================================
   14. LEAFLET MAP CUSTOMIZATION
   ============================================================================ */

.leaflet-popup-content-wrapper {
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 15px;
    font-family: 'Prompt', sans-serif;
}

.leaflet-routing-container {
    display: none !important;
}

.leaflet-control-route-summary {
    max-width: 320px !important;
}

/* Marker Labels */
.marker-label {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 600;
    color: var(--primary);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    font-size: 13px;
    position: relative;
    height: 32px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

.marker-label::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--primary);
}

.marker-label::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid white;
    z-index: 1;
}

.customer-marker-label {
    background: white;
    border: 2px solid var(--success);
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 600;
    color: var(--success);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    font-size: 13px;
    position: relative;
    transform: translate(-50%, calc(-100% - 12px));
}

.customer-marker-label::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid var(--success);
}

.customer-marker-label::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
    z-index: 1;
}

.route-marker-icon {
    background: var(--primary);
    color: white;
    border: 3px solid white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.customer-info-popup {
    max-width: 300px;
    font-size: 0.95rem;
}

.customer-info-popup h6 {
    color: var(--primary);
    margin-bottom: 10px;
}

.customer-info-popup .badge {
    font-size: 0.75rem;
    padding: 5px 10px;
    margin: 2px;
    font-weight: 500;
}

/* ============================================================================
   15. UTILITY CLASSES
   ============================================================================ */

/* Brand Colors */
.bg-brand,
.bg-gradient {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    color: #fff !important;
}

.text-brand {
    color: var(--primary-600) !important;
}

.text-success {
    color: var(--primary-600) !important;
}

.border-brand {
    border-color: var(--primary-600) !important;
}

.border-success {
    border-color: var(--primary-600) !important;
}

/* Shadows */
.shadow {
    box-shadow: 0 .5rem 1rem rgba(var(--brand-shadow-rgb), .15) !important;
}

.shadow-sm {
    box-shadow: 0 .125rem .25rem rgba(var(--brand-shadow-rgb), .18) !important;
}

.shadow-lg {
    box-shadow: 0 1rem 3rem rgba(var(--brand-shadow-rgb), .2) !important;
}

.shadow-none {
    box-shadow: none !important;
}

.shadow-brand {
    box-shadow: 0 .5rem 1rem rgba(102, 126, 234, .15) !important;
}

.brand-glow {
    box-shadow: 0 8px 24px rgba(102, 126, 234, .25), 0 2px 6px rgba(118, 75, 162, .2);
}

/* Text Utilities */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-title {
    font-weight: 700;
    color: var(--ink-900);
}

.footer-muted {
    color: var(--muted);
}

/* Spacing Utilities */
.mt-safe-5 {
    margin-top: 3rem !important;
}

.pt-safe-3 {
    padding-top: 1rem !important;
}

/* Section Headers */
.section-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-weight: 600;
}

/* Print Utilities */
.no-print {
    display: block;
}

@media print {
    .no-print {
        display: none !important;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.spinner-container {
    text-align: center;
}

.spinner-border-custom {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: var(--primary);
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

.spinner-border.text-success,
.spinner-grow.text-success {
    color: var(--primary-600) !important;
}

/* Search Highlight */
.search-highlight {
    background-color: #fef3c7 !important;
    border: 2px solid #f59e0b !important;
    animation: highlight-pulse 1.5s ease-in-out;
}

/* ============================================================================
   16. ANIMATIONS
   ============================================================================ */

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes highlight-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================================================
   17. FULLSCREEN MODE
   ============================================================================ */

body.fullscreen-mode {
    overflow: hidden;
}

body.fullscreen-mode .topbar,
body.fullscreen-mode .sidebar {
    display: none !important;
}

body.fullscreen-mode .main-container {
    margin-top: 0;
}

body.fullscreen-mode .map-container {
    height: 100vh !important;
}

body.fullscreen-mode .content-area .col-lg-9 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
}

/* ============================================================================
   18. MOBILE SIDEBAR COMPONENT
   ============================================================================ */

body.msb-open {
    overflow: hidden;
}

.msb-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    z-index: 1040;
}

.msb-backdrop.is-show {
    opacity: 1;
    pointer-events: auto;
}

.msb-panel {
    position: fixed;
    inset: 0;
    background: #fff;
    color: #111;
    transform: translateX(100%);
    transition: transform .28s ease;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.msb-panel.is-show {
    transform: translateX(0);
}

.msb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.msb-title {
    font-weight: 600;
    font-size: 1.05rem;
}

.msb-close {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 8px;
    line-height: 1;
    font-size: 1.25rem;
    cursor: pointer;
}

.msb-body {
    padding: 8px 16px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.msb-body .navbar-nav,
.msb-body .site-menu,
.msb-body .main-menu,
.msb-body ul {
    list-style: none;
    padding-left: 0;
    margin: 8px 0;
}

.msb-body a {
    display: block;
    padding: 12px 10px;
    text-decoration: none;
    color: inherit;
    border-radius: 10px;
}

.msb-body a:hover {
    background: #f3f4f6;
}

/* ============================================================================
   19. MOBILE RESPONSIVE STYLES
   ============================================================================ */

/* Tablet & Below (992px) */
@media (max-width: 992px) {
    .topbar {
        padding: 0 16px;
    }

    .topbar .brand {
        font-size: 1.2rem;
        margin-right: 0;
    }

    .topbar .brand i {
        font-size: 1.4rem;
    }

    .topbar .brand span {
        display: inline;
    }

    /* Mobile Navigation Sidebar */
    .topbar .nav-links {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        flex-direction: column;
        gap: 0;
        padding: 24px 20px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        max-height: 100vh;
        overflow-y: auto;
        z-index: 1031;
    }

    .topbar .nav-links.show {
        transform: translateX(0);
        animation: slideInFromLeft 0.3s ease-out;
    }

    .topbar .nav-links::before {
        content: 'เมนู';
        display: block;
        font-size: 1.5rem;
        font-weight: 700;
        color: white;
        margin-bottom: 24px;
        padding-bottom: 20px;
        border-bottom: 2px solid rgba(255, 255, 255, 0.2);
        position: relative;
    }

    .topbar .nav-link {
        width: 100%;
        padding: 18px 20px;
        border-radius: 12px;
        margin-bottom: 12px;
        font-size: 1.15rem;
        font-weight: 500;
    }

    .topbar .nav-link:last-child {
        margin-bottom: 0;
    }

    .topbar .nav-link i {
        font-size: 1.4rem;
        width: 32px;
    }

    .topbar .nav-link::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: translate(-50%, -50%);
        transition: width 0.4s, height 0.4s;
    }

    .topbar .nav-link:active::after {
        width: 300px;
        height: 300px;
    }

    /* Sidebar Close Button */
    .sidebar-close-btn {
        position: fixed;
        top: 8px;
        right: 16px;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        color: white;
        font-size: 2rem;
        cursor: pointer;
        padding: 8px 16px;
        border-radius: 8px;
        transition: all 0.3s ease;
        z-index: 1033;
        width: 48px;
        height: 48px;
        display: none;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .nav-links.show .sidebar-close-btn {
        display: flex;
    }

    .sidebar-close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: rotate(90deg);
    }

    .sidebar-close-btn:active {
        transform: rotate(90deg) scale(0.95);
    }

    .topbar .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1029;
        height: 42px;
        width: 42px;
        padding: 0;
        font-size: 1.6rem;
        line-height: 1;
    }

    body.mobile-menu-open .topbar .mobile-toggle {
        opacity: 0;
        pointer-events: none;
    }

    body.mobile-menu-open {
        overflow: hidden;
    }

    .mobile-nav-overlay {
        display: none;
    }

    /* Scrollbar for Mobile Nav */
    .topbar .nav-links::-webkit-scrollbar {
        width: 6px;
    }

    .topbar .nav-links::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 3px;
    }

    .topbar .nav-links::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }

    /* Sidebar (Routes Page) */
    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        width: 90%;
        max-width: 380px;
        height: calc(100vh - var(--topbar-height));
        z-index: 1020;
        transform: translateX(-100%);
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.2);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1019;
        backdrop-filter: blur(2px);
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .mobile-sidebar-toggle {
        display: flex;
        bottom: 24px;
        left: 24px;
        width: 60px;
        height: 60px;
        font-size: 1.6rem;
    }

    .mobile-sidebar-toggle:hover {
        transform: scale(1.1);
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.5);
    }

    .mobile-sidebar-toggle:active {
        transform: scale(0.95);
    }

    .map-container {
        height: calc(100vh - var(--topbar-height)) !important;
    }

    .msb-backdrop,
    .msb-panel {
        display: none !important;
    }
}

/* Mobile Phones (768px) */
@media (max-width: 768px) {
    #map {
        height: 300px;
    }

    .topbar {
        padding: 0 12px;
    }

    .topbar .brand {
        font-size: 1.1rem;
    }

    .topbar .brand i {
        font-size: 1.3rem;
    }

    .topbar .nav-links {
        padding: 24px 20px;
    }

    .topbar .nav-link {
        font-size: 1.1rem;
        padding: 16px 18px;
    }

    .sidebar-close-btn {
        width: 44px;
        height: 44px;
        font-size: 1.8rem;
        top: 8px;
        right: 12px;
    }

    .toolbar {
        padding: 12px;
    }

    .btn-brand {
        width: 100%;
        padding: 12px 20px;
    }

    .table th,
    .table td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }

    .mobile-sidebar-toggle {
        width: 56px;
        height: 56px;
        bottom: 20px;
        left: 20px;
        font-size: 1.5rem;
    }

    .sidebar {
        width: 85%;
        max-width: 340px;
        padding: 16px;
    }

    .stats-card h3 {
        font-size: 1.75rem;
    }

    .collapsible-header {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
}

/* Small Phones (480px) */
@media (max-width: 480px) {
    .topbar .brand span {
        font-size: 1rem;
    }

    .topbar .mobile-toggle {
        padding: 6px 10px;
        font-size: 1.6rem;
    }

    .topbar .nav-links {
        padding: 20px 16px;
    }

    .topbar .nav-link {
        font-size: 1.05rem;
        padding: 15px 16px;
    }

    .sidebar-close-btn {
        width: 42px;
        height: 42px;
        font-size: 1.6rem;
        top: 6px;
        right: 12px;
    }

    .filter-chip {
        font-size: 0.8rem;
        padding: 5px 10px;
    }

    .market-analysis-panel {
        padding: 12px;
    }

    .route-point {
        padding: 10px;
    }

    .route-point .point-number {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
}

/* Desktop Only (993px+) */
@media (min-width: 993px) {
    .mobile-sidebar-toggle {
        display: none;
    }

    .mobile-nav-overlay {
        display: none !important;
    }

    .sidebar-close-btn {
        display: none !important;
    }
}

/* ============================================================================
   20. MOBILE TABLE STYLES
   ============================================================================ */

.is-mobile .table-bordered>:not(caption)>*>* {
    border-width: var(--bs-border-width) !important;
}

.is-mobile table thead {
    display: none;
}

.is-mobile table tr {
    display: block;
    margin: 0 0 20px;
    border-radius: 16px;
    padding: 0;
    position: relative;
    background: #fff;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.12);
    overflow: hidden;
    border: 2px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
    animation: slideInUp 0.3s ease-out;
}

.is-mobile table tr:hover {
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2) !important;
    transform: translateY(-2px);
    border-color: rgba(102, 126, 234, 0.3);
}

.is-mobile table td {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    text-align: right !important;
    font-size: 0.95rem;
    padding: 12px 18px;
    white-space: normal;
    border: none;
    border-bottom: 1px solid rgba(102, 126, 234, 0.08);
    position: relative;
    gap: 12px;
}

.is-mobile table td:first-child {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    font-weight: 800;
    color: var(--brand-700);
    font-size: 1.2rem;
    text-align: center !important;
    padding: 16px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
    letter-spacing: 0.5px;
    justify-content: center;
}

.is-mobile table td:last-child {
    border-bottom: none;
    padding-bottom: 16px;
}

.is-mobile table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--brand-700);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: block;
    opacity: 0.9;
    flex-shrink: 0;
    text-align: left;
    min-width: 120px;
}

.is-mobile table td:first-child::before {
    display: none;
}

.is-mobile .table-card {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* === FIX ลำดับ: เอาสไตล์เดิมที่ทำให้มองไม่เห็นออก และให้ข้อความเป็นสีดำ === */
.is-mobile table td[data-label="ลำดับ"] {
  /* ล้างผลจากกฎเดิมที่ใช้ flex/justify ฯลฯ */
  display: block;
  align-items: initial;
  justify-content: initial;
  text-align: left !important;

  background: transparent;
  color: #000;              /* ต้องการแค่ "สีดำ" */
  font-size: inherit;       /* ให้ขนาดเท่า td อื่น ๆ */
  font-weight: inherit;
  padding: 10px 14px;       /* คง padding ตามมือถือ */
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.is-mobile table td[data-label="ลำดับ"]::before {
  /* ป้าย data-label (ข้อความ "ลำดับ") */
  color: #000;              /* สีดำเช่นกัน */
  /* ขนาดตัวหนังสือของ data-label ปรับตรงนี้ → font-size */
  /* ตัวอย่าง: font-size: 0.8rem;  (ถ้าอยากเท่าข้อความหลักให้ใช้ inherit) */
  font-size: inherit;
  font-weight: 700;
  letter-spacing: .4px;
  min-width: 110px;
}

/* === ปุ่มบนมือถือให้เล็กลง และ width:100% === */
@media (max-width: 576px) {
  /* ให้ปุ่มหลัก / ขอบน้ำเงิน / ขอบแดง กว้างเต็มเสมอ */
  .is-mobile .btn.btn-primary,
  .is-mobile .btn.btn-outline-primary,
  .is-mobile .btn.btn-outline-danger {
    width: 100%;
    display: block;
  }

  /* ปรับขนาดแนว btn-sm ให้เล็กลงแต่ยังแตะง่าย */
  .is-mobile .btn.btn-sm {
    padding: .38rem .6rem;  /* เล็กลงจากปกติ */
    font-size: .875rem;     /* ตัวเล็กลงนิดหน่อย */
    line-height: 1.2;
    min-height: 38px;       /* ยังแตะง่ายบนจอสัมผัส */
  }

  /* ถ้าอยู่ใน .btn-group ให้มีช่องว่างเล็ก ๆ ระหว่างปุ่ม */
  .is-mobile .btn-group > .btn {
    margin-bottom: 8px;
  }
}

/* === ตกแต่งคอลัมน์ "ตำแหน่ง GPS" และ "จัดการ" ให้ดูมี UI มากขึ้น === */
.is-mobile table td[data-label="ตำแหน่ง GPS"],
.is-mobile table td[data-label="จัดการ"] {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center !important;

  padding: 12px 14px;
  gap: 10px;

  background:
    linear-gradient(to bottom, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0.02));
  border: 1px solid rgba(99, 102, 241, 0.10);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

/* ทำหัวข้อ data-label ให้เป็นเหมือน badge เล็ก ๆ */
.is-mobile table td[data-label="ตำแหน่ง GPS"]::before,
.is-mobile table td[data-label="จัดการ"]::before {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: #eef2ff;          /* โทนอ่อน */
  color: #1f2937;               /* ข้อความเข้ม */
  font-weight: 700;
  font-size: .80rem;            /* อยากปรับก็แก้ค่าตรงนี้ */
}

/* กลุ่มปุ่ม/คอนโทรลให้ไปชิดล่าง และคงดูเป็นระเบียบ */
.is-mobile table td[data-label="ตำแหน่ง GPS"] .actions,
.is-mobile table td[data-label="จัดการ"] .actions,
.is-mobile table td[data-label="ตำแหน่ง GPS"] .controls,
.is-mobile table td[data-label="จัดการ"] .controls {
  margin-top: auto;
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ปรับ label ของทุกคอลัมน์ในตารางมือถือ */
.is-mobile table td::before {
  font-size: 0.9rem;              /* ใส่ค่าที่ต้องการ เช่น 0.85rem / 14px */
}

/* ปรับสีข้อความคอลัมน์ ลำดับ ให้เป็นสีดำ ทั้งข้อความหลักและ label */
.is-mobile table td[data-label="ลำดับ"],
.is-mobile table td[data-label="ลำดับ"]::before {
    color: #000 !important;
}

/* มือถือ: จัดกึ่งกลาง และดันปุ่มไว้ล่างในคอลัมน์ ตำแหน่ง GPS / จัดการ */
.is-mobile table td[data-label="ตำแหน่ง GPS"],
.is-mobile table td[data-label="จัดการ"] {
    display: flex;                  /* ทำให้ภายในจัดวางแนวตั้งได้ */
    flex-direction: column;
    align-items: center;             /* จัดกึ่งกลางแนวนอน */
    justify-content: flex-start;     /* เนื้อหาปกติอยู่ด้านบน */
    text-align: center !important;
    min-height: 140px;               /* ความสูงพอให้มี "ด้านล่าง" สำหรับปุ่ม */
    border-top: 2px solid rgba(102, 126, 234, 0.15);
    padding: 16px 18px;
    background: linear-gradient(to bottom, rgba(102, 126, 234, 0.03), transparent);
}

/* label ::before ให้เป็นบล็อกและมีช่องไฟด้านล่าง */
.is-mobile table td[data-label="ตำแหน่ง GPS"]::before,
.is-mobile table td[data-label="จัดการ"]::before {
    display: block;
    text-align: center !important;
    margin-bottom: 12px;
}

/* ดันปุ่ม/แอ็คชันลงไปด้านล่างของเซลล์ */
.is-mobile table td[data-label="ตำแหน่ง GPS"] .btn,
.is-mobile table td[data-label="ตำแหน่ง GPS"] button,
.is-mobile table td[data-label="ตำแหน่ง GPS"] .btn-group,
.is-mobile table td[data-label="จัดการ"] .btn,
.is-mobile table td[data-label="จัดการ"] button,
.is-mobile table td[data-label="จัดการ"] .btn-group {
    margin-top: auto;                /* ดันองค์ประกอบนี้ไปชิดด้านล่าง */
    width: 100%;                     /* (ตัวเลือก) ให้ปุ่มเต็มความกว้างในมือถือ */
}

/* ถ้ามี wrapper สำหรับปุ่ม เช่น .actions/.controls จะยิ่งเป๊ะ */
.is-mobile table td[data-label="ตำแหน่ง GPS"] .actions,
.is-mobile table td[data-label="จัดการ"] .actions,
.is-mobile table td[data-label="ตำแหน่ง GPS"] .controls,
.is-mobile table td[data-label="จัดการ"] .controls {
    margin-top: auto;                /* ดันทั้งกลุ่มปุ่มลงล่าง */
    width: 100%;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.is-mobile .truncate-cell {
    white-space: normal;
    word-break: break-word;
    line-height: 1.5;
}

.is-mobile .badge {
    display: inline-block;
    margin-top: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 24px;
    font-weight: 600;
}

.is-mobile .btn-group {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: nowrap;
    width: 100%;
}

.is-mobile .btn-group .btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 48px;
}

.is-mobile .btn-group .btn i {
    font-size: 1rem;
}

.is-mobile .btn-group .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.is-mobile .btn-group .btn-outline-primary,
.is-mobile .btn-group .btn-outline-danger {
    border-width: 2px !important;
    font-weight: 600 !important;
}

.is-mobile .btn-group .btn-outline-primary::after {
    content: " แก้ไข";
    margin-left: 4px;
}

.is-mobile .btn-group .btn-outline-danger::after {
    content: " ลบข้อมูล";
    margin-left: 4px;
}

/* Fix Button Border Radius in Mobile */
body.is-mobile .btn-group > .btn-group:not(:last-child) > .btn,
body.is-mobile .btn-group > .btn.dropdown-toggle-split:first-child,
body.is-mobile .btn-group > .btn:not(:last-child):not(.dropdown-toggle) {
    border-top-right-radius: 10px !important;
    border-bottom-right-radius: 10px !important;
}

body.is-mobile .btn-group > .btn-group:not(:first-child) > .btn,
body.is-mobile .btn-group > .btn:nth-child(n+2) {
    border-top-left-radius: 10px !important;
    border-bottom-left-radius: 10px !important;
}

.is-mobile table td[data-label="เบอร์ติดต่อ"] i {
    margin-right: 6px;
    color: var(--brand-600);
}

.is-mobile table td[data-label="ชื่อลูกค้า"] {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--ink-900);
}

.is-mobile table td[data-label="ที่อยู่"] {
    color: var(--ink-700);
    line-height: 1.6;
}

.is-mobile table td[data-label="กลุ่มความต้องการ"],
.is-mobile table td[data-label="สินค้า"] {
    color: var(--ink-600);
}

.is-mobile .table-responsive {
    padding: 8px;
}

.is-mobile .container-fluid {
    padding: 12px !important;
}

.is-mobile .toolbar {
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.15);
}

.is-mobile .toolbar .row {
    gap: 12px;
}

.is-mobile .form-select,
.is-mobile .form-control {
    border-radius: 10px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    padding: 12px 14px;
    font-size: 0.95rem;
}

.is-mobile .form-select:focus,
.is-mobile .form-control:focus {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.is-mobile .input-group-text {
    background: white;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-right: none;
    color: var(--brand-600);
}

.is-mobile #summaryRow {
    background: white;
    border-radius: 12px;
    padding: 16px !important;
    margin: 16px 8px;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.15);
}

.is-mobile #summaryText {
    font-size: 0.9rem;
    color: var(--ink-700);
    font-weight: 500;
}

.is-mobile .pagination {
    flex-wrap: wrap;
    gap: 6px;
}

.is-mobile .pagination .page-link {
    border-radius: 10px;
    min-width: 44px;
    height: 44px;
    font-weight: 600;
    border: 2px solid rgba(102, 126, 234, 0.2);
}

.is-mobile .pagination .page-item.active .page-link {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.is-mobile .btn {
    border-radius: 10px;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.95rem;
}

.is-mobile .btn-brand {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.is-mobile .page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px !important;
}

/* ============================================================================
   21. PRINT STYLES
   ============================================================================ */

@media print {
    .no-print,
    .sidebar,
    .mobile-sidebar-toggle,
    .leaflet-control-container {
        display: none !important;
    }

    .table-card {
        border: none;
    }

    .map-container {
        height: 100vh !important;
    }
}

/* ============================================================================
   22. BOOTSTRAP COMPONENT OVERRIDES
   ============================================================================ */

/* Links */
a {
    color: var(--primary-600);
}

a:hover {
    color: var(--primary-700);
}

.link-success {
    color: var(--primary-600) !important;
}

.link-success:hover {
    color: var(--primary-700) !important;
}

/* Alerts */
.alert-success {
    --bs-alert-bg: rgba(102, 126, 234, .12);
    --bs-alert-border-color: rgba(102, 126, 234, .35);
    --bs-alert-color: #dfe4ff;
    color: var(--text);
    border-color: var(--bs-alert-border-color) !important;
    background-color: var(--bs-alert-bg) !important;
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border-color: transparent !important;
    color: #fff !important;
}

/* Nav Components */
.nav-pills .nav-link.active,
.nav-pills .show>.nav-link {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    background-color: var(--primary-600);
    color: #fff;
}

.nav-tabs .nav-link.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
}

/* List Groups */
.list-group-item.active {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border-color: transparent;
}

/* Dropdowns */
.dropdown-item.active,
.dropdown-item:active {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    background-color: var(--primary-600);
    color: #fff;
}

/* Progress Bars */
.progress,
.progress-bar {
    background-color: rgba(102, 126, 234, .1);
}

.progress-bar.bg-success,
.progress .bg-success {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700)) !important;
}

.progress-bar {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
}

/* Form Validation */
.was-validated .form-control:valid,
.form-control.is-valid,
.was-validated .form-select:valid,
.form-select.is-valid {
    border-color: var(--primary-600);
    background-image: none;
}

.was-validated .form-control:valid:focus,
.form-control.is-valid:focus,
.was-validated .form-select:valid:focus,
.form-select.is-valid:focus {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .25);
}

/* Form Range */
.form-range::-webkit-slider-thumb {
    background-color: var(--primary-600);
}

.form-range::-moz-range-thumb {
    background-color: var(--primary-600);
}

.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .25);
}

/* Tables */
.table thead th,
.table> :not(caption)>*>th {
    background-color: rgba(102, 126, 234, .06);
    border-bottom: 2px solid rgba(102, 126, 234, .35);
}

.table-dark thead th,
.table-dark> :not(caption)>*>th {
    background-color: rgba(102, 126, 234, .12);
    border-bottom-color: rgba(102, 126, 234, .45);
}

.table,
.table> :not(caption)>*>th,
.table> :not(caption)>*>td {
    border-color: rgba(102, 126, 234, .18);
}

.table-success,
.table> :not(caption)>*>.table-success {
    --bs-table-bg: rgba(102, 126, 234, .08);
    --bs-table-striped-bg: rgba(102, 126, 234, .12);
    --bs-table-striped-color: var(--text);
    --bs-table-active-bg: rgba(102, 126, 234, .16);
    --bs-table-hover-bg: rgba(102, 126, 234, .12);
    color: var(--text);
    background-color: var(--bs-table-bg) !important;
    color: var(--text) !important;
}

.table-hover tbody tr.table-success:hover {
    --bs-table-bg: rgba(102, 126, 234, .12);
    --bs-table-striped-bg: rgba(102, 126, 234, .18);
    --bs-table-hover-bg: rgba(102, 126, 234, .22);
    --bs-table-color: var(--text);
    background-color: var(--bs-table-bg) !important;
    color: var(--text) !important;
}

tr.selected,
.table .selected {
    background-color: rgba(102, 126, 234, .18) !important;
}

/* Toasts */
.toast .bg-success,
.toast .text-bg-success {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700)) !important;
}

.toast .btn-close:focus {
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .25);
}

/* Background Utilities */
.bg-success {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700)) !important;
    color: #fff !important;
}

/* Button States */
.btn-check:focus+.btn-success,
.btn-check:active+.btn-success,
.btn-check:checked+.btn-success,
.btn-success:active,
.show>.btn-success.dropdown-toggle {
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border-color: transparent;
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .35);
}

.btn-outline-success {
    --bs-btn-color: var(--primary-600);
    --bs-btn-border-color: var(--primary-600);
    --bs-btn-hover-bg: var(--primary-600);
    --bs-btn-hover-border-color: var(--primary-600);
    --bs-btn-active-bg: var(--primary-600);
    --bs-btn-active-border-color: var(--primary-600);
    --bs-btn-disabled-color: var(--primary-600);
    --bs-btn-disabled-border-color: var(--primary-600);
    color: var(--primary-600);
    border-color: var(--primary-600);
}

.btn-outline-success:hover,
.btn-outline-success:active {
    color: #fff;
    background-image: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    border-color: transparent;
}

/* Input Group Focus States */
.input-group .form-control:focus+.input-group-text,
.input-group .form-select:focus+.input-group-text,
.input-group .input-group-text:has(+ .form-control:focus),
.input-group .input-group-text:has(+ .form-select:focus) {
    border-color: var(--primary-600);
    box-shadow: 0 0 0 .25rem rgba(102, 126, 234, .25);
}

/* Style Elements with Inline Brand Colors */
*[style*="#667eea"],
*[style*="#667eea"] {
    box-shadow: 0 .5rem 1rem rgba(var(--brand-shadow-rgb), .15) !important;
    border-color: rgba(102, 126, 234, .35) !important;
}

/* ============================================================================
   23. FINAL TOUCHUPS & EDGE CASES
   ============================================================================ */

strong {
    color: var(--dark);
}

.route-point strong,
.nearby-customer strong,
.saved-route strong {
    color: var(--dark);
}

.nearby-customer small {
    color: var(--success);
    font-weight: 600;
}

.saved-route small {
    color: #6b7280;
    font-size: 0.85rem;
}

#myRouteSummary .text-muted {
    font-size: 0.88rem;
}

.input-group .form-control:not(:first-child) {
    margin-left: -2px;
}

/* ============================================================================
   END OF STYLESHEET
   ============================================================================ */

/* ============ PATCH: ลำดับ, GPS/จัดการ, ระยะห่างมือถือ ============ */

/* 1) ให้คอลัมน์ ลำดับ แสดงเหมือน td อื่น ๆ (ไม่ใช้สไตล์พิเศษของ :first-child) */
.is-mobile table td[data-label="ลำดับ"] {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;   /* ให้จัดวางเหมือนคอลัมน์ปกติ */
  text-align: right !important;
  background: transparent;          /* ล้างกราเดียนต์ของกฎ td:first-child เดิม */
  font-weight: 500;
  font-size: 0.95rem;               /* เท่ากับ td อื่น ๆ */
  padding: 10px 14px;               /* กระชับกว่าเดิมเล็กน้อย */
  border-bottom: 1px solid rgba(102, 126, 234, 0.08);
}

/* ถ้า ลำดับ ดันอยู่เป็นคอลัมน์แรก ให้บังคับล้างสไตล์พิเศษเดิมทับอีกชั้น */
.is-mobile table td[data-label="ลำดับ"]:first-child {
  background: transparent;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(102, 126, 234, 0.08);
  justify-content: space-between;
}

/* label ข้างหน้า (data-label) ให้ขนาดมาตรฐานเดียวกับคอลัมน์อื่น */
.is-mobile table td[data-label="ลำดับ"]::before,
.is-mobile table td[data-label="ลำดับ"]:first-child::before {
  display: block;
  text-align: left;
  font-size: 0.8rem;               /* คงไว้ตามสไตล์รวมของตารางมือถือ */
  font-weight: 700;
  letter-spacing: 0.8px;
  min-width: 120px;
  opacity: 0.9;
}

/* 2) ปรับคอลัมน์ ตำแหน่ง GPS / จัดการ ให้สวยขึ้นและคง layout ปุ่มไว้ล่าง */
.is-mobile table td[data-label="ตำแหน่ง GPS"],
.is-mobile table td[data-label="จัดการ"] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;       /* เนื้อหาทั่วไปอยู่ด้านบน */
  text-align: center !important;
  gap: 8px;                          /* ช่องไฟภายในลดลง */
  min-height: 120px;                 /* เตี้ยลงจากเดิมเพื่อประหยัดพื้นที่ */
  padding: 12px 14px;
  background: linear-gradient(to bottom, rgba(102,126,234,0.025), transparent);
  border-top: 1px dashed rgba(102,126,234,0.18);
  border-radius: 12px;               /* มุมมนเล็กน้อยให้ดูเป็นการ์ด */
}

/* title ของเซลล์ให้เป็นบล็อกเล็กน้อยและมีช่องไฟ */
.is-mobile table td[data-label="ตำแหน่ง GPS"]::before,
.is-mobile table td[data-label="จัดการ"]::before {
  display: block;
  margin-bottom: 8px;                /* ลดลงจาก 12px */
  text-align: center !important;
}

/* กลุ่มปุ่มให้ชิดล่างเสมอ และจัดกลาง */
.is-mobile table td[data-label="ตำแหน่ง GPS"] .actions,
.is-mobile table td[data-label="จัดการ"] .actions,
.is-mobile table td[data-label="ตำแหน่ง GPS"] .controls,
.is-mobile table td[data-label="จัดการ"] .controls {
  margin-top: auto;                  /* ดันลงล่าง */
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* โทนเสริมให้ badge/ข้อความเล็ก ๆ ในคอลัมน์นี้ดูอ่านง่ายขึ้น */
.is-mobile table td[data-label="ตำแหน่ง GPS"] .badge,
.is-mobile table td[data-label="จัดการ"] .badge {
  margin-top: 4px;
  font-size: 0.82rem;
}

/* 3) ลดช่องไฟของ td บนมือถือให้กะทัดรัดขึ้นทั้งตาราง */
.is-mobile table tr {
  margin: 0 0 14px;                  /* เดิม 20px */
}

.is-mobile table td {
  padding: 10px 14px;                /* เดิม 12px 18px */
  gap: 10px;                         /* ลดช่องไฟองค์ประกอบภายใน */
}

/* ยิ่งเล็ก (<=480px) ลดเพิ่มอีกเล็กน้อย */
@media (max-width: 480px) {
  .is-mobile table tr {
    margin-bottom: 12px;
  }
  .is-mobile table td {
    padding: 8px 12px;
    gap: 8px;
  }
  .is-mobile table td::before {
    min-width: 92px;                 /* label สั้นลงเพื่อประหยัดที่ */
    font-size: 0.78rem;
  }
  .is-mobile .btn-group .btn {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.9rem;
  }
}
/* ============ END PATCH ============ */


/* ========================
   HOTFIX 2025-11-09
   - Fix visibility/color for data-label="ลำดับ"
   - Mobile buttons: smaller + full width
   - Mild UI for ตำแหน่ง GPS / จัดการ
   ======================== */

/* 1) ลำดับ: ให้ข้อความ (ทั้ง label และค่า) เป็น "สีดำ" และไม่ถูกกฎอื่นทับ */
.is-mobile table td[data-label="ลำดับ"],
.is-mobile table td[data-label="ลำดับ"] * {
  color: #000 !important;
}
.is-mobile table td[data-label="ลำดับ"]::before {
  color: #000 !important;
  /* ขนาดตัวหนังสือของ label (data-label) ปรับตรงนี้ */
  /* ตัวอย่าง: font-size: 0.8rem; */
  font-size: inherit;
  font-weight: 700;
}

/* 2) ปรับขนาดตัวหนังสือของ label (data-label) ทั้งตารางมือถือได้ที่นี่ */
.is-mobile table td::before {
  /* ค่าเริ่มต้นที่อ่านง่ายบนมือถือ */
  font-size: 0.85rem;
}

/* 3) ปุ่มบนมือถือให้เล็กลงและกว้าง 100% */
@media (max-width: 576px) {
  .is-mobile .btn.btn-primary,
  .is-mobile .btn.btn-outline-primary,
  .is-mobile .btn.btn-outline-danger {
    width: 100% !important;
    display: block;
    padding: .45rem .7rem !important;
    font-size: .92rem !important;
    line-height: 1.25;
    min-height: 40px;
  }
  .is-mobile .btn.btn-sm {
    padding: .35rem .55rem !important;
    font-size: .86rem !important;
    min-height: 36px;
  }
  /* เผื่อใช้ใน .btn-group */
  .is-mobile .btn-group > .btn {
    width: 100%;
    margin-bottom: 8px;
  }
}

/* 4) ตกแต่งเซลล์ "ตำแหน่ง GPS" และ "จัดการ" แบบเรียบ ไม่ชนกับของเดิม */
.is-mobile table td[data-label="ตำแหน่ง GPS"],
.is-mobile table td[data-label="จัดการ"] {
  background: linear-gradient(to bottom, rgba(102,126,234,.05), rgba(102,126,234,.02));
  border: 1px solid rgba(102,126,234,.12);
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(15,23,42,.06);
  padding: 12px 14px;
}

.is-mobile table td[data-label="ตำแหน่ง GPS"]::before,
.is-mobile table td[data-label="จัดการ"]::before {
  display: inline-block;
  background: #eef2ff;
  color: #111;
  padding: 4px 10px;
  border-radius: 9999px;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 0.8rem;
}
/* ====================== END HOTFIX ====================== */


/* ========================
   HOTFIX 2025-11-09 B: Stronger mobile button override
   Target: .btn-primary/.btn-outline-primary/.btn-outline-danger (incl. .btn-sm)
   Make smaller + full width on narrow screens.
   ======================== */
@media (max-width: 576px) {
  /* Full width + block on mobile, even inside groups */
  .btn.btn-primary,
  .btn.btn-outline-primary,
  .btn.btn-outline-danger,
  .btn-group > .btn.btn-primary,
  .btn-group > .btn.btn-outline-primary,
  .btn-group > .btn.btn-outline-danger {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }

  /* Small size defaults for any of these buttons */
  .btn.btn-primary,
  .btn.btn-outline-primary,
  .btn.btn-outline-danger {
    /* Use Bootstrap variable overrides so padding from .btn picks them up */
    --bs-btn-padding-y: 0.48rem;
    --bs-btn-padding-x: 0.8rem;
    --bs-btn-font-size: 0.94rem;
    --bs-btn-border-radius: 0.7rem;
    line-height: 1.25;
    min-height: 40px;
  }

  /* Extra small when .btn-sm is present */
  .btn.btn-sm,
  .btn.btn-primary.btn-sm,
  .btn.btn-outline-primary.btn-sm,
  .btn.btn-outline-danger.btn-sm {
    --bs-btn-padding-y: 0.34rem;
    --bs-btn-padding-x: 0.6rem;
    --bs-btn-font-size: 0.86rem;
    --bs-btn-border-radius: 0.6rem;
    min-height: 36px;
  }

  /* Tighten icon spacing */
  .btn .bi,
  .btn i { margin-right: .35rem; }
}

/* If your mobile layout is inside .is-mobile, keep this too for safety */
@media (max-width: 576px) {
  .is-mobile .btn,
  .is-mobile .btn-group > .btn {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
  }
}
/* ===== END HOTFIX B ===== */
