/**
 * FBT Frontend Styles
 * Multiple style variations: amazon, minimal, cards, list, theme
 */

/* ========================================
   CSS Variables
======================================== */
:root {
    --fbt-primary-color: #ff9900;
    --fbt-secondary-color: #232f3e;
    --fbt-border-color: #ddd;
    --fbt-bg-color: #fff;
    --fbt-text-color: #333;
    --fbt-text-muted: #666;
    --fbt-success-color: #4CAF50;
    --fbt-error-color: #f44336;
}

/* ========================================
   Base Styles (applies to all)
======================================== */
.fbt-container {
    margin: 30px 0;
    padding: 20px;
    background: var(--fbt-bg-color);
    border-radius: 8px;
}

.fbt-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: var(--fbt-secondary-color);
}

.fbt-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
}

.fbt-products {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.fbt-product-card {
    position: relative;
    text-align: center;
    flex: 0 0 auto;
    min-width: 120px;
    max-width: 150px;
}

.fbt-product-image {
    margin-bottom: 3px;
}

.fbt-product-image img {
    max-width: 100px;
    height: auto;
    border-radius: 4px;
}

.fbt-product-info {
    line-height: 1.2;
}

.fbt-product-title {
    font-size: 13px;
    font-weight: 400;
    margin: 0;
    line-height: 1.2;
}

.fbt-product-title a {
    color: #0066c0;
    text-decoration: none;
}

.fbt-product-title a:hover {
    color: #c45500;
    text-decoration: underline;
}

.fbt-this-item {
    display: block;
    font-weight: 700;
    font-size: 12px;
    margin-bottom: 0;
}

.fbt-product-price {
    font-size: 14px;
    color: var(--fbt-text-color);
    margin: 0;
    padding: 0;
}

.fbt-product-price .woocommerce-Price-amount,
.fbt-product-price .amount {
    margin: 0;
    padding: 0;
}

.fbt-product-price del,
.fbt-product-price ins {
    display: inline;
    margin: 0;
    text-decoration: inherit;
}

.fbt-product-price del {
    color: #999;
    font-size: 12px;
    margin-left: 3px;
}

.fbt-product-price ins {
    text-decoration: none;
}

.fbt-product-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 12px;
    margin-top: 5px;
}

.fbt-product-rating .star-rating {
    font-size: 12px;
}

.fbt-review-count {
    color: #0066c0;
}

/* Checkbox Styles */
.fbt-checkbox-wrapper {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 10;
}

.fbt-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.fbt-checkmark {
    position: absolute;
    top: 0;
    right: 0;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 2px solid #007185;
    border-radius: 3px;
    pointer-events: none;
}

.fbt-checkbox:checked + .fbt-checkmark {
    background: #007185;
}

.fbt-checkbox:checked + .fbt-checkmark::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Totals Section */
.fbt-totals-section {
    flex: 0 0 auto;
    min-width: 180px;
    text-align: center;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
}

.fbt-totals {
    margin-bottom: 15px;
}

.fbt-total-price {
    font-size: 18px;
    margin-bottom: 5px;
}

.fbt-total-label {
    color: var(--fbt-text-muted);
    margin-right: 5px;
}

.fbt-total-amount {
    font-weight: 700;
    color: #B12704;
}

.fbt-savings {
    color: var(--fbt-success-color);
    font-size: 14px;
}

.fbt-discount-percent {
    font-size: 12px;
}

/* Add to Cart Button */
.fbt-add-to-cart-btn {
    background: linear-gradient(to bottom, #f7dfa5, #f0c14b);
    border: 1px solid #a88734;
    border-radius: 20px;
    padding: 10px 25px;
    font-size: 14px;
    color: #111;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 0 rgba(255,255,255,.4) inset;
    transition: all 0.2s;
}

.fbt-add-to-cart-btn:hover {
    background: linear-gradient(to bottom, #f5d78e, #eeb933);
}

.fbt-add-to-cart-btn:active {
    box-shadow: 0 1px 3px rgba(0,0,0,.2) inset;
}

.fbt-add-to-cart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading Spinner */
.fbt-loading {
    display: inline-flex;
    align-items: center;
    margin-left: 10px;
}

.fbt-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: var(--fbt-primary-color);
    border-radius: 50%;
    animation: fbt-spin 0.8s linear infinite;
}

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

/* Message */
.fbt-message {
    margin-top: 10px;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.fbt-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.fbt-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ========================================
   Amazon Style
======================================== */
.fbt-style-amazon {
    border: 1px solid #ddd;
    padding: 20px;
}

.fbt-style-amazon .fbt-products {
    align-items: center;
}

.fbt-style-amazon .fbt-product-card {
    background: #fff;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 4px;
    min-width: 120px;
    max-width: 150px;
}

.fbt-style-amazon .fbt-product-image img {
    max-width: 90px;
}

.fbt-style-amazon .fbt-product-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Plus Sign */
.fbt-plus-sign {
    font-size: 24px;
    font-weight: 300;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

/* ========================================
   Minimal Style
======================================== */
.fbt-style-minimal {
    background: transparent;
    padding: 20px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.fbt-style-minimal .fbt-product-card {
    padding: 10px;
    min-width: 100px;
    max-width: 130px;
}

.fbt-style-minimal .fbt-product-image img {
    max-width: 80px;
}

.fbt-style-minimal .fbt-add-to-cart-btn {
    background: var(--fbt-primary-color);
    border-color: var(--fbt-primary-color);
    color: #fff;
    border-radius: 4px;
}

.fbt-style-minimal .fbt-add-to-cart-btn:hover {
    background: #e68a00;
}

/* ========================================
   Cards Style
======================================== */
.fbt-style-cards .fbt-products {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 15px;
}

.fbt-style-cards .fbt-plus-sign {
    display: none;
}

.fbt-style-cards .fbt-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 140px;
    max-width: 180px;
}

.fbt-style-cards .fbt-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.fbt-style-cards .fbt-product-image img {
    max-width: 100%;
    height: auto;
}

.fbt-style-cards .fbt-checkbox-wrapper {
    position: relative;
    top: auto;
    right: auto;
    margin-bottom: 10px;
}

/* ========================================
   List Style
======================================== */
.fbt-style-list .fbt-products {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
}

.fbt-style-list .fbt-plus-sign {
    display: flex;
}

.fbt-style-list .fbt-product-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 6px;
    min-width: 120px;
    max-width: 150px;
}

.fbt-style-list .fbt-checkbox-wrapper {
    position: relative;
    top: auto;
    right: auto;
    margin-bottom: 8px;
}

.fbt-style-list .fbt-product-image {
    margin-bottom: 8px;
}

.fbt-style-list .fbt-product-image img {
    max-width: 80px;
}

.fbt-style-list .fbt-product-info {
    flex: 1;
}

.fbt-style-list .fbt-product-title {
    font-size: 13px;
}

.fbt-style-list .fbt-product-rating {
    justify-content: center;
}

/* ========================================
   Theme Style (Inherits)
======================================== */
.fbt-style-theme {
    background: transparent;
    padding: 0;
}

.fbt-style-theme .fbt-product-card {
    padding: 10px;
    min-width: 100px;
    max-width: 140px;
}

.fbt-style-theme .fbt-add-to-cart-btn {
    background: var(--fbt-primary-color);
    border: none;
    border-radius: 4px;
    color: #fff;
}

/* ========================================
   Responsive
======================================== */
@media (max-width: 768px) {
    .fbt-container {
        padding: 15px;
    }

    .fbt-title {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .fbt-wrapper {
        flex-direction: column;
        gap: 15px;
    }

    .fbt-products {
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .fbt-product-card {
        min-width: 90px !important;
        max-width: 100px !important;
        padding: 8px !important;
    }

    .fbt-product-image img {
        max-width: 70px !important;
    }

    .fbt-product-title {
        font-size: 11px !important;
        line-height: 1.3;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .fbt-this-item {
        font-size: 9px !important;
    }

    .fbt-product-price {
        font-size: 11px !important;
    }

    .fbt-product-rating {
        display: none;
    }

    .fbt-plus-sign {
        font-size: 16px;
        padding: 0 2px;
    }

    .fbt-checkbox-wrapper {
        top: 3px;
        right: 3px;
    }

    .fbt-checkbox {
        width: 16px;
        height: 16px;
    }

    .fbt-checkmark {
        width: 18px;
        height: 18px;
    }

    .fbt-totals-section {
        width: 100%;
    }

    .fbt-total-price {
        font-size: 15px;
    }

    .fbt-add-to-cart-btn {
        width: 100%;
        padding: 12px 20px;
    }
}

@media (max-width: 480px) {
    .fbt-container {
        padding: 12px;
        margin: 15px 0;
    }

    .fbt-products {
        gap: 6px;
    }

    .fbt-product-card {
        min-width: 80px !important;
        max-width: 85px !important;
        padding: 6px !important;
    }

    .fbt-product-image img {
        max-width: 60px !important;
    }

    .fbt-product-title {
        font-size: 10px !important;
    }

    .fbt-product-price {
        font-size: 10px !important;
    }

    .fbt-plus-sign {
        font-size: 14px;
    }
    
    /* Simple list mobile */
    .fbt-simple-list .fbt-product-card {
        min-width: 100px !important;
        max-width: 120px !important;
    }
    
    .fbt-single-btn {
        padding: 6px 8px !important;
        font-size: 10px !important;
    }
}

/* ========================================
   Animation
======================================== */
.fbt-product-card {
    transition: opacity 0.3s, transform 0.3s;
}

.fbt-product-card.fbt-unchecked {
    opacity: 0.5;
}

.fbt-product-card.fbt-unchecked .fbt-product-image {
    filter: grayscale(50%);
}

/* ========================================
   Simple List (Related/Featured) Styles
======================================== */
.fbt-simple-list .fbt-wrapper {
    display: block;
}

.fbt-simple-list .fbt-products {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.fbt-simple-list .fbt-product-card {
    min-width: 140px;
    max-width: 180px;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fff;
}

.fbt-simple-list .fbt-product-image img {
    max-width: 100%;
    height: auto;
}

.fbt-single-add-to-cart {
    margin-top: 10px;
}

.fbt-single-btn {
    display: block;
    width: 100%;
    padding: 8px 12px !important;
    font-size: 12px !important;
    text-align: center;
    background: var(--fbt-primary-color) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.2s;
}

.fbt-single-btn:hover {
    background: #e68a00 !important;
    color: #fff !important;
}

.fbt-single-btn.added::after {
    content: ' ✓';
}

.fbt-single-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Hide totals section for simple list */
.fbt-simple-list .fbt-totals-section {
    display: none;
}

/* ========================================
   WooCommerce Star Rating Fix
======================================== */
.fbt-container .star-rating {
    overflow: hidden;
    position: relative;
    height: 1em;
    width: 5.4em;
    font-family: star;
    font-size: 1em;
}

.fbt-container .star-rating::before {
    content: "\73\73\73\73\73";
    color: #d3ced2;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
}

.fbt-container .star-rating span {
    overflow: hidden;
    float: left;
    top: 0;
    left: 0;
    position: absolute;
    padding-top: 1.5em;
}

.fbt-container .star-rating span::before {
    content: "\53\53\53\53\53";
    color: #ffc107;
    top: 0;
    position: absolute;
    left: 0;
}
