/**
 * Single Product Page Styles
 *
 * Consolidated styles for product info, tabs, technical features, and relations.
 * Previously inline in product-info.php, product-tabs.php,
 * product-technical-features.php, and product-relations.php.
 */

/* ==========================================================================
   Product Info
   ========================================================================== */

.product-info-label {
    color: var(--wp--preset--color--dark);
}

.product-info-value {
    color: var(--wp--preset--color--dark-faded);
}

.product-barcode {
    display: inline-block;
}

.subcategory-dropdown {
    font: inherit;
    font-size: 0.9em;
    color: var(--wp--preset--color--dark-faded);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    max-width: 100%;
}

.subcategory-dropdown:hover,
.subcategory-dropdown:focus {
    border-color: #999;
    outline: none;
}

.product-supplier-logo img {
    max-height: 60px;
    width: auto;
}

/* ==========================================================================
   Product Tabs
   ========================================================================== */

/* Tab content container */
.product-tab-ajax-content {
    min-height: 100px;
}

/* Empty state message */
.tab-content-empty {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Technical Features in tabs - remove section wrapper styling */
.product-tab-ajax-content .product-technical-features-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.product-tab-ajax-content .product-technical-features-title {
    display: none; /* Title is in the tab */
}

/* Related Products in tabs - remove section wrapper styling */
.product-tab-ajax-content .product-relations-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.product-tab-ajax-content .product-relations-title {
    display: none; /* Title is in the tab */
}

/* Skeleton loader styles for tabs */
.tab-content-skeleton {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

/* Technical features skeleton in tabs */
.tab-content-skeleton.technical-features-skeleton .skeleton-row {
    display: flex;
    padding: 10px 15px;
    border-bottom: 1px solid #e8e8e8;
}

.tab-content-skeleton.technical-features-skeleton .skeleton-row:last-child {
    border-bottom: none;
}

.tab-content-skeleton.technical-features-skeleton .skeleton-cell {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tab-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.tab-content-skeleton.technical-features-skeleton .skeleton-cell:first-child {
    width: 40%;
    margin-right: 10%;
}

.tab-content-skeleton.technical-features-skeleton .skeleton-cell:last-child {
    width: 35%;
}

/* Relations skeleton in tabs */
.tab-content-skeleton.product-relations-skeleton {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    background: transparent;
    border: none;
}

.tab-content-skeleton .relation-group-skeleton {
    flex: 1 1 300px;
    min-width: 300px;
    max-width: calc(33.333% - 14px);
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.tab-content-skeleton .skeleton-type-title {
    height: 20px;
    margin: 12px 15px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tab-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
    width: 60%;
}

.tab-content-skeleton .skeleton-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 15px;
    border-top: 1px solid #e8e8e8;
}

.tab-content-skeleton .skeleton-image {
    width: 50px;
    height: 50px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tab-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.tab-content-skeleton .skeleton-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tab-content-skeleton .skeleton-name {
    height: 14px;
    width: 80%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tab-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.tab-content-skeleton .skeleton-price {
    height: 14px;
    width: 40%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tab-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.tab-content-skeleton .skeleton-button {
    width: 36px;
    height: 36px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: tab-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes tab-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (max-width: 768px) {
    .tab-content-skeleton .relation-group-skeleton {
        min-width: 100%;
        max-width: 100%;
    }
}

/* ==========================================================================
   Technical Features
   ========================================================================== */

.product-technical-features-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid #e0e0e0;
}

.product-technical-features-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

.technical-feature-group {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.technical-feature-table {
    width: 100%;
    border-collapse: collapse;
}

.technical-feature-table tbody tr {
    border-bottom: 1px solid #e8e8e8;
}

.technical-feature-table tbody tr:last-child {
    border-bottom: none;
}

.technical-feature-table tbody tr:hover {
    background: #f9f9f9;
}

.technical-feature-table td {
    padding: 10px 15px;
    font-size: 14px;
    vertical-align: top;
}

.technical-feature-table .feature-parts {
    color: #666;
    width: 50%;
}

.technical-feature-table .feature-value {
    color: #333;
    font-weight: 500;
    width: 50%;
}

@media (max-width: 768px) {
    .technical-feature-table td {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Technical features standalone skeleton */
.technical-features-skeleton {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.technical-features-skeleton .skeleton-row {
    display: flex;
    padding: 10px 15px;
    border-bottom: 1px solid #e8e8e8;
}

.technical-features-skeleton .skeleton-row:last-child {
    border-bottom: none;
}

.technical-features-skeleton .skeleton-cell {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
    width: 50%;
}

.technical-features-skeleton .skeleton-cell:first-child {
    width: 40%;
    margin-right: 10%;
}

.technical-features-skeleton .skeleton-cell:last-child {
    width: 35%;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   Product Relations
   ========================================================================== */

.product-relations-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid #e0e0e0;
}

.product-relations-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #333;
}

.product-relations-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.relation-group {
    flex: 1 1 300px;
    min-width: 300px;
    max-width: calc(33.333% - 14px);
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.relation-type-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin: 0;
    padding: 12px 15px;
    background: #f8f8f8;
    border-bottom: 2px solid #3d7b80;
}

.relation-items {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: #e8e8e8;
    max-height: 300px;
    overflow-y: auto;
}

.relation-item {
    display: grid;
    grid-template-columns: 60px 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 15px;
    background: white;
    transition: background-color 0.2s ease;
}

.relation-item:hover {
    background: #f9f9f9;
}

.relation-item-image {
    width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.relation-item-image p {
    display: none;
}

.relation-item-image img {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    background: #f5f5f5;
    object-fit: contain;
}

.relation-item-image .relation-item-sku {
    font-size: 14px;
    text-align: center;
    line-height: 1.2;
    margin-top: 6px;
}

.relation-item-image .relation-item-sku a {
    color: #666;
    text-decoration: none;
}

.relation-item-image .relation-item-sku a:hover {
    color: var(--wp--preset--color--primary, #22424f);
}

.relation-item-info {
    min-width: 0;
}

.relation-item-name a {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    display: block;
    line-height: 1.4;
}

.relation-item-name a:hover {
    color: var(--wp--preset--color--primary, #22424f);
}

.relation-item-quantity {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.relation-item-price {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.relation-item-actions {
    text-align: center;
    min-width: 70px;
}

.relation-item-actions .family-add-to-cart-btn .btn-qty {
    position: absolute;
    right: 2px;
    bottom: 2px;
}

.relation-item-actions .family-add-to-cart-btn .btn-qty {
    color: white;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.out-of-stock-label {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* Compact quantity controller for relation items */
.relation-item .qty-controller {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px;
    background: white;
}

.relation-item .qty-controller.updating {
    opacity: 0.6;
    pointer-events: none;
}

.relation-item .qty-controller .qty-minus,
.relation-item .qty-controller .qty-plus {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #666;
    font-size: 12px;
    line-height: 1;
    padding: 0;
}

.relation-item .qty-controller .qty-minus:hover,
.relation-item .qty-controller .qty-plus:hover {
    background: #e5e5e5;
    border-color: #bbb;
}

.relation-item .qty-controller .qty-input {
    width: 28px;
    height: 20px;
    border: none;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: #333;
    padding: 0;
    background: transparent;
    -moz-appearance: textfield;
}

.relation-item .qty-controller .qty-input::-webkit-outer-spin-button,
.relation-item .qty-controller .qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Relations responsive */
@media (max-width: 768px) {
    .product-relations-groups {
        flex-direction: column;
    }

    .relation-group {
        min-width: 100%;
    }

    .relation-item {
        grid-template-columns: 50px 1fr;
        gap: 10px;
    }

    .relation-item-image {
        width: 50px;
    }

    .relation-item-image img {
        width: 40px;
        height: 40px;
    }

    .relation-item-image .relation-item-sku {
        font-size: 12px;
    }

    .relation-item-price {
        grid-column: 2;
        text-align: left;
    }

    .relation-item-actions {
        grid-column: 2;
        text-align: left;
    }
}

/* Relations standalone skeleton */
.product-relations-skeleton {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.relation-group-skeleton {
    flex: 1 1 300px;
    min-width: 300px;
    max-width: calc(33.333% - 14px);
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.relation-group-skeleton .skeleton-type-title {
    height: 20px;
    margin: 12px 15px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: relations-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
    width: 60%;
}

.relation-group-skeleton .skeleton-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 15px;
    border-top: 1px solid #e8e8e8;
}

.relation-group-skeleton .skeleton-image {
    width: 50px;
    height: 50px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: relations-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.relation-group-skeleton .skeleton-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.relation-group-skeleton .skeleton-name {
    height: 14px;
    width: 80%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: relations-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.relation-group-skeleton .skeleton-price {
    height: 14px;
    width: 40%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: relations-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

.relation-group-skeleton .skeleton-button {
    width: 36px;
    height: 36px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: relations-skeleton-shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes relations-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (max-width: 768px) {
    .relation-group-skeleton {
        min-width: 100%;
        max-width: 100%;
    }
}

/* ==========================================================================
   Single Product — Visual Redesign
   ========================================================================== */

/* Product info card (right column) */
.single-product .wp-block-columns.alignwide > .wp-block-column:last-child {
    background: #f5f5f5;
    border-radius: 12px;
    padding: 30px;
}

/* Product title — larger in the right column */
.single-product .wp-block-columns.alignwide > .wp-block-column:last-child h1 {
    font-size: 1.75rem;
    line-height: 1.3;
}

/* Tab content card wrapper */
.woocommerce-Tabs-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 25px;
}

/* ---------- Product info 2x2 grid (SKU, Barcode, Subcategory, Packaging) ---------- */

.product-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
}

/* ---------- Barcode + supplier logo 1x2 grid ---------- */

.product-barcode-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 1.5rem;
}

.product-barcode-container > * {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

/* ---------- Price + availability on same row, white card ---------- */

.product-price-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    background: #fff;
    border-radius: 8px;
}

/* Price prominence */
.product-price-row .wp-block-woocommerce-product-price {
    font-size: 1.75rem !important;
    font-weight: 700;
    line-height: 1;
    color: var(--wp--preset--color--dark, #222);
}

/* Hide the duplicate stock inside the add-to-cart form */
.single-product .wp-block-woocommerce-add-to-cart-form > p.stock {
    display: none;
}

/* ---------- Availability badge ---------- */

.single-product .stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    margin: 0;
}

.single-product .stock.stock-green {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.single-product .stock.stock-green::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    flex-shrink: 0;
}

.single-product .stock.stock-yellow {
    background: rgba(255, 193, 7, 0.1);
    color: #d4a005;
}

.single-product .stock.stock-yellow::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #ffc107;
    border-radius: 50%;
    flex-shrink: 0;
}

.single-product .stock.stock-red {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.single-product .stock.stock-red::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ---------- Cart form layout — quantity + button + heart on one row ---------- */

.single-product .wp-block-add-to-cart-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.single-product form.cart {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    padding: 0;
}

.single-product form.cart .single_add_to_cart_button {
    background-color: #22424f !important;
}

.single-product form.cart .single_add_to_cart_button:hover {
    background-color: #1a343e !important;
}

/* ---------- Quantity input with +/- buttons ---------- */

.single-product .quantity {
    display: flex;
    align-items: center;
}

.single-product .quantity .minus,
.single-product .quantity .plus {
    background: #22424f;
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.single-product .quantity .minus {
    border-radius: 4px 0 0 4px;
}

.single-product .quantity .plus {
    border-radius: 0 4px 4px 0;
}

.single-product .quantity .minus:hover,
.single-product .quantity .plus:hover {
    background: #1a343e;
}

.single-product .quantity .qty {
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    border-radius: 0;
    padding: 8px 4px;
    margin: 0 !important;
    text-align: center;
    font-size: 15px;
    width: 60px;
    height: 42px;
    box-sizing: border-box;
    -moz-appearance: textfield;
}

.single-product .quantity .qty::-webkit-outer-spin-button,
.single-product .quantity .qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---------- Product info responsive ---------- */

@media (max-width: 768px) {
    .single-product .wp-block-columns.alignwide > .wp-block-column:last-child {
        padding: 20px;
    }

    .product-info-grid {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .product-barcode-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1rem;
    }

    .product-price-row {
        padding: 0.75rem 1rem;
        margin: 1rem 0;
    }

    .product-price-row .wp-block-woocommerce-product-price {
        font-size: 1.5rem !important;
    }
}

/* ---------- Product info — small mobile ---------- */

@media (max-width: 480px) {
    /* Smaller title on narrow screens */
    .single-product .wp-block-columns.alignwide > .wp-block-column:last-child h1 {
        font-size: 1.25rem;
    }

    /* Stack quantity + add-to-cart vertically */
    .single-product form.cart {
        flex-wrap: wrap;
        width: 100%;
    }

    .single-product form.cart .single_add_to_cart_button {
        width: 100%;
    }

    .single-product .wp-block-add-to-cart-form {
        width: 100%;
    }

    .single-product .wp-block-columns.alignwide > .wp-block-column:last-child {
        padding: 15px;
    }
}
