.grid-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 16px;
    margin: 16px auto;
}

.grid-item {
    /* flex: 0 0 auto so items size to content (the 450px YouTube iframe
       + title). Previously flex:1 stretched items to fill the row,
       which left a single video misaligned because the iframe was
       smaller than its parent. */
    flex: 0 0 auto;
    min-width: 400px;
    margin: 0;
    background-color: #f0f0f0;
    padding: 20px;
    text-align: center;
}

.grid-container-product {
    /* Flex (not grid) so partial last rows center instead of left-align.
       Grid with 1fr columns always stretches to fill width, which means
       a row of 5 items in a 4-column layout leaves the lone 5th card
       flush left. Flex with fixed-basis items + justify-content: center
       gives a properly centered tail row. */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin: 16px auto;
    align-items: stretch;
}

.grid-item-product {
    display: flex;
    flex-direction: column;
    flex: 0 0 220px;        /* fixed basis so last-row centering works */
    background-color: #f5f7fa;
    border: 1px solid #e3e7ec;
    border-radius: 8px;
    padding: 14px;
    margin: 0;
    min-width: 0;
    transition: box-shadow 0.15s, transform 0.15s;
}
.grid-item-product:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.grid-item-product__image {
    text-align: center;
    margin-bottom: 10px;
}
.grid-item-product__image img {
    max-width: 100%;
    height: 130px;
    object-fit: contain;
    display: inline-block;
}

.grid-item-product__title {
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
    margin: 0 0 8px;
    /* Reserve a fixed 3-line slot so cards stay aligned regardless of
       title length. Anything longer is truncated with an ellipsis. */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
    min-height: calc(13px * 1.35 * 3);
}
.grid-item-product__title a {
    color: #1f3a5f;
    text-decoration: none;
}
.grid-item-product__title a:hover { text-decoration: underline; }

.grid-item-product__price {
    text-align: center;
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: #111;
    /* margin-top: auto pushes the price + button block to the bottom of
       the card so all cards in a row line up at the bottom. */
    margin-top: auto;
}
.grid-item-product__price del {
    color: #888;
    font-weight: 400;
    font-size: 13px;
    margin-right: 4px;
}
.grid-item-product__price ins {
    background: transparent;
    text-decoration: none;
}

.grid-item-product__backorder {
    text-align: center;
    font-size: 11px;
    line-height: 1.3;
    color: #b3261e;
    margin: 0 0 6px;
    font-weight: 500;
}

.grid-item-product__cart {
    text-align: center;
    margin: 0;
}
.grid-item-product__cart .add_to_cart_inline {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    display: block !important;
    text-align: center;
}
.grid-item-product__cart .add_to_cart_inline .price,
.grid-item-product__cart .add_to_cart_inline ins,
.grid-item-product__cart .add_to_cart_inline del,
.grid-item-product__cart .add_to_cart_inline bdi {
    display: none; /* price already shown above the button */
}
.grid-item-product__cart a.button,
.grid-item-product__cart .button {
    display: inline-block !important;
    width: auto !important;
    padding: 6px 14px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    background: #1f3a5f !important;
    color: #fff !important;
    border-radius: 4px !important;
    border: none !important;
    text-transform: none !important;
    letter-spacing: 0.3px;
    margin: 0 !important;
    box-shadow: none !important;
    height: auto !important;
    min-height: 0 !important;
    min-width: 0 !important;
    text-decoration: none !important;
    white-space: nowrap;
}
.grid-item-product__cart a.button:hover,
.grid-item-product__cart .button:hover {
    background: #2c5288 !important;
    color: #fff !important;
}
/* "Read more" link for unpriced/out-of-stock products: muted gray */
.grid-item-product__cart a.button.product_type_simple:not(.add_to_cart_button) {
    background: #6b7280 !important;
}
.grid-item-product__cart a.button.product_type_simple:not(.add_to_cart_button):hover {
    background: #4b5563 !important;
}

.grid-container-schematic {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    text-align: center;
}

.grid-item-schematic {
    flex: 1;
    min-width: 400px;
    max-height: 500px;
    margin: 10px;
    background-color: #f0f0f0;
    padding: 30px;
    text-align: center;
}

.grid-container-brand {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    text-align: center;
}

.grid-item-brand {
    flex: 1;
    min-width: 300px;
    max-height: 500px;
    margin: 10px;
    background-color: #f0f0f0;
    padding: 30px;
    text-align: center;
}

@media screen and (max-width: 768px) {
    .grid-item {
        min-width: calc(100% - 20px); /* Adjust the width and margin as needed */
    }
    .grid-container-product {
        gap: 10px;
    }
    .grid-item-product {
        flex: 0 0 150px;    /* tighter basis on small screens */
    }
    .grid-item-schematic {
        min-width: calc(100% - 20px); /* Adjust the width and margin as needed */
    }
    .grid-item-brand {
        min-width: calc(100% - 20px); /* Adjust the width and margin as needed */
    }
}

/* Schematic Image Container Styles */
.schematic-image-container {
    position: relative;
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
}

.schematic-image-container.schematic-loading {
    opacity: 0.6;
    pointer-events: none;
}

.schematic-image-container.schematic-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Remove Image Button Styles */
.remove-image-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: background-color 0.3s ease;
}

.remove-image-btn:hover {
    background-color: #c82333;
}

.remove-image-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Image Header Styles */
.image-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.image-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

/* Add SKU Section Styles */
.add-sku-section {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
}

.add-sku-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
}

.add-sku-form {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.add-sku-form .form-group {
    flex: 1;
    min-width: 120px;
}

.add-sku-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.add-sku-form input[type="text"],
.add-sku-form input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.add-sku-button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: background-color 0.3s ease;
}

.add-sku-button:hover {
    background-color: #218838;
}

.add-sku-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

/* Parts Table Styles */
.parts-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #fff;
}

.parts-table th,
.parts-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.parts-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.parts-table tbody tr:hover {
    background-color: #f8f9fa;
}

.remove-item-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.remove-item-btn:hover {
    background-color: #c82333;
}

/* Message Styles */
.schematic-message {
    padding: 12px 16px;
    margin: 15px 0;
    border-radius: 4px;
    font-size: 14px;
}

.schematic-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.schematic-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .add-sku-form {
        flex-direction: column;
    }
    
    .add-sku-form .form-group {
        min-width: 100%;
    }
    
    .image-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .parts-table {
        font-size: 12px;
    }
    
    .parts-table th,
    .parts-table td {
        padding: 8px;
    }
}

/* ====================================================================
   Compatibility chart: collapsible "show all" toggle.
   The full link list is always in the rendered HTML (so Googlebot
   indexes every internal link); CSS just hides the overflow behind
   a button click. SEO impact: none — Google treats hidden-but-
   accessible content the same as visible.
   ==================================================================== */
.schematic-compat-chart__extra[hidden] {
    display: none;
}
.schematic-compat-chart__toggle {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 14px;
    background: #f0f4f8;
    color: #1f3a5f;
    border: 1px solid #c5d0db;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s, border-color .15s;
}
.schematic-compat-chart__toggle:hover,
.schematic-compat-chart__toggle:focus {
    background: #e2eaf2;
    border-color: #8fa5bf;
    outline: none;
}
.schematic-compat-chart__toggle[aria-expanded="true"] {
    background: #fff;
    border-color: #8fa5bf;
}

/* ====================================================================
   Breadcrumb trail — Schematics › Brand › Model
   Rendered by includes/breadcrumbs.php on brand pages and single
   schematic pages. Link color comes from the vru-theme token
   (--vru-color-primary) with the literal blue as fallback for any
   context where the theme stylesheet isn't loaded.
   ==================================================================== */
.schematics-breadcrumbs {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.4;
}
.schematics-breadcrumbs ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
.schematics-breadcrumbs li {
    display: flex;
    align-items: center;
}
.schematics-breadcrumbs li + li::before {
    content: "\203A"; /* › */
    margin: 0 8px;
    color: #999;
}
.schematics-breadcrumbs a {
    color: var(--vru-color-primary, #0170B9);
    text-decoration: none;
}
.schematics-breadcrumbs a:hover,
.schematics-breadcrumbs a:focus {
    text-decoration: underline;
}
.schematics-breadcrumbs [aria-current="page"] {
    color: #666;
}
