/**
 * Cross-Sells - Compact Production Styles
 * 
 * Features:
 * - More compact spacing (reduced padding)
 * - Responsive accordion (mobile/tablet)
 * - Main product distinct styling
 * - Full width table layout
 * - Smooth animations
 * - SKU-optimized display
 * - Top and bottom Add to Cart buttons
 * 
 * Place this file in: /wp-content/themes/1800doorbell/assets/css/cross-sells.css
 * 
 * Version: 3.2.1 - Fixed Mobile Accordion Toggle
 */

/* ================================================
   WRAPPER & CONTAINER
   ================================================ */

.cross-sells-wrapper {
    margin: 30px auto;
    padding: 0 15px;
    clear: both;
    max-width: 1200px;
    width: 100%;
}

/* ================================================
   ACCORDION TOGGLE (Mobile/Tablet Only)
   ================================================ */

.cross-sells-toggle {
    display: none; /* Hidden on desktop */
    background: linear-gradient(135deg, #14365D 0%, #1a4470 100%);
    border-radius: 8px;
    padding: 15px 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 12px;
}

.cross-sells-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cross-sells-toggle:active {
    transform: translateY(0);
}

.cross-sells-heading-mobile {
    margin: 0 0 8px 0;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.items-badge {
    background: rgba(232, 93, 4, 0.9);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.toggle-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.95rem;
    transition: opacity 0.3s ease;
}

.toggle-button:hover {
    opacity: 0.9;
}

.toggle-text {
    font-size: 0.9rem;
    opacity: 0.9;
}

.toggle-icon {
    font-size: 1.1rem;
    transition: transform 0.3s ease;
    margin-left: 10px;
}

.cross-sells-toggle[data-state="expanded"] .toggle-icon {
    transform: rotate(180deg);
}

.cross-sells-toggle[data-state="expanded"] .toggle-text::after {
    content: ' to hide';
}

/* ================================================
   CONTAINER (Collapsible on Mobile/Tablet)
   ================================================ */

.cross-sells-container {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

/* Desktop Heading (Always Visible on Desktop) */
.cross-sells-heading-desktop {
    font-size: 1.2rem;
    color: #14365D;
    margin: 0;
    padding: 15px 15px 12px;
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
    display: block; /* Visible on desktop */
}

/* ================================================
   TABLE
   ================================================ */

.cross-sells-table {
    /* No extra styling needed - rows handle layout */
}

/* ================================================
   PRODUCT ROWS (MORE COMPACT)
   ================================================ */

.cross-sell-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    gap: 12px;
}

.cross-sell-row:last-of-type {
    border-bottom: 2px solid #e0e0e0;
}

.cross-sell-row:hover {
    background-color: #fafafa;
}

.cross-sell-row.out-of-stock {
    opacity: 0.6;
    background-color: #f9f9f9;
}

/* ================================================
   MAIN PRODUCT ROW (Distinct Styling)
   ================================================ */

.main-product-row {
    background: linear-gradient(to right, #fffbf5, #ffffff);
    border-bottom: 2px solid #E85D04 !important;
    position: relative;
}

.main-product-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #E85D04;
}

.main-product-row:hover {
    background: linear-gradient(to right, #fff8f0, #fafafa);
}

.main-product-badge {
    display: inline-block;
    background: #E85D04;
    color: white;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cross-sell-product-name {
    display: inline-flex;
    align-items: center;
    color: #14365D;
}

/* ================================================
   COLUMNS (COMPACT SIZING)
   ================================================ */

.cross-sell-checkbox-col {
    flex: 0 0 auto;
    width: 22px;
}

.cross-sell-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    accent-color: #E85D04;
}

.cross-sell-checkbox:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.cross-sell-thumb-col {
    flex: 0 0 auto;
    width: 50px;
}

.cross-sell-thumb-col a {
    display: block;
    line-height: 0;
}

.cross-sell-thumb-col img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.cross-sell-name-col {
    flex: 1 1 auto;
    min-width: 0;
}

.cross-sell-product-link {
    color: #14365D;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.3;
    display: block;
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.cross-sell-product-link:hover {
    color: #E85D04;
}

.cross-sell-variation-select {
    margin-top: 6px;
}

.variation-select {
    width: 100%;
    max-width: 220px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.variation-select:focus {
    outline: none;
    border-color: #E85D04;
    box-shadow: 0 0 0 1px rgba(232, 93, 4, 0.2);
}

.out-of-stock-text {
    display: inline-block;
    color: #ff4444;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 4px;
}

.cross-sell-qty-col {
    flex: 0 0 auto;
    width: 70px;
    text-align: center;
}

.cross-sell-qty {
    width: 55px;
    padding: 5px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
    transition: border-color 0.3s ease;
}

.cross-sell-qty:focus {
    outline: none;
    border-color: #E85D04;
    box-shadow: 0 0 0 1px rgba(232, 93, 4, 0.2);
}

.cross-sell-qty:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.6;
}

.cross-sell-qty::-webkit-inner-spin-button,
.cross-sell-qty::-webkit-outer-spin-button {
    opacity: 1;
}

.cross-sell-price-col {
    flex: 0 0 auto;
    text-align: right;
    min-width: 75px;
}

.price-amount {
    color: #E85D04;
    font-weight: bold;
    font-size: 1.05rem;
    white-space: nowrap;
}

.price-amount .woocommerce-Price-amount {
    color: #E85D04;
}

/* ================================================
   SUMMARY & ADD TO CART (COMPACT)
   ================================================ */

.cross-sell-add-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 12px;
    background: #fafafa;
    border-top: 2px solid #e0e0e0;
    gap: 15px;
    flex-wrap: wrap;
}

/* Top button row - border on bottom instead of top */
.cross-sell-add-row-top {
    border-top: none;
    border-bottom: 2px solid #e0e0e0;
}

/* Bottom button row - no additional styles needed, inherits from base */
.cross-sell-add-row-bottom {
    border-top: 2px solid #e0e0e0;
}

.cross-sell-summary {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    flex: 1;
}

.selected-summary,
.total-price-summary {
    font-size: 0.95rem;
    color: #14365D;
    font-weight: 500;
}

.selected-count {
    font-weight: bold;
    color: #E85D04;
    font-size: 1.15rem;
}

.total-amount {
    color: #E85D04;
    font-size: 1.25rem;
}

.cross-sell-add-button {
    background: #E85D04 !important;
    color: white !important;
    padding: 10px 28px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    white-space: nowrap;
    min-width: 190px;
}

.cross-sell-add-button:not(:disabled):hover {
    background: #d64000 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(232, 93, 4, 0.3) !important;
}

.cross-sell-add-button:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    transform: none !important;
}

.loading-spinner {
    display: inline-block;
}

.spinner {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================================================
   NO ACCESSORIES MESSAGE
   ================================================ */

.no-accessories-message {
    padding: 35px 20px;
    text-align: center;
    color: #666;
}

.no-accessories-message p {
    margin: 0;
    font-size: 0.95rem;
}

/* ================================================
   RESPONSIVE - TABLET (768px - 1023px)
   ================================================ */

@media (max-width: 1023px) {
    /* Show accordion toggle */
    .cross-sells-toggle {
        display: block;
    }
    
    /* Hide desktop heading */
    .cross-sells-heading-desktop {
        display: none;
    }
    
    /* Container starts collapsed */
    .cross-sells-container[aria-hidden="true"] {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        transition: max-height 0.4s ease, opacity 0.3s ease;
    }
    
    /* Container expanded */
    .cross-sells-container[aria-hidden="false"] {
        max-height: 5000px;
        opacity: 1;
        transition: max-height 0.4s ease, opacity 0.3s ease;
    }
}

/* ================================================
   RESPONSIVE - MOBILE (≤767px)
   ================================================ */

@media (max-width: 767px) {
    .cross-sells-wrapper {
        padding: 0 12px;
    }
    
    .cross-sells-toggle {
        padding: 12px 15px;
    }
    
    .cross-sells-heading-mobile {
        font-size: 1.1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .cross-sell-row {
        padding: 8px 10px;
        gap: 8px;
    }
    
    .cross-sell-thumb-col {
        width: 45px;
    }
    
    .cross-sell-thumb-col img {
        width: 45px;
        height: 45px;
    }
    
    .cross-sell-product-link,
    .cross-sell-product-name {
        font-size: 0.9rem;
    }
    
    .main-product-badge {
        font-size: 0.65rem;
        padding: 2px 5px;
    }
    
    .variation-select {
        max-width: 100%;
        font-size: 0.8rem;
    }
    
    .cross-sell-add-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 10px;
    }
    
    .cross-sell-summary {
        justify-content: space-between;
        width: 100%;
        gap: 12px;
    }
    
    .cross-sell-add-button {
        width: 100%;
    }
}

/* ================================================
   RESPONSIVE - SMALL MOBILE (≤480px)
   ================================================ */

@media (max-width: 480px) {
    .cross-sell-row {
        flex-wrap: wrap;
        padding: 8px;
    }
    
    .cross-sell-checkbox-col {
        order: 1;
    }
    
    .cross-sell-thumb-col {
        order: 2;
        width: 45px;
    }
    
    .cross-sell-qty-col {
        order: 3;
        width: 55px;
    }
    
    .cross-sell-price-col {
        order: 4;
        margin-left: auto;
    }
    
    .cross-sell-name-col {
        order: 5;
        flex: 1 1 100%;
        margin-top: 8px;
    }
    
    .cross-sell-product-link,
    .cross-sell-product-name {
        font-size: 0.85rem;
    }
    
    .price-amount {
        font-size: 0.95rem;
    }
    
    .cross-sell-summary {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .selected-count {
        font-size: 1.05rem;
    }
    
    .total-amount {
        font-size: 1.15rem;
    }
}

/* ================================================
   DESKTOP - ALWAYS EXPANDED (≥1024px)
   ================================================ */

@media (min-width: 1024px) {
    /* Force container to always be visible on desktop */
    .cross-sells-container {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }
    
    .cross-sells-container[aria-hidden="true"] {
        display: block !important;
    }
}