/**
 * TUH Cart - Base Styles
 * Estilos compartilhados entre side cart e cart page
 *
 * @package TUH_Checkout
 * @subpackage Features/Cart
 * @since 2.2.0
 */

/* ======= CSS Variables ======= */
:root {
    --tuh-cart-bg: #ffffff;
    --tuh-cart-header-bg: #f8fafc;
    --tuh-cart-text: #1f2937;
    --tuh-cart-text-muted: #6b7280;
    --tuh-cart-border: #e5e7eb;
    --tuh-cart-button: var(--tuh-primary, #8C52FF);
    --tuh-cart-button-hover: var(--tuh-primary-hover, #7c3aed);
    --tuh-cart-button-text: #ffffff;
    --tuh-cart-success: #10b981;
    --tuh-cart-error: #ef4444;
    --tuh-cart-radius: 12px;
    --tuh-cart-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --tuh-cart-transition: 0.3s ease;
}

/* ======= Reset ======= */
.tuh-cart *,
.tuh-cart *::before,
.tuh-cart *::after {
    box-sizing: border-box;
}

/* ======= Typography & CSS Containment ======= */
.tuh-cart {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--tuh-cart-text);
    /* CSS Containment - Isola estilos do tema */
    contain: layout style;
    isolation: isolate;
}

.tuh-cart-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--tuh-cart-text);
}

.tuh-cart-subtitle {
    font-size: 13px;
    color: var(--tuh-cart-text-muted);
    margin: 0;
}

/* ======= Product Item ======= */
.tuh-cart-item {
    display: flex !important;
    gap: 15px !important;
    padding: 15px !important;
    margin-bottom: 12px !important;
    background: var(--tuh-cart-header-bg, #f8fafc) !important;
    border: 1px solid var(--tuh-cart-border, #e5e7eb) !important;
    border-radius: 8px !important;
}

.tuh-cart-item:last-child {
    margin-bottom: 0 !important;
}

.tuh-cart-item-image {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--tuh-cart-header-bg);
}

.tuh-cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tuh-cart-item-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.tuh-cart-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--tuh-cart-text);
    margin: 0 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tuh-cart-item-meta {
    font-size: 12px !important;
    color: var(--tuh-cart-text-muted) !important;
}

/* ======= Item Header (nome + botão remover) ======= */
.tuh-cart-item-header {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin-bottom: 4px !important;
}

.tuh-cart-item-name-wrap {
    flex: 1 !important;
    min-width: 0 !important;
}

/* ======= Price Line (preço + PIX) ======= */
.tuh-cart-item-price-line {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    margin-bottom: 4px !important;
}

.tuh-cart-item-price-main {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--tuh-cart-text) !important;
    line-height: 1.3 !important;
}

.tuh-cart-item-price-discount {
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--tuh-cart-success, #10b981) !important;
    line-height: 1.3 !important;
}

/* ======= Item Actions (qty + parcelamento) ======= */
.tuh-cart-item-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    margin-top: 4px !important;
}

.tuh-cart-item-installment {
    font-size: 12px !important;
    color: var(--tuh-cart-text-muted, #6b7280) !important;
    white-space: nowrap !important;
}

/* Legacy (não usados no template atual) */
.tuh-cart-item-price {
    font-size: 15px;
    font-weight: 600;
    color: var(--tuh-cart-text);
}

.tuh-cart-item-price del {
    color: var(--tuh-cart-text-muted);
    font-weight: 400;
    font-size: 13px;
    margin-right: 6px;
}

.tuh-cart-item-price ins {
    text-decoration: none;
    color: var(--tuh-cart-success);
}

/* ======= Quantity Selector ======= */
.tuh-cart-qty {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    background: transparent !important;
}

.tuh-cart-qty-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: 1px solid var(--tuh-cart-button, #8C52FF) !important;
    border-radius: 4px !important;
    color: var(--tuh-cart-button, #8C52FF) !important;
    cursor: pointer !important;
    font-size: 16px !important;
    font-weight: bold !important;
    transition: background 0.2s ease !important;
    padding: 0 !important;
}

.tuh-cart .tuh-cart-qty-btn svg,
.tuh-side-cart .tuh-cart-qty-btn svg,
.tuh-cart-qty-btn svg {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    min-height: 14px !important;
    stroke: currentColor !important;
    stroke-width: 2.5 !important;
    color: inherit !important;
    fill: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.tuh-cart-qty-btn:hover {
    background: var(--tuh-cart-button, #8C52FF) !important;
    color: var(--tuh-cart-button-text, #fff) !important;
}

.tuh-cart-qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tuh-cart-qty-value {
    width: 45px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border: 1px solid var(--tuh-cart-border, #e5e7eb) !important;
    border-radius: 4px !important;
    background: var(--tuh-cart-header-bg, #f8fafc) !important;
    color: var(--tuh-cart-text) !important;
}

/* ======= Remove Button ======= */
.tuh-cart-remove {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.25) !important;
    color: var(--tuh-cart-error, #ef4444) !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    font-size: 18px !important;
    font-weight: bold !important;
    line-height: 1 !important;
}

.tuh-cart-remove:hover {
    background: var(--tuh-cart-error, #ef4444) !important;
    border-color: var(--tuh-cart-error, #ef4444) !important;
    color: #fff !important;
    transform: scale(1.05) !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3) !important;
}

.tuh-cart-remove svg {
    width: 16px;
    height: 16px;
}

/* ======= Free Shipping Bar ======= */
.tuh-cart-shipping-bar {
    background: var(--tuh-cart-header-bg);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.tuh-cart-shipping-progress {
    height: 6px;
    background: var(--tuh-cart-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.tuh-cart-shipping-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tuh-cart-button), var(--tuh-cart-success));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.tuh-cart-shipping-text {
    font-size: 13px;
    color: var(--tuh-cart-text);
    text-align: center;
}

.tuh-cart-shipping-text strong {
    color: var(--tuh-cart-button);
}

.tuh-cart-shipping-achieved {
    color: var(--tuh-cart-success);
    font-weight: 500;
}

.tuh-cart-shipping-achieved::before {
    content: "\2713";
    margin-right: 6px;
}

/* ======= Coupon Field ======= */
.tuh-cart-coupon {
    display: flex !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
}

.tuh-cart-coupon-input {
    flex: 1 !important;
    padding: 10px 14px !important;
    border: 1px solid var(--tuh-cart-border) !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    color: var(--tuh-cart-text) !important;
    background: var(--tuh-cart-bg) !important;
    transition: border-color var(--tuh-cart-transition) !important;
    min-height: auto !important;
}

.tuh-cart-coupon-input:focus {
    outline: none !important;
    border-color: var(--tuh-cart-button) !important;
}

.tuh-cart-coupon-input::placeholder {
    color: var(--tuh-cart-text-muted) !important;
}

.tuh-cart-coupon-btn {
    padding: 10px 16px !important;
    background: var(--tuh-cart-header-bg) !important;
    border: 1px solid var(--tuh-cart-border) !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--tuh-cart-text) !important;
    cursor: pointer !important;
    transition: all var(--tuh-cart-transition) !important;
    white-space: nowrap !important;
    min-height: auto !important;
}

.tuh-cart-coupon-btn:hover {
    background: var(--tuh-cart-border) !important;
}

/* ======= Totals ======= */
.tuh-cart-totals {
    padding-top: 16px;
    border-top: 1px solid var(--tuh-cart-border);
}

.tuh-cart-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
}

.tuh-cart-totals-row.subtotal {
    color: var(--tuh-cart-text-muted);
}

.tuh-cart-totals-row.discount {
    color: var(--tuh-cart-success);
}

.tuh-cart-totals-row.shipping {
    color: var(--tuh-cart-text-muted);
}

.tuh-cart-totals-row.total {
    font-size: 18px;
    font-weight: 700;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 2px solid var(--tuh-cart-border);
}

/* ======= Buttons ======= */
.tuh-cart-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 14px 24px !important;
    border-radius: 10px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all var(--tuh-cart-transition) !important;
    text-decoration: none !important;
    border: none !important;
    min-height: auto !important;
    box-shadow: none !important;
    text-transform: none !important;
    text-shadow: none !important;
    line-height: 1.4 !important;
}

.tuh-cart-btn-primary {
    background: var(--tuh-cart-button) !important;
    color: var(--tuh-cart-button-text) !important;
}

.tuh-cart-btn-primary:hover {
    background: var(--tuh-cart-button-hover) !important;
    color: var(--tuh-cart-button-text) !important;
    box-shadow: 0 4px 12px rgba(140, 82, 255, 0.3) !important;
}

.tuh-cart-btn-outline {
    background: transparent !important;
    color: var(--tuh-cart-text) !important;
    border: 1px solid var(--tuh-cart-border) !important;
}

.tuh-cart-btn-outline:hover {
    background: var(--tuh-cart-header-bg) !important;
    color: var(--tuh-cart-text) !important;
}

.tuh-cart-btn-secondary {
    background: #374151 !important;
    color: #ffffff !important;
    border: none !important;
}

.tuh-cart-btn-secondary:hover {
    background: #1f2937 !important;
    color: #ffffff !important;
}

.tuh-cart-btn-link {
    background: transparent !important;
    color: var(--tuh-cart-button) !important;
    padding: 8px !important;
}

.tuh-cart-btn-link:hover {
    text-decoration: underline !important;
}

.tuh-cart-btn-continue {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 10px 16px !important;
    margin-bottom: 12px !important;
    background: transparent !important;
    color: var(--tuh-cart-text-muted, #6b7280) !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    min-height: auto !important;
    text-transform: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
    line-height: 1.4 !important;
}

.tuh-cart-btn-continue:hover {
    color: var(--tuh-cart-text, #1f2937) !important;
    background: var(--tuh-cart-header-bg, #f8fafc) !important;
}

/* ======= Buttons Grid ======= */
.tuh-cart-buttons-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
}

/* ======= Empty Cart ======= */
.tuh-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.tuh-cart-empty-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    color: var(--tuh-cart-text-muted);
    opacity: 0.5;
}

.tuh-cart-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--tuh-cart-text);
    margin: 0 0 8px;
}

.tuh-cart-empty-text {
    font-size: 14px;
    color: var(--tuh-cart-text-muted);
    margin: 0 0 24px;
}

/* ======= Loading State ======= */
.tuh-cart-loading {
    position: relative;
    pointer-events: none;
}

.tuh-cart-loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.tuh-cart-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--tuh-cart-border);
    border-top-color: var(--tuh-cart-button);
    border-radius: 50%;
    animation: tuh-cart-spin 0.8s linear infinite;
}

@keyframes tuh-cart-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ======= Notifications ======= */
.tuh-cart-notice {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tuh-cart-notice-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.tuh-cart-notice-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.tuh-cart-notice-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ======= Animations ======= */
@keyframes tuh-cart-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tuh-cart-slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes tuh-cart-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.tuh-cart-item-added {
    animation: tuh-cart-pulse 0.3s ease;
}

/* ======= Body State ======= */
body.tuh-side-cart-open {
    overflow: hidden;
}

/* ======= Item Badges ======= */
.tuh-cart-item-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.tuh-cart-item-badge-bump {
    background: linear-gradient(135deg, #fefce8, #fef9c3);
    color: #a16207;
}

/* ======= Item Layout ======= */
.tuh-cart-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.tuh-cart-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

/* ======= Remove Coupon Link ======= */
.tuh-cart-remove-coupon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    color: var(--tuh-cart-success);
    opacity: 0.7;
    transition: opacity var(--tuh-cart-transition);
    vertical-align: middle;
}

.tuh-cart-remove-coupon:hover {
    opacity: 1;
}
