/*
 * Zagwear Cart — Base Structural Styles
 *
 * This file supplies all structural CSS that cart.php / cart-empty.php /
 * mini-cart.php require.  It is designed to work on ANY WordPress theme,
 * so it only targets Zagwear-namespaced selectors and a minimal Bootstrap-
 * like grid scoped to #zw-cart-area.
 *
 * Load order: this file FIRST, then zagwear-cart.css (overrides).
 *
 * ⚠  FONT NOTE: 'Charlie Display' and 'Charlie Text' are proprietary Zagwear
 *    brand fonts. This plugin ships readable system-font fallbacks so the cart
 *    is legible on any site. To match the original branding exactly, the target
 *    site must load those fonts separately (e.g. via the theme or @font-face).
 */

/* ==========================================================================
   0. Design tokens — read from Elementor global settings with hardcoded
      fallbacks so the cart is fully usable without Elementor.

      In Elementor: Site Settings → Global Colors / Global Typography
        Global Colors  → Primary  maps to button / badge colour
                      → Text     maps to body text colour
        Global Fonts   → Primary  maps to heading font (Charlie Display)
                      → Text     maps to body font (Charlie Text)

      To override per-site without Elementor, add Custom CSS:
        :root { --zw-color-primary: #your-color; }
   ========================================================================== */
:root {
    --zw-color-primary:      var(--e-global-color-primary, #1868DB);
    --zw-color-primary-dark: #123263;
    --zw-color-text:         var(--e-global-color-text, #101214);
    --zw-color-text-muted:   #7D818A;
    --zw-font-heading:       var(--e-global-typography-primary-font-family, 'Charlie Display'), 'Helvetica Neue', Arial, sans-serif;
    --zw-font-body:          var(--e-global-typography-text-font-family, 'Charlie Text'), 'Helvetica Neue', Arial, sans-serif;
}

/* ==========================================================================
   1. Box-sizing baseline
   ========================================================================== */
#zw-cart-area *,
#zw-cart-area *::before,
#zw-cart-area *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   2. Theme container & outer wrappers
   ========================================================================== */
.zw-theme-container {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

.zw-checkout-cart-box {
    width: 100%;
    padding: 20px 0 40px;
}

.container-fluid {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

/* ==========================================================================
   3. Flex row & columns (scoped to cart area)
   ========================================================================== */
#zw-cart-area .row,
#zw-cart-area .zw-cart-section {
    display: flex;
    flex-wrap: wrap;
    margin-left: -15px;
    margin-right: -15px;
    width: 100%;
}

/* Two-column layout: products left (7/12) + summary right (5/12) */
#zw-cart-area .col-lg-7,
#zw-cart-area .col-lg-5 {
    position: relative;
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

@media (min-width: 992px) {
    #zw-cart-area .col-lg-7 {
        flex: 0 0 58.3333%;
        max-width: 58.3333%;
    }

    #zw-cart-area .col-lg-5 {
        flex: 0 0 41.6667%;
        max-width: 41.6667%;
    }
}

/* ==========================================================================
   4. Flex utility classes
   ========================================================================== */
.zw-flex-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.zw-flex-center,
.zw-flex-center.zw-flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ==========================================================================
   5. Text alignment helpers
   ========================================================================== */
.text-left   { text-align: left !important; }
.text-right  { text-align: right !important; }
.text-center { text-align: center !important; }
.text-danger { color: #d63638; }

/* ==========================================================================
   6. Responsive table wrapper
   ========================================================================== */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   7. Base table styles (.table)
   ========================================================================== */
.zw-main-cart-page .table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent;
}

.zw-main-cart-page .table td,
.zw-main-cart-page .table th {
    padding: 10px 8px;
    vertical-align: middle;
    border-top: 1px solid rgba(9, 30, 66, 0.08);
}

.zw-main-cart-page .table > tbody > tr:first-child > td {
    border-top: none;
}

/* ==========================================================================
   8. Cart table layout
   ========================================================================== */
.zw-cart-table {
    margin-bottom: 0;
}

/* Image cell + name cell — each ~50% */
.zw-td-50 {
    width: 50%;
    vertical-align: top;
}

/* image cell: fixed narrow width */
.zw-cart-table > tbody > tr.zw-cart-row > td:first-child.zw-td-50 {
    width: 90px;
    min-width: 80px;
    max-width: 110px;
    padding-right: 14px;
}

.zw-cart-table img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Hidden tbody for spacing */
.zw-hidden-cart-tbody {
    visibility: hidden;
}
.zw-xs-hidden {
    /* shown at wider viewports; hidden in mobile override below */
}

/* ==========================================================================
   9. Product text area
   ========================================================================== */
.zw-product-text {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.zw-cart-item-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.zw-cart-item-top {
    flex: 1 0 auto;
}

.zw-cart-item-bot {
    margin-top: 12px;
}

.zw-item-name {
    font-size: 14px;
    line-height: 20px;
    color: var(--zw-color-text);
    font-weight: 400;
    font-family: var(--zw-font-body);
    margin: 0 0 4px;
}

.zw-item-name a {
    color: inherit;
    text-decoration: none;
}

.zw-item-name a:hover {
    text-decoration: underline;
}

.zw-item-no {
    font-size: 13px;
    line-height: 18px;
    color: var(--zw-color-text-muted);
    font-family: var(--zw-font-body);
    font-weight: 400;
    margin: 0 0 2px;
}

/* ==========================================================================
   10. Qty input group
   ========================================================================== */
.zw-qty-group-box {
    display: inline-flex;
    align-items: center;
}

.zw-item-qty-box {
    display: inline-flex;
    align-items: center;
}

.zw-item-qty-input-box {
    display: inline-flex;
    align-items: center;
}

/* Base qty input (overrides refine this in zagwear-cart.css) */
.zw-item-qty-input,
.zw-main-cart-page .zw-cart-table .quantity input.qty {
    width: 56px;
    height: 36px;
    text-align: center;
    border: 2px solid rgba(9, 30, 66, 0.14);
    border-radius: 3px;
    padding: 8px;
    font-size: 14px;
    line-height: 20px;
    font-family: var(--zw-font-body);
    color: var(--zw-color-text);
    background: #fff;
    -moz-appearance: textfield;
}

.zw-item-qty-input::-webkit-inner-spin-button,
.zw-item-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-group {
    display: flex;
    align-items: center;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ==========================================================================
   11. Total / subtotal cell
   ========================================================================== */
.zw-td-total {
    text-align: right;
    vertical-align: top;
    white-space: nowrap;
    min-width: 80px;
    position: relative;
}

.zw-total-text {
    font-size: 14px;
    line-height: 20px;
    color: var(--zw-color-text);
    font-family: var(--zw-font-body);
    font-weight: 400;
}

/* ==========================================================================
   12. Variant sub-rows
   ========================================================================== */
.zw-sub-row td {
    padding: 6px 8px;
    font-size: 13px;
    line-height: 18px;
    color: #444955;
    font-family: var(--zw-font-body);
    border-top: 1px solid rgba(9, 30, 66, 0.05);
}

.zw-sub-input {
    text-align: center;
}

.zw-input-group {
    display: inline-flex;
    align-items: center;
    flex-direction: column;
}

.zw-variant-valid {
    font-size: 12px;
    line-height: 16px;
    margin: 2px 0 0;
}

/* ==========================================================================
   13. Cart form actions bar
   ========================================================================== */
.zw-main-cart-page .actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(9, 30, 66, 0.08);
}

.zw-main-cart-page .actions .coupon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zw-main-cart-page .actions .coupon input.input-text {
    height: 40px;
    padding: 8px 12px;
    border: 2px solid rgba(9, 30, 66, 0.14);
    border-radius: 4px;
    font-size: 14px;
    font-family: var(--zw-font-body);
    color: var(--zw-color-text);
    min-width: 180px;
}

/* ==========================================================================
   14. Order summary panel (right column)
   ========================================================================== */
.zw-total-table-wrapper {
    background: #F8F8F8;
    padding: 22px 14px 24px;
    border-radius: 20px;
}

.zw-total-table-area {
    margin-bottom: 16px;
}

.zw-total-table-box h1 {
    font-size: 20px;
    line-height: 28px;
    font-weight: 700;
    color: var(--zw-color-text);
    font-family: var(--zw-font-heading);
    margin: 0 0 12px;
}

.zw-total-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.zw-total-table td {
    padding: 6px 0;
    border: none;
    vertical-align: middle;
}

.zw-total-text-label p {
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    font-family: var(--zw-font-body);
    color: var(--zw-color-text);
}

.zw-total-amount p {
    margin: 0;
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    font-family: var(--zw-font-body);
    color: var(--zw-color-text);
    text-align: right;
}

/* ==========================================================================
   15. Checkout / Continue Shopping button section
   ========================================================================== */
.zw-ship-btn-section {
    margin-top: 16px;
}

.zw-checkout-cart-btn {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.zw-add-btn-section {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.zw-cart-btn-ship {
    width: 100%;
}

/* Base "Continue Checkout" primary button */
.zw-shipto-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 24px;
    background-color: var(--zw-color-primary);
    color: #ffffff;
    font-size: 16px;
    line-height: 20px;
    font-weight: 600;
    font-family: var(--zw-font-body);
    border: none;
    border-radius: 40px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.zw-shipto-btn:hover {
    background-color: var(--zw-color-primary-dark);
    color: #ffffff;
    text-decoration: none;
}

/* Base "Continue Shopping" secondary button */
.zw-btn-white-bg,
.zw-theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 24px;
    background: transparent;
    color: var(--zw-color-text);
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    font-family: var(--zw-font-body);
    border: 0;
    border-radius: 0;
    text-decoration: none;
    cursor: pointer;
}

/* .btn reset so WooCommerce / Bootstrap .btn class doesn't fight us */
.zw-main-cart-page .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--zw-font-body);
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

/* WooCommerce button overrides on cart page */
.zw-main-cart-page .woocommerce button.button,
.zw-main-cart-page .woocommerce a.button {
    border-radius: 40px;
    font-family: var(--zw-font-body);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 20px;
}

/* ==========================================================================
   16. Page title area
   ========================================================================== */
#zw-checkout-cart #zw-page-title {
    padding: 13px;
}

/* ==========================================================================
   17. Cart badge (.checkout-cart-count) used by [zw_cart_icon]
   ========================================================================== */
.zw-cart-icon-wrapper {
    display: inline-flex;
    align-items: center;
}

.zw-cart-icon-wrapper a {
    position: relative;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: currentColor;
}

.zw-cart-icon-img {
    display: block;
    width: 25px;
    height: 25px;
}

.checkout-cart-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    margin-left: 4px;
    background: var(--zw-color-primary);
    color: #ffffff;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
    font-family: var(--zw-font-body);
    border-radius: 100px;
    vertical-align: top;
}

.checkout-cart-count.large-count {
    min-width: 26px;
    padding: 0 5px;
    font-size: 10px;
}

/* Bounce animation triggered by JS */
@keyframes zw-cart-bounce {
    0%, 100% { transform: scale(1); }
    30%       { transform: scale(1.35); }
    60%       { transform: scale(0.9); }
}

.checkout-cart-count.bounce {
    animation: zw-cart-bounce 0.5s ease;
}

/* ==========================================================================
   18. Responsive overrides
   ========================================================================== */
@media (max-width: 767.98px) {
    .zw-xs-hidden {
        display: none !important;
    }

    /* Stack columns on mobile */
    #zw-cart-area .col-lg-7,
    #zw-cart-area .col-lg-5 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .zw-total-table-wrapper {
        margin-top: 24px;
    }
}
