body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background-color: #0078d4;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.4rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.loc-select-header {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    max-width: 220px;
    text-overflow: ellipsis;
}

    .loc-select-header option {
        background: #0078d4;
        color: white;
    }

/* --- SIDE DRAWER SYSTEM --- */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    visibility: hidden;
    z-index: 1000;
}

    .mobile-drawer.open {
        visibility: visible;
    }

.drawer-overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-drawer.open .drawer-overlay {
    opacity: 1;
}

.drawer-content {
    position: absolute;
    left: -280px;
    width: 280px;
    height: 100%;
    background: white;
    transition: left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.mobile-drawer.open .drawer-content {
    left: 0;
}

.drawer-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.drawer-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 30px;
}

    .drawer-nav a {
        text-decoration: none;
        color: #333;
        padding: 12px 15px;
        border-radius: 4px;
        font-weight: 500;
        transition: 0.2s;
    }

        .drawer-nav a:hover {
            background: #f0f2f5;
            color: #0078d4;
        }

main {
    max-width: 1200px;
    margin: 0.5rem auto;
    padding: 0 1rem;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
}

.card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
}

h2 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.3rem;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 0.4rem;
    margin-bottom: 0.8rem;
}

.btn-primary {
    background: white;
    color: #0078d4;
    border: none;
    padding: 8px 20px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 20px;
    transition: 0.2s;
}

    .btn-primary:hover {
        background: #e6f2fb;
    }

.btn-action {
    background: #0078d4;
    color: white;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    transition: 0.2s;
    font-weight: bold;
}

    .btn-action:hover:not(:disabled) {
        background: #005a9e;
    }

    .btn-action:disabled {
        background-color: #ccc;
        cursor: not-allowed;
    }

.btn-secondary {
    background: transparent;
    color: white;
    border: 1px solid rgba(255,255,255,0.6);
    padding: 8px 20px;
    cursor: pointer;
    font-weight: 600;
    border-radius: 20px;
    transition: 0.2s;
}

/* --- SEARCH PATHS (MUTUALITY UI) --- */
.search-paths-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.search-path-box {
    transition: opacity 0.3s;
}

.ymmt-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.curated-path-container {
    margin-top: 0;
}

.main-input {
    width: 100%;
    padding: 6px 12px; /* Reduced vertical padding */
    font-size: 0.95rem; /* Reduced font size */
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    height: 36px; /* Forced smaller height */
}

/* VIN Input & Keyboard */
.vin-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

#vinInput {
    letter-spacing: 2px;
    text-transform: uppercase;
    padding-right: 35px !important;
}

#vinInput::placeholder {
    text-transform: none;
    letter-spacing: normal;
}

.clear-input-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #999;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 5;
    padding: 0;
    line-height: 1;
}

    .clear-input-btn:hover {
        color: #d13438;
    }

.keyboard-area {
    width: 100%;
    margin-top: 15px;
    display: none;
}

.keyboard-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(10, 1fr);
}

@media (max-width: 600px) {
    .keyboard-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .key-tile {
        min-height: 55px;
        font-size: 1.4rem;
    }
}

.key-tile {
    aspect-ratio: 1;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}

    .key-tile:active {
        transform: translateY(2px);
        background: #e0e0e0;
    }

    .key-tile.disabled {
        opacity: 0.3;
        pointer-events: none;
        background: #f4f4f4;
    }

    .key-tile.backspace {
        background-color: #fff0f0;
        color: #d13438;
    }

@keyframes pulse-blue {
    0% {
        background-color: #cce4f7;
    }

    100% {
        background-color: #fff;
    }
}

.auto-filled {
    animation: pulse-blue 0.5s ease-out;
}

@keyframes key-pop {
    0% {
        transform: scale(1);
        background-color: #0078d4;
        color: white;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        background-color: #fff;
        color: #333;
    }
}

.key-tile.auto-flash {
    animation: key-pop 0.4s ease-out;
}

/* --- RESULTS RENDERING (SCREEN) --- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #ccc;
    padding-bottom: 10px;
}

/* Screen Cards: Default border, no side colors */
.result-card {
    background: white;
    border: 1px solid #ccc;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Badges: Clean text, no background colors */
.badge {
    display: inline-block;
    padding: 0;
    font-size: 0.95rem;
    font-weight: bold;
    color: #333;
    text-transform: uppercase;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.research-warning {
    margin-top: 4px;
    margin-bottom: 4px;
    background: transparent;
    border: none;
    color: #333;
    padding: 0;
    font-size: 0.95rem;
    font-weight: normal;
    text-align: left;
}

.vehicle-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.95rem;
}

.meta-item strong {
    color: #555;
}

.only-print {
    display: none;
}


/* --- NEW: CUSTOM AUTOCOMPLETE DROPDOWN --- */
.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dropdown-item {
    padding: 8px 15px; /* Reduced vertical padding */
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    line-height: 1.4; /* Ensures clean spacing if wrapping occurs */
}

    .dropdown-item:last-child {
        border-bottom: none;
    }

    .dropdown-item:hover, .dropdown-item:active {
        background: #f0f2f5;
    }

.item-part-name {
    display: inline; /* Forces it onto one line */
    font-weight: bold;
    color: #0078d4;
    font-size: 1.05rem; /* Scaled down slightly */
}

.item-category-name {
    display: inline; /* Forces it onto one line */
    font-size: 0.85rem;
    color: #888;
    text-transform: capitalize; /* Natural casing instead of ALL CAPS */
}

/* --- HORIZONTAL CHIPS (HYBRID BROWSE) --- */
.category-chips-container {
    display: flex;
    flex-wrap: wrap; /* Desktop: Wrap into multiple rows */
    gap: 8px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.category-chip {
    background: #e6f2fb;
    color: #0078d4;
    border: 1px solid #cce4f7;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    white-space: nowrap;
}

    .category-chip:active, .category-chip:hover {
        background: #cce4f7;
    }

/* Mobile Override: Single swipeable row ONLY for touch-screen devices */
@media (pointer: coarse) {
    .category-chips-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        /* Hide scrollbar for a clean app feel */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

        .category-chips-container::-webkit-scrollbar {
            display: none;
        }
}


/* --- 80mm THERMAL RECEIPT PRINTER CSS --- */
@media print {
    @page {
        margin: 0;
        size: 80mm auto;
    }

    body {
        width: 80mm;
        margin: 0;
        padding: 4mm;
        background: white;
        color: black;
        font-family: 'Courier New', Courier, monospace;
    }

    /* Force uniform text size and strip all bold/italic universally */
    * {
        font-size: 14px !important;
        font-weight: normal !important;
        font-style: normal !important;
    }

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

    .only-print {
        display: block !important;
    }

    #appContent {
        margin: 0;
        padding: 0;
    }

    #resultsSection {
        display: block !important;
    }

    /* Format like a clean receipt list */
    .result-card {
        border: none !important;
        border-radius: 0 !important;
        margin-bottom: 8mm !important; /* Replaced dash with vertical white space */
        padding: 0 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    /* Make badges raw text */
    .badge {
        border: none !important;
        background: transparent !important;
        color: black !important;
        font-size: 14px;
        display: inline-block !important;
        margin-bottom: 2px !important;
        padding: 0 !important;
        font-weight: normal !important;
    }

        .badge::before {
            content: "[ ";
        }

        .badge::after {
            content: " ]";
        }

    .research-warning {
        background: transparent !important;
        border: none !important; /* Removed dashed border */
        color: black !important;
        margin-top: 2px !important;
        margin-bottom: 6px !important;
        padding: 0 !important;
        text-align: left !important;
    }

    .vehicle-meta {
        display: block;
        margin-top: 0;
    }

    .meta-item {
        display: block;
        margin-bottom: 2px;
    }

        .meta-item strong {
            color: black;
            font-weight: normal !important;
        }

    /* Spacing for headers and footers */
    .print-header {
        margin-bottom: 6mm !important;
        border: none !important;
        text-align: left;
    }

    /* FIX: Ensure footer and disclaimer are left-justified */
    .print-footer {
        margin-top: 6mm !important;
        border: none !important;
        text-align: left;
    }

    .disclaimer {
        margin-top: 6mm !important;
        text-align: left;
        color: black !important;
    }
}

/* User Settings Table */
.perm-grid {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.9rem;
    background: white;
}

    .perm-grid th {
        padding: 12px 8px;
        border-bottom: 2px solid #000;
        text-transform: uppercase;
        text-align: left;
    }

    .perm-grid td {
        padding: 12px 8px;
        border-bottom: 1px solid #eee;
        color: #444;
    }

.active-user td {
    background-color: #f4f4f4;
    font-weight: bold !important;
    color: #000 !important;
}

@media (max-width: 600px) {
    .perm-grid {
        display: none;
    }
}

/* --- FITMENT BUTTON & QR CODE --- */
.fitment-btn {
    margin-top: 10px;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.qr-container {
    margin-top: 10px;
}
    /* Ensure the QR code canvas prints cleanly */
    .qr-container canvas, .qr-container img {
        max-width: 100%;
        height: auto;
    }

@media print {
    /* Position the QR code neatly within the receipt card */
    .qr-container {
        margin-top: 5px !important;
        margin-bottom: 5px !important;
        text-align: center; /* Centers the QR code on the receipt */
    }
}
