/**
 * iHowz Shopping Cart — Styles
 *
 * Covers: cart widget, cart page, add-to-cart buttons, quantity controls,
 * remove buttons, toast notifications, upsell banner, cart badge, responsive.
 * Follows iHowz design system — using existing colour variables and patterns.
 *
 * @package    IHowz
 * @subpackage Documents
 * @version    1.0.0
 */

/* =====================================================
   ADD-TO-CART BUTTONS
   ===================================================== */

.ihowz-add-to-cart-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--primary-green, #9cc130);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    line-height: 1.4;
    text-decoration: none;
}

.ihowz-add-to-cart-btn:hover,
.ihowz-add-to-cart-btn:focus {
    background: #8ab02a;
    color: #fff;
    transform: translateY(-1px);
}

.ihowz-add-to-cart-btn:active {
    transform: translateY(0);
}

.ihowz-add-to-cart-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.ihowz-add-to-cart-added {
    background: var(--success-green, #4caf50) !important;
}

.ihowz-add-to-cart-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1.4;
}

/* Add-to-cart in different contexts */
.ihowz-card-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.ihowz-row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* =====================================================
   CART BADGE
   ===================================================== */

.ihowz-cart-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--primary-green, #9cc130);
    color: #fff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    position: relative;
    top: -8px;
    margin-left: -4px;
}

.ihowz-cart-badge:empty,
.ihowz-cart-badge[data-count="0"] {
    display: none;
}

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */

.ihowz-cart-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    z-index: 99999;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    max-width: 360px;
    word-wrap: break-word;
}

.ihowz-cart-toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.ihowz-cart-toast-success {
    background: var(--success-green, #4caf50);
}

.ihowz-cart-toast-error {
    background: var(--error-red, #f44336);
}

/* =====================================================
   CART WIDGET (SIDEBAR)
   ===================================================== */

.ihowz-cart-widget {
    background: #fff;
    border: 1px solid var(--neutral-gray-light, #e0e0e0);
    border-radius: 8px;
    padding: 16px;
    font-size: 14px;
}

.ihowz-cart-widget-title {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-charcoal, #263238);
    border-bottom: 2px solid var(--primary-green, #9cc130);
    padding-bottom: 8px;
}

.ihowz-cart-empty {
    color: var(--neutral-gray, #757575);
    font-style: italic;
    margin: 0;
    padding: 8px 0;
}

/* Widget items */
.ihowz-cart-widget-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ihowz-cart-widget-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.ihowz-cart-widget-item:last-child {
    border-bottom: none;
}

.ihowz-cart-widget-item-title {
    flex: 1;
    font-size: 13px;
    color: var(--primary-charcoal, #263238);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ihowz-cart-widget-item-qty {
    color: var(--neutral-gray, #757575);
    font-size: 12px;
    white-space: nowrap;
}

.ihowz-cart-widget-item-price {
    font-weight: 600;
    font-size: 13px;
    color: var(--primary-charcoal, #263238);
    white-space: nowrap;
}

.ihowz-cart-widget-remove {
    background: none;
    border: none;
    color: var(--neutral-gray, #999);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.ihowz-cart-widget-remove:hover {
    color: var(--error-red, #f44336);
}

/* Widget total */
.ihowz-cart-widget-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-top: 8px;
    border-top: 2px solid var(--neutral-gray-light, #e0e0e0);
    font-weight: 600;
}

.ihowz-cart-widget-total-label {
    font-size: 14px;
    color: var(--primary-charcoal, #263238);
}

.ihowz-cart-widget-total-value {
    font-size: 16px;
    color: var(--primary-green, #9cc130);
}

/* Widget action buttons */
.ihowz-cart-widget-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.ihowz-cart-widget-actions .ihowz-btn {
    display: block;
    text-align: center;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
}

/* =====================================================
   CART PAGE
   ===================================================== */

.ihowz-cart-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}

.ihowz-cart-page h2 {
    margin: 0 0 24px;
    font-size: 24px;
    color: var(--primary-charcoal, #263238);
}

/* Empty cart */
.ihowz-cart-empty-page {
    text-align: center;
    padding: 60px 20px;
    color: var(--neutral-gray, #757575);
}

.ihowz-cart-empty-page p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* Upsell banner (non-member) */
.ihowz-cart-upsell {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
    border: 1px solid var(--primary-green, #9cc130);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ihowz-cart-upsell p {
    margin: 0;
    font-size: 14px;
    color: var(--primary-charcoal, #263238);
    flex: 1;
}

.ihowz-cart-upsell .ihowz-btn-success {
    background: var(--primary-green, #9cc130);
    color: #fff;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

/* Cart table */
.ihowz-cart-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.ihowz-cart-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--neutral-gray, #757575);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--neutral-gray-light, #e0e0e0);
    background: #fafafa;
}

.ihowz-cart-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.ihowz-cart-table tbody tr:last-child td {
    border-bottom: none;
}

.ihowz-cart-cell-title {
    font-weight: 500;
    color: var(--primary-charcoal, #263238);
}

.ihowz-cart-cell-price {
    white-space: nowrap;
    color: var(--neutral-gray, #757575);
}

.ihowz-cart-cell-subtotal {
    font-weight: 600;
    white-space: nowrap;
    color: var(--primary-charcoal, #263238);
}

/* Quantity controls */
.ihowz-cart-cell-qty {
    display: flex;
    align-items: center;
    gap: 0;
}

.ihowz-cart-qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--neutral-gray-light, #e0e0e0);
    background: #fff;
    color: var(--primary-charcoal, #263238);
    font-size: 16px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}

.ihowz-cart-qty-btn:hover {
    background: #f5f5f5;
}

.ihowz-cart-qty-dec {
    border-radius: 4px 0 0 4px;
}

.ihowz-cart-qty-inc {
    border-radius: 0 4px 4px 0;
}

.ihowz-cart-qty-input {
    width: 50px;
    height: 32px;
    border: 1px solid var(--neutral-gray-light, #e0e0e0);
    border-left: none;
    border-right: none;
    text-align: center;
    font-size: 14px;
    padding: 0 4px;
    -moz-appearance: textfield;
}

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

.ihowz-cart-qty-input:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--primary-green, #9cc130);
}

/* Remove button */
.ihowz-cart-remove-btn {
    background: none;
    border: none;
    color: var(--neutral-gray, #999);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.ihowz-cart-remove-btn:hover {
    color: var(--error-red, #f44336);
}

/* Cart footer */
.ihowz-cart-footer {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.ihowz-cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--neutral-gray-light, #e0e0e0);
}

.ihowz-cart-total-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-charcoal, #263238);
}

.ihowz-cart-total-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-green, #9cc130);
}

.ihowz-cart-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.ihowz-cart-actions .ihowz-btn {
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}

.ihowz-cart-clear-btn {
    margin-right: auto;
}

/* =====================================================
   BUTTON VARIANTS (shared)
   ===================================================== */

.ihowz-btn-primary {
    background: var(--primary-green, #9cc130);
    color: #fff !important;
    border: 1px solid var(--primary-green, #9cc130);
}

.ihowz-btn-primary:hover {
    background: #8ab02a;
    color: #fff !important;
}

.ihowz-btn-secondary {
    background: var(--background-pure-white, #fff);
    color: var(--primary-charcoal, #263238) !important;
    border: 1px solid var(--neutral-gray-light, #e0e0e0);
}

.ihowz-btn-secondary:hover {
    background: #f5f5f5;
    color: var(--primary-charcoal, #263238) !important;
}

.ihowz-btn-danger {
    background: var(--background-pure-white, #fff);
    color: var(--error-red, #f44336) !important;
    border: 1px solid var(--error-red, #f44336);
}

.ihowz-btn-danger:hover {
    background: #fff5f5;
    color: var(--error-red, #d32f2f) !important;
}

.ihowz-btn-success {
    background: var(--primary-green, #9cc130);
    color: #fff !important;
    border: 1px solid var(--primary-green, #9cc130);
}

.ihowz-btn-success:hover {
    background: #8ab02a;
    color: #fff !important;
}

.ihowz-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =====================================================
   RESPONSIVE BREAKPOINTS
   ===================================================== */

@media (max-width: 768px) {
    /* Cart page - stack on mobile */
    .ihowz-cart-page {
        padding: 10px;
    }

    .ihowz-cart-table thead {
        display: none;
    }

    .ihowz-cart-table tbody tr {
        display: block;
        padding: 12px 0;
        border-bottom: 1px solid #f0f0f0;
    }

    .ihowz-cart-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border-bottom: none;
    }

    .ihowz-cart-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--neutral-gray, #757575);
        font-size: 12px;
        text-transform: uppercase;
        margin-right: 8px;
    }

    .ihowz-cart-cell-title::before { content: 'Item'; }
    .ihowz-cart-cell-price::before { content: 'Price'; }
    .ihowz-cart-cell-qty::before { content: 'Qty'; }
    .ihowz-cart-cell-subtotal::before { content: 'Subtotal'; }

    .ihowz-cart-footer {
        padding: 16px;
    }

    .ihowz-cart-actions {
        flex-direction: column;
    }

    .ihowz-cart-actions .ihowz-btn {
        width: 100%;
    }

    .ihowz-cart-clear-btn {
        margin-right: 0;
        order: 3;
    }

    /* Upsell banner */
    .ihowz-cart-upsell {
        flex-direction: column;
        text-align: center;
    }

    .ihowz-cart-upsell p {
        text-align: center;
    }

    /* Toast on mobile */
    .ihowz-cart-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }

    /* Widget on mobile */
    .ihowz-cart-widget-actions {
        flex-direction: row;
    }

    .ihowz-cart-widget-actions .ihowz-btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .ihowz-cart-table tbody td {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .ihowz-cart-cell-qty {
        flex-direction: row;
    }

    .ihowz-add-to-cart-btn {
        width: 100%;
        justify-content: center;
    }

    .ihowz-card-actions {
        flex-direction: column;
    }
}
