/* ============================================================
   JDM User Hub — Styles
   Designed to sit on top of your Elementor/custom theme.
   Dark mode toggled via .jdm-dark on <html>
   ============================================================ */

:root {
    --jdm-bg:          #ffffff;
    --jdm-surface:     #f5f5f5;
    --jdm-border:      #e0e0e0;
    --jdm-text:        #1a1a1a;
    --jdm-text-muted:  #666666;
    --jdm-accent:      #c8102e;   /* JDM red */
    --jdm-accent-dark: #9e0c24;
    --jdm-radius:      8px;
    --jdm-shadow:      0 2px 12px rgba(0,0,0,0.08);
    --jdm-transition:  0.2s ease;
}

html.jdm-dark {
    --jdm-bg:         #111111;
    --jdm-surface:    #1e1e1e;
    --jdm-border:     #2e2e2e;
    --jdm-text:       #f0f0f0;
    --jdm-text-muted: #999999;
    --jdm-shadow:     0 2px 12px rgba(0,0,0,0.4);
}

/* --- Scoped to hub elements only (avoids affecting the rest of the theme) */
.jdm-hub,
.jdm-modal,
.jdm-toast {
    color: var(--jdm-text);
    font-family: inherit;
    box-sizing: border-box;
}

.jdm-hub *,
.jdm-hub *::before,
.jdm-hub *::after {
    box-sizing: border-box;
}

/* ============================================================
   Dashboard Layout
   ============================================================ */
.jdm-hub {
    background: var(--jdm-bg);
    border-radius: var(--jdm-radius);
    padding: 24px;
}

.jdm-hub__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.jdm-hub__title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--jdm-text);
    margin: 0;
}

/* ============================================================
   Tabs
   ============================================================ */
.jdm-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--jdm-border);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.jdm-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--jdm-text-muted);
    transition: color var(--jdm-transition), border-color var(--jdm-transition);
}

.jdm-tab:hover { color: var(--jdm-text); }

.jdm-tab.active {
    color: var(--jdm-accent);
    border-bottom-color: var(--jdm-accent);
}

.jdm-tab-count {
    display: inline-block;
    background: var(--jdm-accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    margin-left: 5px;
    vertical-align: middle;
}

.jdm-tab-panel { display: none; }
.jdm-tab-panel.active { display: block; }

/* ============================================================
   Cards / Items
   ============================================================ */
.jdm-card {
    background: var(--jdm-surface);
    border: 1px solid var(--jdm-border);
    border-radius: var(--jdm-radius);
    padding: 16px;
    margin-bottom: 12px;
}

.jdm-search-item,
.jdm-fav-item {
    background: var(--jdm-surface);
    border: 1px solid var(--jdm-border);
    border-radius: var(--jdm-radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: border-color var(--jdm-transition);
}

.jdm-search-item:hover,
.jdm-fav-item:hover {
    border-color: var(--jdm-accent);
}

.jdm-search-item__header,
.jdm-fav-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.jdm-search-item__meta,
.jdm-fav-item__meta {
    font-size: 0.82rem;
    color: var(--jdm-text-muted);
    margin-top: 4px;
}

/* ============================================================
   Favourites Grid
   ============================================================ */
.jdm-fav-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .jdm-fav-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .jdm-fav-grid { grid-template-columns: 1fr; }
}

.jdm-fav-card {
    background: var(--jdm-surface);
    border: 1px solid var(--jdm-border);
    border-radius: var(--jdm-radius);
    overflow: hidden;
    transition: border-color var(--jdm-transition), box-shadow var(--jdm-transition);
}

.jdm-fav-card:hover {
    border-color: var(--jdm-accent);
    box-shadow: var(--jdm-shadow);
}

.jdm-fav-card__image-wrap {
    display: block;
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--jdm-border);
}

.jdm-fav-card__image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.jdm-fav-card:hover .jdm-fav-card__image-wrap img {
    transform: scale(1.03);
}

.jdm-fav-card__no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--jdm-text-muted);
    font-size: 0.8rem;
}

.jdm-fav-card__info {
    padding: 10px 12px 12px;
}

.jdm-fav-card__title {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--jdm-text);
    text-decoration: none;
    line-height: 1.3;
    margin-bottom: 4px;
}

.jdm-fav-card__title:hover { color: var(--jdm-accent); }

.jdm-fav-card__price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--jdm-accent);
    margin-bottom: 4px;
}

.jdm-fav-card__meta {
    font-size: 0.75rem;
    color: var(--jdm-text-muted);
    margin-bottom: 8px;
}

.jdm-fav-card__alert input {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--jdm-border);
    border-radius: var(--jdm-radius);
    background: var(--jdm-bg);
    color: var(--jdm-text);
}

.jdm-fav-card__alert input:focus {
    outline: none;
    border-color: var(--jdm-accent);
}

.jdm-search-item__sources {
    font-size: 0.78rem;
    color: var(--jdm-text-muted);
    margin-top: 2px;
}

.jdm-search-item__notifications {
    margin-top: 8px;
    font-size: 0.85rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.jdm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border-radius: var(--jdm-radius);
    border: none;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--jdm-transition), opacity var(--jdm-transition);
}

.jdm-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.jdm-btn--primary {
    background: var(--jdm-accent);
    color: #fff;
}
.jdm-btn--primary:hover { background: var(--jdm-accent-dark); }

.jdm-btn--secondary {
    background: var(--jdm-surface);
    color: var(--jdm-text);
    border: 1px solid var(--jdm-border);
}
.jdm-btn--secondary:hover { border-color: var(--jdm-accent); color: var(--jdm-accent); }

.jdm-btn--icon {
    background: none;
    border: none;
    padding: 4px 8px;
    font-size: 1.1rem;
    color: var(--jdm-text-muted);
    cursor: pointer;
    line-height: 1;
}
.jdm-btn--icon:hover { color: var(--jdm-accent); }

/* Favourite button */
.jdm-fav-btn {
    background: none;
    border: 1px solid var(--jdm-border);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--jdm-text-muted);
    transition: all var(--jdm-transition);
}
.jdm-fav-btn:hover,
.jdm-fav-btn.active {
    background: var(--jdm-accent);
    border-color: var(--jdm-accent);
    color: #fff;
}
/* Overlay is also a .jdm-fav-btn but must NOT turn red on hover — only the SVG colours */
.jdm-fav-overlay:hover,
.jdm-fav-overlay:focus {
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: transparent !important;
    color: var(--jdm-accent) !important;
}
html.jdm-dark .jdm-fav-overlay:hover,
html.jdm-dark .jdm-fav-overlay:focus {
    background: rgba(30, 30, 30, 0.92) !important;
}
.jdm-fav-overlay.active {
    background: rgba(255, 255, 255, 0.92) !important;
    color: var(--jdm-accent) !important;
}
html.jdm-dark .jdm-fav-overlay.active {
    background: rgba(30, 30, 30, 0.92) !important;
}

/* Save search button */
.jdm-save-search-btn {
    background: none;
    border: 1px solid var(--jdm-accent);
    border-radius: var(--jdm-radius);
    padding: 7px 14px;
    color: var(--jdm-accent);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--jdm-transition);
}
.jdm-save-search-btn:hover {
    background: var(--jdm-accent);
    color: #fff;
}

/* ============================================================
   Forms
   ============================================================ */
.jdm-field {
    margin-bottom: 16px;
}

.jdm-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--jdm-text-muted);
    margin-bottom: 5px;
}

.jdm-field input[type="text"],
.jdm-field input[type="number"],
.jdm-field select,
.jdm-field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--jdm-border);
    border-radius: var(--jdm-radius);
    background: var(--jdm-bg);
    color: var(--jdm-text);
    font-size: 0.9rem;
    transition: border-color var(--jdm-transition);
}

.jdm-field input:focus,
.jdm-field select:focus,
.jdm-field textarea:focus {
    outline: none;
    border-color: var(--jdm-accent);
}

.jdm-checkboxes {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.jdm-checkboxes label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    color: var(--jdm-text);
    cursor: pointer;
}

/* ============================================================
   Calculator
   ============================================================ */
.jdm-calc-result {
    margin-top: 20px;
}

.jdm-calc__fx {
    font-size: 0.8rem;
    color: var(--jdm-text-muted);
    margin-bottom: 12px;
}

.jdm-calc__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.jdm-calc__table th,
.jdm-calc__table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--jdm-border);
    text-align: left;
}

.jdm-calc__table thead th {
    font-weight: 700;
    color: var(--jdm-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.jdm-calc__amount { text-align: right; font-variant-numeric: tabular-nums; }

.jdm-calc__total th {
    font-size: 1rem;
    color: var(--jdm-accent);
}
.jdm-calc__total th:last-child { text-align: right; }

.jdm-calc__disclaimer {
    font-size: 0.78rem;
    color: var(--jdm-text-muted);
    margin-top: 12px;
    padding: 10px;
    background: var(--jdm-surface);
    border-radius: var(--jdm-radius);
    border-left: 3px solid var(--jdm-accent);
}

/* ============================================================
   Dark Mode Toggle
   ============================================================ */
.jdm-dark-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--jdm-text-muted);
}

.jdm-toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
}

.jdm-toggle-switch input { opacity: 0; width: 0; height: 0; }

.jdm-toggle-switch__track {
    position: absolute;
    inset: 0;
    background: var(--jdm-border);
    border-radius: 22px;
    cursor: pointer;
    transition: background var(--jdm-transition);
}

.jdm-toggle-switch__track::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--jdm-transition);
}

.jdm-toggle-switch input:checked + .jdm-toggle-switch__track {
    background: var(--jdm-accent);
}

.jdm-toggle-switch input:checked + .jdm-toggle-switch__track::before {
    transform: translateX(18px);
}

/* ============================================================
   Modal
   ============================================================ */
.jdm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.jdm-modal--visible {
    opacity: 1;
    pointer-events: all;
}

.jdm-modal__inner {
    background: var(--jdm-bg);
    border-radius: var(--jdm-radius);
    padding: 28px;
    width: 100%;
    max-width: 480px;
    position: relative;
    box-shadow: var(--jdm-shadow);
    transform: translateY(12px);
    transition: transform 0.25s ease;
}

.jdm-modal--visible .jdm-modal__inner {
    transform: translateY(0);
}

.jdm-modal__inner h3 {
    margin: 0 0 20px;
    font-size: 1.1rem;
    color: var(--jdm-text);
}

.jdm-modal__close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--jdm-text-muted);
}
.jdm-modal__close:hover { color: var(--jdm-accent); }

/* ============================================================
   Toast Notifications
   ============================================================ */
.jdm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #222;
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--jdm-radius);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 100000;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 320px;
}

.jdm-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

.jdm-toast--error   { background: #c8102e; }
.jdm-toast--info    { background: #1a6eb5; }
.jdm-toast--success { background: #1a7a4a; }

html.jdm-dark .jdm-toast { background: #2a2a2a; }

/* ============================================================
   Favourite Heart — Grid Overlay
   Injected automatically on .jdm-inventory-grid cards
   ============================================================ */

/* The card link needs position:relative — set via JS to avoid
   touching the theme's stylesheet */
.jdm-fav-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    width: 36px;
    height: 36px;
    padding: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 6px rgba(0,0,0,0.18);
    color: #bbb;
    transition: color var(--jdm-transition), background var(--jdm-transition), transform var(--jdm-transition);
    /* Hidden at rest on desktop, visible on hover & always on mobile */
}

html.jdm-dark .jdm-fav-overlay {
    background: rgba(30, 30, 30, 0.92);
    color: #888;
}

/* Show on card hover (desktop) */
a.used-car-card:hover .jdm-fav-overlay,
.jdm-fav-overlay:focus,
.jdm-fav-overlay.active {
    opacity: 1;
}

/* Always visible on touch devices */
@media (hover: none) {
    .jdm-fav-overlay { opacity: 1; }
}

.jdm-fav-overlay:hover {
    color: var(--jdm-accent);
    transform: scale(1.12);
}

.jdm-fav-overlay.active {
    color: var(--jdm-accent);
}

.jdm-fav-overlay svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Loading spinner state */
.jdm-fav-overlay.jdm-fav-btn--loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================
   Favourite Button — Individual Listing Page
   Used as a standalone wide button on the vehicle detail page.
   Add via shortcode [jdm_favourite_btn] or PHP call.
   ============================================================ */
.jdm-fav-btn--page {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--jdm-radius);
    border: 2px solid var(--jdm-border);
    background: var(--jdm-bg);
    color: var(--jdm-text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--jdm-transition);
}

.jdm-fav-btn--page svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.jdm-fav-btn--page:hover {
    border-color: var(--jdm-accent);
    color: var(--jdm-accent);
}

.jdm-fav-btn--page.active {
    background: var(--jdm-accent);
    border-color: var(--jdm-accent);
    color: #fff;
}

.jdm-fav-btn--page.jdm-fav-btn--loading {
    opacity: 0.6;
    pointer-events: none;
}
.jdm-empty {
    color: var(--jdm-text-muted);
    font-size: 0.9rem;
    text-align: center;
    padding: 30px 0;
}

.jdm-error {
    color: var(--jdm-accent);
    font-size: 0.88rem;
}

.jdm-loading {
    text-align: center;
    padding: 20px;
    color: var(--jdm-text-muted);
    font-size: 0.9rem;
}

.jdm-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--jdm-accent);
    color: #fff;
}

.jdm-badge--hot { background: #e05c00; }

.jdm-login-prompt {
    text-align: center;
    padding: 30px;
    color: var(--jdm-text-muted);
}

.jdm-login-prompt a { color: var(--jdm-accent); }
