/* ===================================
   Parts Catalog Styles
   Toyota Parts Direct-style layout
   =================================== */

/* Search Container */
.parts-catalog-page {
    padding: 1rem;
    max-width: 1600px;
    margin: 0 auto;
}

.catalog-search-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.search-wrapper {
    position: relative;
}

.catalog-search-container .input-group-lg .form-control {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.catalog-search-container .input-group-lg .form-control:focus {
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
}

/* Search Results Dropdown */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    z-index: 1050;
    max-height: 500px;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.15s;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-image {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
    background: #f5f5f5;
}

.search-result-image-placeholder {
    width: 48px;
    height: 48px;
    background: #e9ecef;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
}

/* Card Styles */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.card-img-container {
    height: 180px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-img-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: #adb5bd;
    font-size: 3rem;
}

.card-img-placeholder-sm {
    height: 80px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 1.5rem;
}

.card-img-container-sm {
    height: 80px;
    overflow: hidden;
    background: #f8f9fa;
}

.card-img-container-sm img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Assembly Thumbnail */
.assembly-thumbnail {
    position: relative;
}

.assembly-code-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Exploded View Styles */
.exploded-diagram-card {
    border: 2px solid #dee2e6;
}

.exploded-diagram-container {
    position: relative;
    min-height: 300px;
    max-height: 500px;
    overflow: auto;
    background: #fafafa;
    border-radius: 4px;
}

/* Wrapper that contains both the image and hotspots - ensures hotspots are positioned relative to the image */
.exploded-diagram-wrapper {
    position: relative;
    display: inline-block;
}

/* CRITICAL: Image sizing must match the admin editor exactly for hotspot positions to align */
.exploded-diagram-image {
    display: block;
    max-width: 100%;
    max-height: 480px;
}

.exploded-diagram-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #adb5bd;
}

/* Callout Markers */
.callout-marker {
    position: absolute;
    width: 28px;
    height: 28px;
    background: #0d6efd;
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 10;
}

.callout-marker:hover,
.callout-marker.hovered {
    background: #0b5ed7;
    transform: translate(-50%, -50%) scale(1.15);
    z-index: 20;
}

.callout-marker.selected {
    background: #198754;
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 0 4px rgba(25, 135, 84, 0.3);
    z-index: 25;
}

.callout-number {
    color: white;
    font-weight: bold;
    font-size: 11px;
    line-height: 1;
}

/* Part Tooltip */
.part-tooltip {
    position: absolute;
    background: rgba(33, 37, 41, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    z-index: 100;
    min-width: 200px;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.callout-badge-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #0d6efd;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
}

.tooltip-body {
    color: #ced4da;
    margin-bottom: 6px;
}

.tooltip-footer {
    display: flex;
    align-items: center;
}

.tooltip-footer .price {
    font-weight: bold;
    font-size: 14px;
}

/* Parts List */
.parts-list-card {
    border: 2px solid #dee2e6;
}

.parts-table-container {
    max-height: 600px;
    overflow-y: auto;
}

.callout-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.selected-row .callout-badge {
    background: #198754;
}

.quantity-input {
    width: 55px !important;
    text-align: center;
    padding: 2px 4px;
}

.add-to-cart-btn {
    padding: 4px 8px;
}

.part-name {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Selected Row Animation */
.table tbody tr.selected-row {
    animation: highlight-pulse 0.5s ease;
}

@keyframes highlight-pulse {
    0% { background-color: rgba(13, 110, 253, 0.3); }
    100% { background-color: rgba(13, 110, 253, 0.1); }
}

/* Related Assemblies */
.related-assembly-card {
    border: 1px solid #dee2e6;
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .exploded-diagram-container {
        max-height: 400px;
    }
    
    .parts-table-container {
        max-height: 400px;
    }
    
    .part-name {
        max-width: 150px;
    }
}

@media (max-width: 767.98px) {
    .parts-catalog-page {
        padding: 0.5rem;
    }
    
    .card-img-container {
        height: 140px;
    }
    
    .exploded-diagram-container {
        min-height: 250px;
        max-height: 350px;
    }
    
    .callout-marker {
        width: 24px;
        height: 24px;
    }
    
    .callout-number {
        font-size: 10px;
    }
    
    .part-name {
        max-width: 100px;
    }
    
    /* Hide some columns on mobile */
    .parts-table-container th:nth-child(3),
    .parts-table-container td:nth-child(3) {
        display: none;
    }
}

/* ===================================
   Hotspot Editor Styles (Admin)
   =================================== */

.hotspot-editor-container {
    position: relative;
    min-height: 350px;
    max-height: 500px;
    overflow: auto;
    background: #fafafa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

/* Wrapper that contains both the image and hotspots - ensures hotspots are positioned relative to the image */
.hotspot-image-wrapper {
    position: relative;
    display: inline-block;
}

.hotspot-editor-container .hotspot-image {
    display: block;
    max-width: 100%;
    max-height: 480px;
    user-select: none;
    -webkit-user-drag: none;
}

.hotspot-image-wrapper .callout-marker {
    position: absolute;
    width: 32px;
    height: 32px;
    background: #0d6efd;
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 10;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hotspot-image-wrapper .callout-marker .callout-number {
    color: white;
    font-weight: bold;
    font-size: 12px;
    line-height: 1;
}

/* Existing markers (dimmed for context) */
.hotspot-image-wrapper .existing-marker {
    background: #6c757d;
    opacity: 0.5;
    cursor: default;
    z-index: 5;
}

/* Current/new marker (draggable) */
.hotspot-image-wrapper .current-marker {
    background: #198754;
    cursor: grab;
    z-index: 15;
    animation: pulse-marker 2s infinite;
}

.hotspot-image-wrapper .current-marker:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.4);
}

.hotspot-image-wrapper .current-marker.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 6px 16px rgba(25, 135, 84, 0.5);
    animation: none;
}

@keyframes pulse-marker {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(25, 135, 84, 0.3);
    }
    50% {
        box-shadow: 0 2px 8px rgba(25, 135, 84, 0.3), 0 0 0 8px rgba(25, 135, 84, 0.15);
    }
}

/* No image placeholder */
.hotspot-no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #adb5bd;
    text-align: center;
    padding: 2rem;
}

/* Loading overlay */
.hotspot-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    z-index: 100;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .hotspot-editor-container {
        min-height: 280px;
        max-height: 400px;
    }
    
    .hotspot-editor-container .callout-marker {
        width: 28px;
        height: 28px;
    }
    
    .hotspot-editor-container .callout-marker .callout-number {
        font-size: 11px;
    }
}

/* ===================================
   Dark mode
   =================================== */
.theme-dark .search-results-dropdown {
    background: #1a2332;
    border-color: #2d3e50;
}

.theme-dark .search-result-item {
    border-bottom-color: #2d3e50;
}

.theme-dark .search-result-item:hover {
    background: #233047;
}

.theme-dark .search-result-image,
.theme-dark .card-img-container,
.theme-dark .card-img-container-sm,
.theme-dark .card-img-placeholder-sm {
    background: #0f1420;
}

.theme-dark .search-result-image-placeholder {
    background: #233047;
    color: #6b7280;
}

.theme-dark .exploded-diagram-card,
.theme-dark .parts-list-card {
    border-color: #2d3e50;
}

.theme-dark .exploded-diagram-container,
.theme-dark .hotspot-editor-container {
    background: #0f1420;
    border-color: #2d3e50;
}

.theme-dark .related-assembly-card {
    border-color: #2d3e50;
}

.theme-dark .hotspot-loading-overlay {
    background: rgba(15, 20, 32, 0.8);
}
