/* ============================================================
   Vehicle Detail Modal — Unified cross-page vehicle view
   ============================================================ */

/* --- Clickable vehicle links (global) --- */
.vehicle-link {
    color: var(--primary, #0f3460);
    cursor: pointer;
    text-decoration: none;
    border-bottom: 1px dashed var(--primary, #0f3460);
    transition: color 0.15s, border-color 0.15s;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}
.vehicle-link:hover {
    color: var(--accent, #e94560);
    border-bottom-color: var(--accent, #e94560);
}

/* --- Overlay --- */
.vm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.vm-overlay.vm-visible {
    opacity: 1;
}

/* --- Modal container --- */
.vm-modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    transition: transform 0.2s ease;
    overflow: hidden;
}
.vm-overlay.vm-visible .vm-modal {
    transform: translateY(0);
}

/* --- Header --- */
.vm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border, #dfe6e9);
    background: #f8f9fa;
    flex-shrink: 0;
}
.vm-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.vm-header-icon {
    font-size: 1.3rem;
    color: var(--primary, #0f3460);
}
.vm-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #2d3436;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.vm-header-sub {
    font-size: 0.8rem;
    color: #636e72;
    font-weight: 400;
    margin-left: 0.5rem;
}
.vm-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #636e72;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.vm-close:hover {
    background: #dfe6e9;
    color: #2d3436;
}

/* --- Body (scrollable) --- */
.vm-body {
    overflow-y: auto;
    flex: 1;
    padding: 1.25rem;
}

/* --- Loading / Error / Not Found --- */
.vm-loading, .vm-error, .vm-not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: #636e72;
}
.vm-loading i, .vm-error i, .vm-not-found i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}
.vm-error { color: var(--danger, #d63031); }
.vm-error i { color: var(--danger, #d63031); }

/* --- Source badges --- */
.vm-source-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.vm-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    opacity: 0.35;
    transition: opacity 0.15s;
}
.vm-badge.vm-badge-active {
    opacity: 1;
}
.vm-badge-wholesale { background: #2d98da; }
.vm-badge-retail { background: #00b894; }
.vm-badge-enquiry { background: #6c5ce7; }
.vm-badge-customs { background: #e17055; }
.vm-badge-billing { background: #00cec9; }

/* --- Identity card --- */
.vm-identity {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border, #dfe6e9);
}
.vm-id-item {
    display: flex;
    flex-direction: column;
}
.vm-id-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #636e72;
    margin-bottom: 0.2rem;
    font-weight: 600;
}
.vm-id-value {
    font-size: 0.9rem;
    color: #2d3436;
    font-weight: 500;
    word-break: break-all;
}
.vm-id-value.mono {
    font-family: 'Courier New', monospace;
}

/* --- Tabs --- */
.vm-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--border, #dfe6e9);
    padding-bottom: 0;
}
.vm-tab {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: #636e72;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.vm-tab:hover {
    color: #2d3436;
}
.vm-tab.vm-tab-active {
    color: var(--primary, #0f3460);
    border-bottom-color: var(--primary, #0f3460);
    font-weight: 600;
}
.vm-tab-content {
    display: none;
}
.vm-tab-content.vm-tab-visible {
    display: block;
}

/* --- Overview tab: key info cards --- */
.vm-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.vm-overview-card {
    padding: 0.85rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border, #dfe6e9);
}
.vm-overview-card h4 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #636e72;
}
.vm-overview-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.85rem;
}
.vm-overview-row .vm-label {
    color: #636e72;
}
.vm-overview-row .vm-value {
    color: #2d3436;
    font-weight: 500;
    text-align: right;
}
.vm-overview-row .vm-value.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

/* --- Navigation buttons --- */
.vm-nav-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}
.vm-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}
.vm-nav-btn:hover { opacity: 0.85; }
.vm-nav-btn-wholesale { background: #2d98da; }
.vm-nav-btn-retail { background: #00b894; }
.vm-nav-btn-enquiry { background: #6c5ce7; }
.vm-nav-btn-customs { background: #e17055; }
.vm-nav-btn-billing { background: #00cec9; }

/* --- Timeline tab --- */
.vm-timeline {
    position: relative;
    padding-left: 2rem;
}
.vm-timeline::before {
    content: '';
    position: absolute;
    left: 0.65rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 2px;
    background: #dfe6e9;
}
.vm-timeline-item {
    position: relative;
    padding: 0.5rem 0 1rem;
    display: flex;
    gap: 0.75rem;
}
.vm-timeline-item:last-child {
    padding-bottom: 0;
}
.vm-timeline-dot {
    position: absolute;
    left: -1.65rem;
    top: 0.6rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #dfe6e9;
    flex-shrink: 0;
}
.vm-dot-wholesale { background: #2d98da; box-shadow: 0 0 0 2px #2d98da40; }
.vm-dot-retail { background: #00b894; box-shadow: 0 0 0 2px #00b89440; }
.vm-dot-enquiry { background: #6c5ce7; box-shadow: 0 0 0 2px #6c5ce740; }
.vm-dot-customs { background: #e17055; box-shadow: 0 0 0 2px #e1705540; }
.vm-dot-billing { background: #00cec9; box-shadow: 0 0 0 2px #00cec940; }
.vm-timeline-date {
    font-size: 0.78rem;
    color: #636e72;
    min-width: 5.5rem;
    font-weight: 500;
    flex-shrink: 0;
}
.vm-timeline-body {
    flex: 1;
}
.vm-timeline-event {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2d3436;
}
.vm-timeline-detail {
    font-size: 0.78rem;
    color: #636e72;
    margin-top: 0.15rem;
}
.vm-timeline-empty {
    text-align: center;
    padding: 2rem;
    color: #636e72;
    font-size: 0.9rem;
}

/* --- Details tab: accordion sections --- */
.vm-detail-section {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border, #dfe6e9);
    border-radius: 8px;
    overflow: hidden;
}
.vm-detail-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #2d3436;
    border: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}
.vm-detail-header:hover {
    background: #eee;
}
.vm-detail-header i.vm-detail-icon {
    font-size: 0.9rem;
    width: 1.2rem;
    text-align: center;
}
.vm-detail-chevron {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 0.75rem;
    color: #636e72;
}
.vm-detail-section.vm-detail-open .vm-detail-chevron {
    transform: rotate(180deg);
}
.vm-detail-body {
    display: none;
    padding: 0.75rem 0.85rem;
}
.vm-detail-section.vm-detail-open .vm-detail-body {
    display: block;
}
.vm-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
}
.vm-detail-field {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0;
}
.vm-detail-field-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #636e72;
}
.vm-detail-field-value {
    font-size: 0.85rem;
    color: #2d3436;
    font-weight: 500;
}

/* --- Subtle allocation badge (merged into enquiry) --- */
.vm-alloc-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c5ce7;
    background: #6c5ce710;
    border: 1px solid #6c5ce730;
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    margin-bottom: 0.4rem;
}

/* --- View PDF button (customs records) --- */
.vm-pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
    background: #e17055;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, background 0.15s;
}
.vm-pdf-btn:hover {
    background: #d63031;
}

/* --- DFE Live badge --- */
.vm-badge-dfe {
    background: #636e72;
    transition: background 0.3s, opacity 0.3s;
}
.vm-badge-dfe.vm-badge-active { background: #f39c12; opacity: 1; }
.vm-badge-dfe.vm-dfe-loading { background: #f39c12; opacity: 0.7; animation: vm-pulse 1.2s infinite; }
.vm-badge-dfe.vm-dfe-connected { background: #00b894; opacity: 1; }
.vm-badge-dfe.vm-dfe-error { background: #d63031; opacity: 1; }
@keyframes vm-pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* --- DFE Action buttons row --- */
.vm-dfe-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border, #dfe6e9);
}
.vm-dfe-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--primary, #0f3460);
    background: transparent;
    border: 1px solid var(--primary, #0f3460);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.vm-dfe-btn:hover {
    background: var(--primary, #0f3460);
    color: #fff;
}
.vm-dfe-btn:disabled, .vm-dfe-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}
.vm-dfe-btn i { font-size: 0.75rem; }

/* --- Sub-panel (replaces modal body content) --- */
.vm-sub-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.vm-sub-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border, #dfe6e9);
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}
.vm-sub-back {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: #636e72;
    padding: 0.25rem;
    border-radius: 4px;
}
.vm-sub-back:hover { background: #f0f0f0; }
.vm-sub-title {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2d3436;
    margin: 0;
}
.vm-sub-actions {
    display: flex;
    gap: 0.4rem;
}
.vm-sub-print {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border-radius: 5px;
    font-size: 0.75rem;
    color: var(--primary, #0f3460);
    background: transparent;
    border: 1px solid var(--primary, #0f3460);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.vm-sub-print:hover { background: var(--primary, #0f3460); color: #fff; }
.vm-sub-content {
    flex: 1;
    overflow-y: auto;
}

/* --- Technical Details sub-panel --- */
.vm-tech-row {
    display: flex;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
}
.vm-tech-label {
    width: 140px;
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: #636e72;
}
.vm-tech-value {
    flex: 1;
    font-size: 0.85rem;
    color: #2d3436;
}
.vm-tech-collection {
    margin-top: 0.25rem;
}
.vm-tech-collection-toggle {
    font-size: 0.75rem;
    color: var(--primary, #0f3460);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0.2rem 0;
}
.vm-tech-collection-toggle:hover { text-decoration: underline; }
.vm-tech-option {
    font-size: 0.78rem;
    color: #2d3436;
    padding: 0.15rem 0;
    padding-left: 0.5rem;
    border-left: 2px solid #dfe6e9;
    margin-left: 0.25rem;
}

/* --- MSRP sub-panel --- */
.vm-msrp-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
}
.vm-msrp-info-label { color: #636e72; font-weight: 600; }
.vm-msrp-info-value { color: #2d3436; }
.vm-msrp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.vm-msrp-table th {
    text-align: left;
    padding: 0.5rem;
    background: #f8f9fa;
    border-bottom: 2px solid var(--border, #dfe6e9);
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #636e72;
}
.vm-msrp-table td {
    padding: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}
.vm-msrp-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.vm-msrp-table tr:last-child td {
    font-weight: 700;
    border-top: 2px solid var(--border, #dfe6e9);
}

/* --- Inspection sub-panel --- */
.vm-inspection-field {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}
.vm-inspection-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #636e72;
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.vm-inspection-value {
    font-size: 0.88rem;
    color: #2d3436;
    white-space: pre-wrap;
}
.vm-inspection-level {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}
.vm-inspection-level.minor { background: #ffeaa7; color: #b45309; }
.vm-inspection-level.major { background: #fab1a0; color: #d63031; }
.vm-inspection-level.no-damage { background: #dfe6e9; color: #636e72; }

/* --- Retail Capture form --- */
.vm-retail-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.vm-retail-field label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #636e72;
    font-weight: 600;
    margin-bottom: 0.2rem;
}
.vm-retail-field input,
.vm-retail-field select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border, #dfe6e9);
    border-radius: 6px;
    font-size: 0.85rem;
    background: #fff;
}
.vm-retail-field input:read-only,
.vm-retail-field input[disabled] {
    background: #f8f9fa;
    color: #636e72;
}
.vm-retail-field select:focus,
.vm-retail-field input:focus {
    outline: none;
    border-color: var(--primary, #0f3460);
    box-shadow: 0 0 0 2px rgba(15, 52, 96, 0.1);
}
.vm-retail-submit {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary, #0f3460);
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}
.vm-retail-submit:hover { opacity: 0.85; }
.vm-retail-submit:disabled { opacity: 0.35; cursor: not-allowed; }

/* --- Responsive --- */
@media (max-width: 640px) {
    .vm-overlay {
        padding: 0;
    }
    .vm-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        height: 100%;
    }
    .vm-identity {
        grid-template-columns: 1fr 1fr;
    }
    .vm-overview-grid {
        grid-template-columns: 1fr;
    }
    .vm-detail-grid {
        grid-template-columns: 1fr;
    }
    .vm-tabs {
        overflow-x: auto;
    }
    .vm-timeline-date {
        min-width: 4.5rem;
        font-size: 0.72rem;
    }
}
