/**
 * Product Detail Page Styles
 * CSS Module for single product view
 */

/* ============================================================================
   LAYOUT
   ============================================================================ */

.bw-product-layout {
    margin-bottom: 0;
}

.bw-product-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

/* Container for the Image and Description */
.bw-main-details-section {
    flex: 2;
    min-width: 0;
    background: white;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: var(--bw-shadow);
}

/* Container for the Price, Order, and Discount Info */
.bw-order-summary-section {
    flex: 1;
    max-width: 400px;
    min-width: 300px;
    position: sticky;
    top: 2rem;
}


/* ============================================================================
   PRODUCT IMAGE (Nested inside .bw-main-details-section now)
   ============================================================================ */

.bw-product-image {
    width: 35%;
    float: left;
    margin: 0 2rem 1.5rem 0;
}

.bw-product-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 2/3;
    object-fit: cover;
    border-radius: 8px;
}

/* ============================================================================
   PRODUCT INFO (Part of .bw-main-details-section)
   ============================================================================ */

.bw-product-info {
    padding: 0;
}

.bw-main-details-section::after {
    content: "";
    display: table;
    clear: both;
}

.bw-product-title {
    font-size: 2rem;
    font-weight: 700;
    color: #212529;
    margin: 0 0 1rem 0;
    line-height: 1.2;
}

.bw-product-author {
    font-size: 1.1rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.bw-product-description {
    font-size: 1rem;
    color: #495057;
    line-height: 1.8;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    overflow: auto;
    clear: both;
}

/* ============================================================================
   PRICING & ORDER SECTION (REFACTORED)
   ============================================================================ */

.bw-order-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    /* Reduced vertical padding slightly */
    box-shadow: var(--bw-shadow);
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bw-dynamic-price-display {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
}

.bw-total-price-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.25rem;
}

.bw-product-total-label {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #868e96;
}

.bw-total-price-row {
    display: flex;
    align-items: baseline;
}

.bw-product-total-price {
    font-size: 2.25rem;
    font-weight: 700;
    color: #212529;
    margin: 0;
}

.bw-discount-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35em 0.75em;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    background-color: var(--bw-green-dark);
    border-radius: 999px;
    margin-left: auto;
    white-space: nowrap;
    min-width: 3.25rem;
    min-height: 1.85rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.bw-discount-badge.is-visible {
    opacity: 1;
    visibility: visible;
}

.bw-product-order {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.bw-order-action-row {
    display: flex;
    align-items: center;
    /* Changed from flex-end for better vertical alignment */
    gap: 1rem;
}

/* Quantity Selector */
.bw-quantity-selector {
    flex: 1;
    /* Allow quantity selector to grow */
    display: flex;
    flex-direction: column;
    /* Stack label and input */
    align-items: flex-start;
    gap: 0.25rem;
}

.bw-quantity-selector label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.bw-quantity-input {
    width: 100%;
    /* Make input container fill available space */
}

.bw-quantity-input input[type="number"] {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    /* Ensure input field fills its container */
    padding: 0.75rem 0.5rem;
    /* Adjusted padding for better fit */
}

/* Order Button */
.bw-order-action-row>div:last-child {
    flex: 1;
    /* Allow button container to grow */
}

.bw-order-button {
    width: 100%;
    /* Button now fills the remaining space */
    padding: 0.875rem 1rem;
    /* Adjusted padding */
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.3rem;
    /* Align button baseline with quantity input (approx) */
}

/* Success Message */
.bw-order-success {
    display: none;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 1rem;
    /* Added margin to separate from price */
}

.bw-order-success.show {
    display: block;
    animation: slideDown 0.3s ease;
}

/* Keyframes remain unchanged */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   DISCOUNT INFO CARD (Unchanged)
   ============================================================================ */

.bw-discount-card {
    border-radius: 12px;
    box-shadow: var(--bw-shadow);
    background: white;
    overflow: hidden;
}

.bw-discount-card .card-header {
    background: linear-gradient(135deg, var(--bw-green) 0%, var(--bw-green-light) 100%);
    color: white;
    padding: 1.25rem;
    border-bottom: none;
}

.bw-discount-card .card-header h6 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.bw-discount-table {
    font-size: 0.9rem;
    width: 100%;
    margin-bottom: 0;
}

.bw-discount-table tr {
    border-bottom: 1px solid var(--bw-gray-border);
}

.bw-discount-table tr:last-child {
    border-bottom: none;
}

.bw-discount-table td {
    padding: 0.75rem 1.5rem;
    border: none;
    line-height: 1.2;
}

.bw-discount-table .discount-tier {
    color: #495057;
}

.bw-discount-table .discount-value {
    font-weight: 700;
    color: var(--bw-green);
    text-align: right;
}

.bw-discount-card-footer {
    background-color: #f8f9fa;
    padding: 0.75rem 1.5rem;
    text-align: center;
    border-top: 1px solid #e9ecef;
}

/* ============================================================================
   BACK LINK (Unchanged)
   ============================================================================ */

.bw-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--bw-green);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 2rem;
    transition: all 0.2s ease;
}

.bw-back-link:hover {
    color: var(--bw-green-dark);
    transform: translateX(-4px);
}

.bw-back-link::before {
    content: "←";
    font-size: 1.2rem;
}

/* ============================================================================
   RESPONSIVE (Adjusted for new layout)
   ============================================================================ */

@media (max-width: 992px) {
    .bw-product-container {
        flex-direction: column;
        gap: 2rem;
    }

    .bw-order-summary-section {
        max-width: 100%;
        min-width: auto;
        position: static;
        top: auto;
        align-self: center;
    }

    .bw-product-image {
        width: 100%;
        max-width: 400px;
        float: none;
        margin: 0 auto 1.5rem auto;
    }

    .bw-main-details-section::after {
        content: none;
    }
}

@media (max-width: 768px) {
    .bw-main-details-section {
        padding: 1.5rem;
    }

    .bw-product-title {
        font-size: 1.5rem;
    }

    .bw-order-card {
        padding: 1.5rem;
    }

    .bw-product-price {
        font-size: 1.75rem;
    }

    .bw-product-total-price {
        font-size: 1.5rem;
    }

    /* Keep the quantity selector and button side-by-side but allow them to fill space */
    .bw-order-action-row {
        flex-direction: row;
        align-items: center;
    }

    .bw-quantity-selector {
        flex: 1;
    }

    .bw-order-action-row>div:last-child {
        flex: 1;
    }

    .bw-order-button {
        margin-top: 0;
        /* Reset margin-top from larger view */
    }

    .bw-order-summary-section {
        max-width: 100%;
        min-width: auto;
        position: static;
        top: auto;
        align-self: center;
    }
}

@media (max-width: 576px) {
    .bw-main-details-section {
        padding: 1.25rem;
    }

    .bw-product-title {
        font-size: 1.35rem;
    }

    /* On smallest screens, stack quantity and button vertically */
    .bw-order-action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .bw-quantity-selector,
    .bw-order-action-row>div:last-child {
        flex: none;
        /* Remove flex sizing */
        width: 100%;
        /* Ensure both take full width */
    }

    .bw-order-button {
        margin-top: 0;
        /* No top margin when stacked */
    }

    .bw-quantity-input {
        margin-bottom: 0.5rem;
        /* Add some space below the quantity input */
    }

    .bw-order-summary-section {
        max-width: 100%;
        min-width: auto;
        position: static;
        top: auto;
        align-self: center;
    }
}