/**
 * CSS CHO TRANG CHI TIẾT SẢN PHẨM (SINGLE PRODUCT)
 * UPDATED: Tối ưu cột Đặt hàng cho YITH Request a Quote
 * Compatible with: LuanLT Sapo Sync v3.1.0
 */

/* ==========================================================================
   1. HEADER SẢN PHẨM (Tên + Badge Tồn kho)
   ========================================================================== */
.custom-sf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #d26e4b;
}

.custom-sf-header h1.product_title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
}

.custom-sf-header .header-stock {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    padding: 8px 15px;
    border-radius: 20px;
}

.custom-sf-header .header-stock.in-stock {
    background: #e8f5e9;
    color: #2e7d32;
}

.custom-sf-header .header-stock.out-of-stock {
    background: #ffebee;
    color: #c62828;
}

.custom-sf-header .header-stock strong {
    color: #d26e4b;
    font-size: 18px;
}

/* ==========================================================================
   2. BẢNG CHI TIẾT SẢN PHẨM (DESKTOP VIEW)
   ========================================================================== */
.sf-table-wrapper {
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.sf-pro-table {
    width: 100%;
    border-collapse: collapse;
}

.sf-pro-table thead {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: #fff;
}

.sf-pro-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Định nghĩa độ rộng cột */
.sf-pro-table .th-image {
    width: 80px;
}

.sf-pro-table .th-model {
    width: 100px;
}

.sf-pro-table .th-sku {
    width: 100px;
}

.sf-pro-table .th-info {
    width: auto;
}

.sf-pro-table .th-stock {
    width: 180px;
}

.sf-pro-table .th-action {
    width: 130px;
    text-align: center;
}

.sf-pro-table td {
    padding: 15px;
    vertical-align: middle;
    border-bottom: 1px solid #eee;
    color: #333;
}

.sf-pro-table tbody tr:last-child td {
    border-bottom: none;
}

.sf-pro-table tbody tr:hover {
    background-color: #f8f9fa;
}

.sf-pro-table tbody tr.out-of-stock {
    background-color: #fff5f5;
}

/* Cột Ảnh */
.sf-pro-table .t-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #eee;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.sf-pro-table .t-img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Cột Model */
.sf-pro-table .td-model {
    font-weight: 600;
    color: #2c3e50;
}

/* Cột SKU */
.sf-pro-table .td-sku code {
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
}

/* Cột Thông tin */
.product-info-wrapper .product-title {
    font-size: 15px;
    color: #2c3e50;
    display: block;
    margin-bottom: 5px;
}

.product-info-wrapper .variation-description {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #d26e4b;
}

/* === CỘT TỒN KHO === */
.sapo-total-row {
    font-size: 14px;
    padding: 6px 10px;
    background: #e3f2fd;
    border-radius: 4px;
    margin-bottom: 8px;
    text-align: center;
}

.sapo-total-row .total-qty {
    color: #d26e4b;
    font-weight: 700;
    font-size: 16px;
}

.sapo-stock-list {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 12px;
}

.sapo-stock-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    margin-bottom: 3px;
    border-radius: 4px;
    background: #f9f9f9;
}

.sapo-stock-list li:last-child {
    margin-bottom: 0;
}

.sapo-stock-list li.in {
    background: #e8f5e9;
}

.sapo-stock-list li.out {
    background: #ffebee;
}

.sapo-stock-list .loc-name {
    color: #555;
}

.sapo-stock-list .loc-qty {
    font-weight: 700;
}

.sapo-stock-list li.in .loc-qty {
    color: #2e7d32;
}

.sapo-stock-list li.out .loc-qty {
    color: #c62828;
}

/* === CỘT ĐẶT HÀNG (YITH REQUEST A QUOTE) === */
.sf-pro-table .t-action {
    text-align: center;
    vertical-align: middle;
}

.action-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.quote-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.quote-form .qty-row {
    width: 100%;
    display: flex;
    justify-content: center;
}

.quote-form .qty-row .quantity {
    margin: 0 !important;
}

.quote-form .qty-row .qty,
.quote-form .qty-row input.qty {
    width: 60px !important;
    height: 36px !important;
    padding: 6px !important;
    text-align: center !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    margin: 0 !important;
}

.quote-form .btn-row {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* YITH Button Styles */
.quote-form .btn-row .yith-ywraq-add-button,
.quote-form .btn-row .add-request-quote-button,
.quote-form .btn-row button.yith-ywraq-add-button,
.quote-form .btn-row a.add-request-quote-button,
.quote-form .btn-row .button,
.quote-form .quote-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    min-width: 100px !important;
    height: auto !important;
    min-height: 25px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    text-align: center !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    border-radius: 4px !important;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
}

.quote-form .btn-row .yith-ywraq-add-button:hover,
.quote-form .btn-row .add-request-quote-button:hover,
.quote-form .btn-row button.yith-ywraq-add-button:hover,
.quote-form .btn-row a.add-request-quote-button:hover,
.quote-form .btn-row .button:hover,
.quote-form .quote-btn:hover {
    background: linear-gradient(135deg, #2980b9 0%, #1a5276 100%) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.4) !important;
}

.yith_ywraq_add_item_browse-list-1620.yith_ywraq_add_item_browse_message.show.hide-when-removed {
    background: green;
}

/* Hide YITH default wrapper elements */

.quote-form .btn-row .clear,
.quote-form .btn-row br {
    display: none !important;
}

/* Contact button for out of stock */
.contact-btn {
    display: inline-block !important;
    padding: 10px 15px !important;
    background: #f39c12 !important;
    color: #fff !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    text-decoration: none !important;
    text-align: center !important;
    transition: all 0.2s ease !important;
}

.contact-btn:hover {
    background: #e67e22 !important;
    color: #fff !important;
}

/* ==========================================================================
   3. MOBILE CARD VIEW
   ========================================================================== */
.sf-mobile-wrapper {
    padding: 10px;
}

.mobile-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.mobile-card-header {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.mobile-card-img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    cursor: pointer;
}

.mobile-card-info {
    flex-grow: 1;
}

.mobile-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
}

.mobile-card-desc {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mobile-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11px;
}

.mobile-meta-badge {
    background: #f5f5f5;
    padding: 3px 8px;
    border-radius: 4px;
    color: #666;
}

.mobile-meta-badge.phan-loai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.mobile-meta-badge strong {
    color: inherit;
}

/* Mobile Stock Section */
.mobile-stock-section {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.mobile-stock-section .sapo-total-row {
    margin-bottom: 10px;
}

.mobile-stock-section .sapo-stock-list li {
    padding: 6px 10px;
}

/* Mobile Action */
.mobile-action-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* === MOBILE QUOTE FORM (YITH REQUEST A QUOTE) === */
.mobile-quote-form {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.mobile-quote-form .mobile-qty-row {
    flex-shrink: 0;
}

.mobile-quote-form .mobile-qty-row .quantity {
    margin: 0 !important;
}

.mobile-quote-form .mobile-qty-row .qty,
.mobile-quote-form .mobile-qty-row input.qty {
    width: 70px !important;
    height: 44px !important;
    padding: 8px !important;
    text-align: center !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    font-size: 16px !important;
    margin: 0 !important;
}

.mobile-quote-form .mobile-btn-row {
    flex-grow: 1;
    display: flex;
}

/* Mobile YITH Button Styles */
.mobile-quote-form .mobile-btn-row .yith-ywraq-add-button,
.mobile-quote-form .mobile-btn-row .add-request-quote-button,
.mobile-quote-form .mobile-btn-row button.yith-ywraq-add-button,
.mobile-quote-form .mobile-btn-row a.add-request-quote-button,
.mobile-quote-form .mobile-btn-row .button,
.mobile-quote-form .mobile-quote-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    padding: 12px 15px !important;
    min-height: 44px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    text-align: center !important;
    white-space: nowrap !important;
    border-radius: 6px !important;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
}

.mobile-quote-form .mobile-btn-row .yith-ywraq-add-button:hover,
.mobile-quote-form .mobile-btn-row .add-request-quote-button:hover,
.mobile-quote-form .mobile-btn-row .button:hover,
.mobile-quote-form .mobile-quote-btn:hover {
    background: linear-gradient(135deg, #2980b9 0%, #1a5276 100%) !important;
}

/* Hide YITH default wrapper elements on mobile */
.mobile-quote-form .mobile-btn-row .yith-ywraq-add-to-quote,
.mobile-quote-form .mobile-btn-row .yith_ywraq_add_item_product {
    display: contents !important;
    width: 100% !important;
}

.mobile-quote-form .mobile-btn-row .clear,
.mobile-quote-form .mobile-btn-row br {
    display: none !important;
}

/* Mobile Contact Button */
.mobile-contact-btn {
    display: block !important;
    width: 100% !important;
    padding: 14px 20px !important;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%) !important;
    color: #fff !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    text-align: center !important;
    transition: all 0.2s ease !important;
}

.mobile-contact-btn:hover {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%) !important;
    color: #fff !important;
}

/* ==========================================================================
   4. GALLERY GRID
   ========================================================================== */
.product-gallery-grid {
    margin-top: 30px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.product-gallery-grid h3 {
    font-size: 18px;
    margin: 0 0 15px 0;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.gallery-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.gallery-grid-item {
    aspect-ratio: 1/1;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #eee;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-grid-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
    border-color: #d26e4b;
}

.gallery-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================================================
   5. MEDIA QUERIES
   ========================================================================== */
@media (max-width: 1024px) {

    .sf-pro-table .th-info,
    .sf-pro-table .td-info {
        display: none;
    }
}

@media (max-width: 768px) {
    .custom-sf-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .custom-sf-header .header-stock {
        width: 100%;
        text-align: center;
    }

    .gallery-grid-wrapper {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==========================================================================
   6. B2B SPECIFIC STYLES
   ========================================================================== */

/* Zebra striping cho dễ đọc */
.sf-pro-table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.sf-pro-table tbody tr:nth-child(even):hover {
    background-color: #f0f0f0;
}

/* Sticky header cho bảng dài */
@media (min-width: 769px) {
    .sf-table-wrapper {
        overflow-y: auto;
    }

    .sf-pro-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }
}

/* Print styles cho B2B */
@media print {
    .sf-pro-table thead {
        background: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .mobile-product-card,
    .gallery-grid-wrapper,
    .quote-form {
        page-break-inside: avoid;
    }
}