/**
 * Frontend CSS for Jewelry Pricing Engine
 * Layout: stacked rate/breakdown, button rows as requested
 *
 * @package JewelryPricingEngine
 * @since   1.0.0
 */

/* ========== CART FORM – STACK SECTIONS ========== */
form.cart {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

/* Rate info and breakdown – full width and stacked */
.jpe-rate-info,
.jpe-price-breakdown {
    width: 100%;
}

/* ========== RATE INFO BOX ========== */
.jpe-rate-info {
    margin: 0;
    padding: 12px 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.jpe-rate-value {
    font-size: 1rem;
    font-weight: 500;
}

.jpe-rate-label {
    font-weight: 600;
    color: #1e293b;
    margin-right: 6px;
}

.jpe-rate-amount {
    color: #f59e0b;
    font-weight: 700;
    font-size: 1.1rem;
}

.jpe-rate-last-updated {
    font-size: 0.8rem;
    color: #64748b;
}

/* ========== PRICE BREAKDOWN ========== */
.jpe-price-breakdown {
    margin: 0;
    padding: 15px 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.jpe-price-breakdown h3 {
    margin: 0 0 12px 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
}

.jpe-breakdown-table {
    width: 100%;
    border-collapse: collapse;
}

.jpe-breakdown-table tr {
    border-bottom: 1px solid #f3f4f6;
}

.jpe-breakdown-table td {
    padding: 10px 0;
    font-size: 0.95rem;
}

.jpe-breakdown-label {
    text-align: left;
    font-weight: 500;
    color: #4b5563;
}

.jpe-breakdown-value {
    text-align: right;
    font-weight: 500;
    color: #111827;
}

.jpe-total-row {
    border-top: 2px solid #e5e7eb;
    border-bottom: none;
    font-weight: 700;
}

.jpe-total-row td {
    padding-top: 14px;
    font-size: 1.05rem;
}

.jpe-total-row .jpe-breakdown-value {
    font-weight: 700;
    color: #f59e0b;
}

/* ========== HEADER RATE TICKER ========== */
.jpe-rate-ticker {
    background: #1e293b;
    color: #f1f5f9;
    padding: 10px 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.9rem;
    position: relative;
    width: 100%;
}

.jpe-ticker-container {
    overflow: hidden;
    width: 100%;
}

.jpe-ticker-wrapper {
    display: inline-block;
    white-space: nowrap;
    animation: jpe-scroll 30s linear infinite;
}

.jpe-ticker-item {
    display: inline-block;
    margin: 0 24px;
}

.jpe-ticker-metal {
    font-weight: 600;
    margin-right: 6px;
}

.jpe-ticker-rate {
    color: #fbbf24;
    font-weight: 500;
}

@keyframes jpe-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ========== LOADING STATE ========== */
.jpe-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.jpe-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: jpe-spin 0.6s linear infinite;
}

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

/* ========== BUTTON ROW (DESKTOP) ========== */
@media (min-width: 768px) {
    .jpe-button-row {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 12px;
        align-items: center;
        width: 100%;
        margin: 10px 0;
    }

    .jpe-button-row .quantity {
        flex: 0 0 auto;
        width: 120px;
        margin: 0;
    }

    .jpe-button-row .quantity select.qty {
        width: 100%;
        height: 48px;
        padding: 0 12px;
        border-radius: 40px;
        border: 1px solid #d1d5db;
        background: #fff;
        cursor: pointer;
        font-size: 14px;
    }

    .jpe-button-row .jpe-quote-buttons {
        flex: 1 1 auto;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 12px;
        margin: 0;
    }

    .jpe-get-quote-btn,
    .jpe-buy-now-btn {
        flex: 1 1 0;
        min-width: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 12px;
        height: 48px;
        font-size: 14px;
        font-weight: 500;
        font-family: inherit;
        line-height: 1;
        text-align: center;
        text-decoration: none;
        border: none;
        border-radius: 40px;
        cursor: pointer;
        transition: all 0.25s ease;
        white-space: nowrap;
    }
}

/* ========== MOBILE: STACK VERTICALLY ========== */
@media (max-width: 767px) {
    .jpe-button-row {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        margin: 10px 0;
    }

    .jpe-button-row .quantity {
        width: 100%;
    }

    .jpe-button-row .quantity select.qty {
        width: 100%;
        height: 48px;
        padding: 0 12px;
        border-radius: 40px;
        border: 1px solid #d1d5db;
        background: #fff;
        font-size: 14px;
    }

    .jpe-button-row .jpe-quote-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .jpe-get-quote-btn,
    .jpe-buy-now-btn {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 48px;
        padding: 0 12px;
        font-size: 14px;
        font-weight: 500;
        border-radius: 40px;
        cursor: pointer;
        transition: all 0.25s ease;
        white-space: normal;
        text-align: center;
    }
}

/* ========== COMMON BUTTON STYLES (both desktop & mobile) ========== */
.jpe-get-quote-btn {
    background-color: #171831;
    color: #ffffff;
    border: none;
}
.jpe-get-quote-btn:hover {
    background-color: #0f2a44;
    transform: translateY(-1px);
}

.jpe-buy-now-btn {
    background-color: #f59e0b;
    color: #ffffff;
    border: none;
}
.jpe-buy-now-btn:hover {
    background-color: #b38f34;
    transform: translateY(-1px);
}

/* Hide original WooCommerce add to cart buttons */
.single_add_to_cart_button:not(.jpe-buy-now-btn):not(.jpe-get-quote-btn),
.et-single-buy-now,
.et-or-wrapper,
.product-buy-now {
    display: none;
}

/* Customise button (below the button row) */
.jpe-customise-button {
    margin-top: 16px;
    display: inline-block;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 40px;
    padding: 0 24px;
    height: 44px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
}

/* ========== MOBILE ADJUSTMENTS FOR CUSTOMISE BUTTON ========== */
@media (max-width: 767px) {
    .jpe-customise-button {
        width: 100%;
        text-align: center;
    }
}

/* ========== EXTRA FIX FOR THEME CONTAINERS ========== */
.woocommerce div.product form.cart {
    width: 100%;
    overflow: visible;
}