/**
 * CommerceForge WooCommerce Component & Template Styles
 *
 * Product cards, archive catalog, single product layout, cart, checkout, and account.
 *
 * @author Jyotirmay Ray <https://jyotirmayray.in/>
 */

/* -----------------------------------------------------------------------------
 * 1. WooCommerce Product Grid & Catalog
 * -------------------------------------------------------------------------- */
.woocommerce .woocommerce-result-count {
    font-size: var(--cf-font-size-body-sm);
    color: var(--cf-color-text-muted);
    margin: 0;
}

.woocommerce .woocommerce-ordering select {
    padding: var(--cf-space-2) var(--cf-space-4);
    font-size: var(--cf-font-size-body-sm);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-sm);
    background-color: var(--cf-color-surface);
    color: var(--cf-color-text-primary);
}

.cf-shop-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--cf-space-4);
    padding-bottom: var(--cf-space-6);
    margin-bottom: var(--cf-space-8);
    border-bottom: 1px solid var(--cf-color-border-subtle);
}

/* Product Card Component */
.cf-product-card {
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border-subtle);
    border-radius: var(--cf-radius-md);
    overflow: hidden;
    transition: var(--cf-transition-all);
}

.cf-product-card:hover {
    border-color: var(--cf-color-border);
    box-shadow: var(--cf-shadow-md);
    transform: translateY(-2px);
}

.cf-product-card__media {
    position: relative;
    background-color: var(--cf-color-surface-subtle);
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.cf-product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--cf-duration-slow) var(--cf-ease-out);
}

.cf-product-card:hover .cf-product-card__media img {
    transform: scale(1.03);
}

.cf-product-card__badge {
    position: absolute;
    top: var(--cf-space-3);
    left: var(--cf-space-3);
    z-index: var(--cf-z-base);
}

.cf-product-card__body {
    padding: var(--cf-space-5);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.cf-product-card__category {
    font-size: var(--cf-font-size-caption);
    letter-spacing: var(--cf-letter-spacing-wide);
    text-transform: uppercase;
    color: var(--cf-color-text-muted);
    margin-bottom: var(--cf-space-1);
}

.cf-product-card__title {
    font-size: 1.0625rem;
    font-weight: var(--cf-font-weight-semibold);
    color: var(--cf-color-text-primary);
    margin-bottom: var(--cf-space-2);
    line-height: var(--cf-line-height-snug);
}

.cf-product-card__title a {
    color: inherit;
}

.cf-product-card__title a:hover {
    color: var(--cf-color-text-secondary);
}

.cf-product-card__footer {
    margin-top: auto;
    padding-top: var(--cf-space-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--cf-space-2);
}

/* -----------------------------------------------------------------------------
 * 2. Single Product Layout
 * -------------------------------------------------------------------------- */
.cf-single-product {
    padding-top: var(--cf-space-4);
}

.cf-single-product__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--cf-space-10);
    margin-bottom: var(--cf-space-16);
}

@media (min-width: 860px) {
    .cf-single-product__grid {
        grid-template-columns: 1.1fr 1fr;
        gap: var(--cf-space-12);
    }
}

/* Product Gallery */
.cf-product-gallery {
    position: relative;
}

.cf-product-gallery__main {
    background-color: var(--cf-color-surface-subtle);
    border: 1px solid var(--cf-color-border-subtle);
    border-radius: var(--cf-radius-md);
    overflow: hidden;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cf-product-gallery__main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cf-product-gallery__thumbs {
    display: flex;
    gap: var(--cf-space-3);
    margin-top: var(--cf-space-4);
}

.cf-product-gallery__thumb {
    width: 72px;
    height: 72px;
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-sm);
    overflow: hidden;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--cf-transition-color), opacity var(--cf-duration-fast);
}

.cf-product-gallery__thumb.is-active,
.cf-product-gallery__thumb:hover {
    opacity: 1;
    border-color: var(--cf-color-action-primary);
}

.cf-product-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Product Summary / Buy Box */
.cf-product-summary {
    display: flex;
    flex-direction: column;
}

.cf-product-summary__title {
    font-size: var(--cf-font-size-h1);
    margin-bottom: var(--cf-space-3);
}

.cf-product-summary__price {
    font-size: 1.5rem;
    font-weight: var(--cf-font-weight-bold);
    margin-bottom: var(--cf-space-5);
}

.cf-product-summary__desc {
    font-size: var(--cf-font-size-body);
    color: var(--cf-color-text-secondary);
    line-height: var(--cf-line-height-relaxed);
    margin-bottom: var(--cf-space-6);
    padding-bottom: var(--cf-space-6);
    border-bottom: 1px solid var(--cf-color-border-subtle);
}

/* Phase 2 Integration Mount Slot */
.cf-configurator-slot {
    margin-bottom: var(--cf-space-6);
    padding: var(--cf-space-4);
    background-color: var(--cf-color-surface-subtle);
    border: 1px dashed var(--cf-color-border);
    border-radius: var(--cf-radius-md);
}

.cf-configurator-slot__note {
    font-size: var(--cf-font-size-caption);
    color: var(--cf-color-text-muted);
    display: flex;
    align-items: center;
    gap: var(--cf-space-2);
}

/* Add to Cart Area */
.cf-add-to-cart-form {
    display: flex;
    flex-direction: column;
    gap: var(--cf-space-5);
    margin-bottom: var(--cf-space-8);
}

.cf-add-to-cart-row {
    display: flex;
    gap: var(--cf-space-4);
    align-items: center;
}

.cf-add-to-cart-row .cf-btn {
    flex-grow: 1;
}

/* Product Details Accordion */
.cf-product-accordion {
    border-top: 1px solid var(--cf-color-border);
    margin-top: var(--cf-space-6);
}

.cf-accordion-item {
    border-bottom: 1px solid var(--cf-color-border);
}

.cf-accordion-trigger {
    width: 100%;
    padding: var(--cf-space-4) 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--cf-font-size-body);
    font-weight: var(--cf-font-weight-semibold);
    color: var(--cf-color-text-primary);
    text-align: left;
}

.cf-accordion-trigger svg {
    width: 18px;
    height: 18px;
    transition: transform var(--cf-duration-fast) var(--cf-ease-out);
}

.cf-accordion-item.is-open .cf-accordion-trigger svg {
    transform: rotate(180deg);
}

.cf-accordion-content {
    display: none;
    padding-bottom: var(--cf-space-5);
    font-size: var(--cf-font-size-body-sm);
    color: var(--cf-color-text-secondary);
    line-height: var(--cf-line-height-relaxed);
}

.cf-accordion-item.is-open .cf-accordion-content {
    display: block;
}

/* -----------------------------------------------------------------------------
 * 3. Cart Layout
 * -------------------------------------------------------------------------- */
.cf-cart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--cf-space-8);
    margin-top: var(--cf-space-6);
}

@media (min-width: 960px) {
    .cf-cart-grid {
        grid-template-columns: 2fr 1fr;
        align-items: start;
    }
}

.cf-cart-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-md);
    overflow: hidden;
}

.cf-cart-table th {
    background-color: var(--cf-color-surface-subtle);
    padding: var(--cf-space-3) var(--cf-space-4);
    text-align: left;
    font-size: var(--cf-font-size-caption);
    letter-spacing: var(--cf-letter-spacing-wide);
    text-transform: uppercase;
    color: var(--cf-color-text-muted);
    border-bottom: 1px solid var(--cf-color-border);
}

.cf-cart-table td {
    padding: var(--cf-space-4);
    border-bottom: 1px solid var(--cf-color-border-subtle);
    vertical-align: middle;
}

/* Cart Item Configuration & File Metadata */
.cf-cart-table dl.variation,
.cf-checkout-table dl.variation {
    margin: var(--cf-space-2) 0 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: var(--cf-font-size-caption);
    color: var(--cf-color-text-secondary);
}

.cf-cart-table dl.variation dt,
.cf-checkout-table dl.variation dt {
    font-weight: var(--cf-font-weight-semibold);
    color: var(--cf-color-text-primary);
    float: left;
    clear: left;
    margin-right: 4px;
}

.cf-cart-table dl.variation dd,
.cf-checkout-table dl.variation dd {
    margin: 0;
    color: var(--cf-color-text-secondary);
}

.cf-cart-table dl.variation dd p,
.cf-checkout-table dl.variation dd p {
    margin: 0;
}

.cf-cart-totals-card {
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-md);
    padding: var(--cf-space-6);
    position: sticky;
    top: 96px;
}

.cf-cart-totals-card h2 {
    font-size: var(--cf-font-size-h3);
    margin-bottom: var(--cf-space-4);
    padding-bottom: var(--cf-space-3);
    border-bottom: 1px solid var(--cf-color-border-subtle);
}

.cf-totals-row {
    display: flex;
    justify-content: space-between;
    padding: var(--cf-space-3) 0;
    font-size: var(--cf-font-size-body-sm);
    color: var(--cf-color-text-secondary);
}

.cf-totals-row--grand {
    border-top: 1px solid var(--cf-color-border);
    margin-top: var(--cf-space-3);
    padding-top: var(--cf-space-4);
    font-size: var(--cf-font-size-body);
    font-weight: var(--cf-font-weight-bold);
    color: var(--cf-color-text-primary);
}

/* Empty Cart State */
.cf-empty-cart {
    text-align: center;
    padding: var(--cf-space-16) var(--cf-space-4);
    max-width: 540px;
    margin: 0 auto;
}

.cf-empty-cart svg {
    width: 48px;
    height: 48px;
    color: var(--cf-color-text-muted);
    margin-bottom: var(--cf-space-4);
}

/* -----------------------------------------------------------------------------
 * 4. Checkout Layout
 * -------------------------------------------------------------------------- */
.cf-checkout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--cf-space-10);
    margin-top: var(--cf-space-6);
}

@media (min-width: 960px) {
    .cf-checkout-grid {
        grid-template-columns: 1.4fr 1fr;
        align-items: start;
    }
}

.cf-checkout-section {
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-md);
    padding: var(--cf-space-6);
    margin-bottom: var(--cf-space-6);
    box-shadow: var(--cf-shadow-sm);
}

.cf-checkout-section h3 {
    font-size: var(--cf-font-size-h3);
    font-weight: var(--cf-font-weight-semibold);
    margin-bottom: var(--cf-space-5);
    padding-bottom: var(--cf-space-3);
    border-bottom: 1px solid var(--cf-color-border-subtle);
    color: var(--cf-color-text-primary);
}

/* Checkout Form Rows & Inputs */
.woocommerce-checkout .form-row {
    margin-bottom: var(--cf-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--cf-space-1);
}

.woocommerce-checkout .form-row label {
    font-size: var(--cf-font-size-caption);
    font-weight: var(--cf-font-weight-medium);
    color: var(--cf-color-text-primary);
}

.woocommerce-checkout .form-row .required {
    color: var(--cf-color-error);
    text-decoration: none;
}

.woocommerce-checkout .form-row input.input-text,
.woocommerce-checkout .form-row select,
.woocommerce-checkout .form-row textarea {
    width: 100%;
    padding: var(--cf-space-3) var(--cf-space-4);
    font-size: var(--cf-font-size-body-sm);
    font-family: inherit;
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-sm);
    background-color: var(--cf-color-surface);
    color: var(--cf-color-text-primary);
    transition: border-color var(--cf-duration-fast), box-shadow var(--cf-duration-fast);
}

.woocommerce-checkout .form-row input.input-text:focus,
.woocommerce-checkout .form-row select:focus,
.woocommerce-checkout .form-row textarea:focus {
    outline: none;
    border-color: var(--cf-color-action-primary);
    box-shadow: 0 0 0 2px var(--cf-color-surface-subtle);
}

.woocommerce-checkout .form-row-first {
    width: 48%;
    float: left;
    clear: both;
}

.woocommerce-checkout .form-row-last {
    width: 48%;
    float: right;
}

.woocommerce-checkout .form-row-wide {
    clear: both;
    width: 100%;
}

/* Checkout Review Sidebar Card */
.cf-checkout-review-card {
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-md);
    padding: var(--cf-space-6);
    box-shadow: var(--cf-shadow-sm);
    position: sticky;
    top: 96px;
}

/* Order Review Table */
.cf-review-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--cf-font-size-body-sm);
}

.cf-review-table th,
.cf-review-table td {
    padding: var(--cf-space-3) 0;
    border-bottom: 1px solid var(--cf-color-border-subtle);
    vertical-align: top;
}

.cf-review-table thead th {
    font-size: var(--cf-font-size-caption);
    letter-spacing: var(--cf-letter-spacing-wide);
    text-transform: uppercase;
    color: var(--cf-color-text-muted);
    border-bottom: 1px solid var(--cf-color-border);
}

.cf-review-table td.product-total {
    text-align: right;
    font-weight: var(--cf-font-weight-medium);
    white-space: nowrap;
}

.cf-product-meta-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cf-product-name-title {
    font-weight: var(--cf-font-weight-medium);
    color: var(--cf-color-text-primary);
}

.cf-review-table dl.variation {
    margin: var(--cf-space-1) 0 0 0;
    padding: 0;
    font-size: var(--cf-font-size-caption);
    color: var(--cf-color-text-muted);
}

.cf-review-table tfoot th {
    font-weight: var(--cf-font-weight-normal);
    color: var(--cf-color-text-secondary);
}

.cf-review-table tfoot td {
    text-align: right;
}

.cf-review-table .cf-subtotal-row th,
.cf-review-table .cf-subtotal-row td {
    border-top: 1px solid var(--cf-color-border);
}

.cf-review-table .cf-total-row th,
.cf-review-table .cf-total-row td {
    border-top: 2px solid var(--cf-color-border);
    font-size: var(--cf-font-size-body);
    font-weight: var(--cf-font-weight-bold);
    color: var(--cf-color-text-primary);
    padding-top: var(--cf-space-4);
}

.cf-review-table .cf-total-row td strong {
    font-size: var(--cf-font-size-h4);
    color: var(--cf-color-action-primary);
}

/* Payment Methods Area */
.cf-payment-box {
    margin-top: var(--cf-space-4);
}

.cf-payment-methods {
    list-style: none;
    margin: 0 0 var(--cf-space-6) 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--cf-space-3);
}

.cf-payment-method-item {
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-sm);
    padding: var(--cf-space-3) var(--cf-space-4);
    background-color: var(--cf-color-surface);
    transition: border-color var(--cf-duration-fast);
}

.cf-payment-method-item:has(input[type="radio"]:checked) {
    border-color: var(--cf-color-action-primary);
    background-color: var(--cf-color-surface-subtle);
    box-shadow: 0 0 0 1px var(--cf-color-action-primary);
}

.cf-payment-method-label {
    display: flex;
    align-items: center;
    gap: var(--cf-space-3);
    cursor: pointer;
    font-weight: var(--cf-font-weight-medium);
    margin: 0;
}

.cf-payment-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.cf-payment-desc-box {
    margin-top: var(--cf-space-3);
    padding: var(--cf-space-3);
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border-subtle);
    border-radius: var(--cf-radius-sm);
    font-size: var(--cf-font-size-caption);
    color: var(--cf-color-text-secondary);
    line-height: var(--cf-line-height-relaxed);
}

.cf-place-order-wrap {
    margin-top: var(--cf-space-6);
}

.cf-place-order-btn {
    width: 100%;
    padding: var(--cf-space-4) var(--cf-space-6);
    font-size: var(--cf-font-size-body);
    font-weight: var(--cf-font-weight-bold);
    letter-spacing: var(--cf-letter-spacing-wide);
    cursor: pointer;
}

/* Loading Overlay & State */
.cf-checkout-loading-indicator {
    display: flex;
    align-items: center;
    gap: var(--cf-space-2);
    font-size: var(--cf-font-size-caption);
    color: var(--cf-color-action-primary);
    margin-bottom: var(--cf-space-3);
    padding: var(--cf-space-2) var(--cf-space-3);
    background-color: var(--cf-color-surface-subtle);
    border-radius: var(--cf-radius-sm);
}

.cf-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--cf-color-border-subtle);
    border-top-color: var(--cf-color-action-primary);
    border-radius: 50%;
    animation: cf-spin 0.6s linear infinite;
}

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

.woocommerce-checkout.processing .cf-checkout-review-card {
    opacity: 0.7;
    pointer-events: none;
}

/* Notices & Error Presentation */
.woocommerce-NoticeGroup-checkout,
.woocommerce-error,
.woocommerce-info {
    margin-bottom: var(--cf-space-6);
    padding: var(--cf-space-4);
    border-radius: var(--cf-radius-sm);
    font-size: var(--cf-font-size-body-sm);
}

.woocommerce-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--cf-color-error);
    list-style: none;
}

.woocommerce-info {
    background-color: var(--cf-color-surface-subtle);
    border: 1px solid var(--cf-color-border);
    color: var(--cf-color-text-secondary);
}

/* -----------------------------------------------------------------------------
 * 5. My Account Layout
 * -------------------------------------------------------------------------- */
.cf-account-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--cf-space-8);
}

@media (min-width: 768px) {
    .cf-account-layout {
        grid-template-columns: 240px 1fr;
    }
}

.cf-account-nav {
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-md);
    padding: var(--cf-space-2);
}

.cf-account-nav ul {
    display: flex;
    flex-direction: column;
}

.cf-account-nav a {
    display: block;
    padding: var(--cf-space-3) var(--cf-space-4);
    font-size: var(--cf-font-size-body-sm);
    font-weight: var(--cf-font-weight-medium);
    color: var(--cf-color-text-secondary);
    border-radius: var(--cf-radius-sm);
    transition: var(--cf-transition-color);
}

.cf-account-nav a:hover,
.cf-account-nav .is-active a {
    background-color: var(--cf-color-surface-subtle);
    color: var(--cf-color-text-primary);
}

.cf-account-content {
    background-color: var(--cf-color-surface);
    border: 1px solid var(--cf-color-border);
    border-radius: var(--cf-radius-md);
    padding: var(--cf-space-8);
}
