/* MetroTrak - Premium Professional Design with Rich Colors */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --sidebar-bg-start: #0f172a;
    --sidebar-bg-end: #1e293b;
    --sidebar-text: #e5e7eb;
    --sidebar-border: #334155;
    --content-bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --bg-light: #f1f5f9;
    --sidebar-width: 280px;
    --accent-blue: #2563eb;
    --accent-emerald: #10b981;
    --accent-purple: #a855f7;
    --accent-amber: #f59e0b;
    --accent-indigo: #6366f1;
}

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

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, var(--content-bg) 0%, var(--bg-light) 100%);
    color: var(--text-dark);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Login Screen */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #2d3e50 100%);
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 48px;
    width: 480px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.4s ease;
}

.login-box img {
    width: 440px !important;
    margin-bottom: 24px !important;
}

.login-box h1 {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-dark);
    letter-spacing: -0.8px;
}

.login-box h1 span {
    color: var(--primary);
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-box .subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 15px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8fafc;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s ease;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-dark);
}

.btn-outline:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.top-bar {
    display: none;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg-start) 0%, var(--sidebar-bg-end) 100%);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid transparent;
    gap: 14px;
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 4px 0;
    border-radius: 0 8px 8px 0;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    border-left-color: var(--primary);
    font-weight: 700;
    box-shadow: inset 0 0 12px rgba(37, 99, 235, 0.1);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-label {
    flex: 1;
}

.nav-badge {
    background: var(--danger);
    color: white;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 800;
    animation: pulse 2s ease-in-out infinite;
    min-width: 24px;
    text-align: center;
}

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

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Content Area */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: linear-gradient(135deg, var(--content-bg) 0%, var(--bg-light) 100%);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.content-header h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.5px;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
    animation: fadeIn 0.4s ease;
}

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

/* Maps */
.map-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
}

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

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
}

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

.card-title {
    font-weight: 800;
    font-size: 16px;
    color: var(--text-dark);
}

.card-body {
    font-size: 14px;
    color: var(--text-muted);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 28px 24px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.1), transparent);
    border-radius: 50%;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.2);
}

.stat-card .stat-value {
    font-size: 40px;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    position: relative;
    z-index: 1;
}

/* Zone/Client/Lienholder Cards */
.zone-card,
.client-card,
.lienholder-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 5px solid var(--accent-blue);
}

.zone-card {
    border-left-color: var(--accent-amber);
}

.client-card {
    border-left-color: var(--accent-emerald);
}

.lienholder-card {
    border-left-color: var(--accent-purple);
}

.zone-card:hover,
.client-card:hover,
.lienholder-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: rgba(0, 0, 0, 0.1);
}

.zone-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
}

.zone-card-title {
    font-weight: 800;
    font-size: 17px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.zone-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.zone-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 20px;
    font-size: 12px;
    border-top: 1px solid var(--border);
}

.zone-stat {
    text-align: center;
}

.zone-stat-value {
    font-weight: 900;
    color: var(--text-dark);
    font-size: 24px;
}

.zone-stat-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 4px;
}

/* Order Lists */
.order-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--success);
}

.order-item:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    border-color: var(--primary);
}

.order-item.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(37, 99, 235, 0.04) 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

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

.order-debtor-name {
    font-weight: 800;
    font-size: 15px;
    color: var(--text-dark);
}

.order-vin {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 700;
    font-size: 11px;
    color: #000;
    background: #f1f5f9;
    padding: 3px 6px;
    border-radius: 4px;
}

.order-plate {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.order-date {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.order-client {
    font-size: 11px;
    color: var(--primary);
    font-weight: 700;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.status-open {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.status-on_hold {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.status-closed {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #7f1d1d;
}

.status-pending_acceptance {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #0c2d6b;
}

.status-declined {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #374151;
}

/* Detail Panel */
.detail-panel {
    position: absolute;
    top: 0;
    left: -100%;
    width: min(580px, 100%);
    height: 100%;
    background: white;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel.open {
    left: 0;
}

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.detail-header h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-dark);
}

.detail-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 28px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-close-btn:hover {
    color: var(--danger);
    transform: rotate(90deg);
}

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

.detail-section {
    margin-bottom: 24px;
}

.detail-section-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.6px;
}

.detail-field {
    margin-bottom: 12px;
}

.detail-field-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.detail-field-value {
    font-size: 14px;
    color: var(--text-dark);
    word-break: break-word;
    font-weight: 500;
    margin-top: 4px;
}

.detail-field-value.vin {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 700;
    background: #f1f5f9;
    padding: 6px 8px;
    border-radius: 6px;
}

/* Hidden sections (admin only) */
.hidden-section {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid #fca5a5;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

.hidden-section-warning {
    font-size: 12px;
    color: #991b1b;
    font-weight: 800;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Update Form */
.update-form {
    border-top: 1px solid var(--border);
    padding: 20px;
    flex-shrink: 0;
}

.update-form textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    min-height: 100px;
    margin-bottom: 12px;
    font-family: inherit;
    transition: all 0.2s ease;
}

.update-form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.update-form select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.update-form select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.update-buttons {
    display: flex;
    gap: 10px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(4px);
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 32px;
    width: 540px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal h2 {
    margin-bottom: 20px;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-dark);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    padding: 16px 20px;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 420px;
    pointer-events: auto;
}

.toast-info {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.toast-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.toast-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
}

.toast-error {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

@keyframes slideInRight {
    from {
        transform: translateX(120%) rotate(5deg);
        opacity: 0;
    }
    to {
        transform: translateX(0) rotate(0);
        opacity: 1;
    }
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 800;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.data-table tr:hover td {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(37, 99, 235, 0.02) 100%);
}

/* Leaflet Overrides */
.leaflet-popup-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    min-width: 220px;
}

.leaflet-popup-close-button {
    color: var(--text-muted);
    font-size: 24px;
}

.popup-title {
    font-weight: 800;
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--text-dark);
}

.popup-vehicle {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.popup-address {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-dark);
    font-weight: 500;
}

.popup-client {
    color: var(--primary);
    font-size: 12px;
    margin-top: 6px;
    font-weight: 700;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        width: 280px;
        height: 100%;
        z-index: 500;
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .main-content {
        flex-direction: column;
    }

    .map-container {
        height: 60%;
    }

    .detail-panel {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal {
        width: 95vw;
    }

    .login-box {
        width: 95vw;
        padding: 32px;
    }

    .login-box img {
        width: 280px !important;
    }
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Loading skeleton */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* GPU acceleration hints */
.btn,
.nav-item,
.card,
.order-item,
.detail-panel,
.toast {
    will-change: transform, box-shadow;
}

/* ============================================================
   ORDER MODAL OVERLAY (Map-centric full-featured order view)
   ============================================================ */
.order-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.order-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}
.order-modal {
    background: white;
    border-radius: 14px;
    width: 860px;
    height: 700px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(0,0,0,0.35);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
    overflow: hidden;
    position: relative;
}
@media (max-width: 900px) { .order-modal { width: 96vw; } }
@media (max-height: 740px) { .order-modal { height: 96vh; } }
.order-modal-overlay.active .order-modal {
    transform: translateY(0) scale(1);
}

/* Close X button */
.order-modal-close {
    position: absolute;
    top: 8px; right: 8px;
    width: 28px; height: 28px;
    border: none;
    background: rgba(255,255,255,0.85);
    color: #475569;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.order-modal-close:hover {
    background: white;
    color: #ef4444;
    transform: scale(1.1);
}

/* ── TEMPLATE HEADER (persistent across all tabs) ── */
.modal-template {
    display: flex;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    min-height: 210px;
}

/* Road background - SVG rendered behind everything */
.modal-template::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        /* Road curve on right side */
        radial-gradient(ellipse 180px 600px at 92% 120%, #6b7280 0%, #6b7280 32%, #9ca3af 32.5%, #9ca3af 33.5%, transparent 34%) no-repeat,
        /* Yellow center line */
        radial-gradient(ellipse 170px 580px at 92% 120%, transparent 0%, transparent 30%, #eab308 30.5%, #eab308 31.5%, transparent 32%) no-repeat,
        /* White edge line outer */
        radial-gradient(ellipse 192px 620px at 92% 120%, transparent 0%, transparent 31.5%, rgba(255,255,255,0.7) 31.8%, rgba(255,255,255,0.7) 32.3%, transparent 32.6%) no-repeat,
        /* Base gradient */
        linear-gradient(145deg, #f1f5f9 0%, #e2e8f0 50%, #cbd5e1 100%);
    z-index: 0;
}

.modal-template-info {
    flex: 1;
    padding: 16px 20px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}
.modal-template-vehicle {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}
.modal-template-vehicle img {
    width: 340px;
    height: auto;
    filter: drop-shadow(2px 8px 16px rgba(0,0,0,0.25));
    /* Aggressively crop whitespace: top 15%, bottom 12% */
    clip-path: inset(15% 0% 10% 0%);
    transform: scale(1.35);
    transform-origin: center 55%;
    margin-bottom: -10px;
    position: relative;
    z-index: 2;
}
.modal-vehicle-label {
    font-weight: 800;
    font-size: 13px;
    color: #1e293b;
    text-align: center;
    padding: 6px 0 2px;
    z-index: 3;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.modal-towing-alert {
    width: 90%;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-align: left;
    z-index: 3;
    margin-bottom: 6px;
    backdrop-filter: blur(4px);
}

/* Template info rows */
.tpl-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}
.tpl-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    /* No background - icons sit directly on the gradient */
}
.tpl-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.tpl-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255,255,255,0.7);
    color: #334155;
    backdrop-filter: blur(4px);
}
.tpl-badge-lien {
    background: rgba(254,243,199,0.8);
    color: #92400e;
}
.tpl-badge-type {
    background: rgba(224,231,255,0.8);
    color: #3730a3;
}

/* Contact badges */
.tpl-contact-badge {
    margin-left: 6px;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
}
.tpl-contact-yes {
    background: rgba(220,252,231,0.85);
    color: #166534;
    border: 1px solid #86efac;
}
.tpl-contact-no {
    background: rgba(254,226,226,0.85);
    color: #dc2626;
    border: 1px dashed #fca5a5;
}

/* Large tab title (e.g. "UPDATE" in red) */
.modal-tab-title {
    font-size: 32px;
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1;
    margin-top: 6px;
    text-shadow: 0 1px 2px rgba(255,255,255,0.6);
}

/* ── TABS ── */
.order-modal-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    flex-shrink: 0;
    overflow-x: auto;
    background: white;
}
.order-modal-tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.order-modal-tab:hover {
    color: #1e293b;
    background: #f8fafc;
}
.order-modal-tab.active {
    color: #1e40af;
    border-bottom-color: #1e40af;
    background: white;
}

/* ── TAB CONTENT ── */
.order-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    min-height: 0;
    background: white;
}

/* Footer */
.order-modal-footer {
    padding: 10px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-shrink: 0;
    background: #f8fafc;
}

/* ── COLLAPSIBLE SECTIONS (Vehicle Intel) ── */
.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #1e3a5f;
    color: white;
    border-radius: 8px;
    margin-bottom: 3px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    transition: background 0.15s;
}
.collapsible-header:hover { background: #2a4a6f; }
.collapsible-header .chevron {
    transition: transform 0.2s;
    font-size: 12px;
}
.collapsible-header.open .chevron { transform: rotate(180deg); }
.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 14px;
}
.collapsible-content.open {
    max-height: 800px;
    padding: 10px 14px;
}

/* ── VOICE / MIC BUTTON ── */
.mic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.mic-btn:hover {
    border-color: #1e40af;
    color: #1e40af;
    background: #eff6ff;
}
.mic-btn.recording {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
    animation: micPulse 1s infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Navigate button */
.navigate-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #2563eb;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.navigate-btn:hover {
    background: #1d4ed8;
}

/* Agent location marker */
.agent-self-marker {
    background: #2563eb;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 3px #2563eb, 0 2px 8px rgba(37,99,235,0.5);
    width: 18px;
    height: 18px;
    animation: agentPulse 2s infinite;
}
@keyframes agentPulse {
    0%, 100% { box-shadow: 0 0 0 3px #2563eb, 0 2px 8px rgba(37,99,235,0.5); }
    50% { box-shadow: 0 0 0 6px rgba(37,99,235,0.3), 0 2px 12px rgba(37,99,235,0.6); }
}
