/**
 * TUH Cart - Side Cart Styles
 * Carrinho lateral que abre ao adicionar produtos
 *
 * @package TUH_Checkout
 * @subpackage Features/Cart
 * @since 2.2.0
 */

/* Z-index e cores são injetados via wp_add_inline_style em SideCart.php */
/* Theme isolation reset está inline no template (side-cart.php) */

/* ======= RESET SVG - Específico para SVGs do TUH ======= */
/* Usa seletores específicos em vez de !important excessivo */
.tuh-cart-icon-floating svg,
.tuh-side-cart svg,
.tuh-side-cart-close svg,
.tuh-suggested-popup svg,
.tuh-suggested-popup-close svg,
.tuh-cart-qty-btn svg,
.tuh-cart-remove svg {
    display: inline-block;
    visibility: visible;
    opacity: 1;
    pointer-events: none;
    box-sizing: content-box;
    max-width: none;
    max-height: none;
}

/* Alta especificidade para garantir visibilidade (fallback) */
html body .tuh-side-cart svg,
html body .tuh-cart-icon-floating svg {
    visibility: visible;
    opacity: 1;
}

/* ======= Overlay ======= */
.tuh-side-cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--tuh-cart-transition);
    z-index: var(--tuh-z-overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    contain: layout style paint;
    margin: 0;
    padding: 0;
    border: none;
}

.tuh-side-cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ======= Side Cart Container ======= */
.tuh-side-cart {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 100%;
    max-width: var(--tuh-side-cart-width, 420px);
    background: var(--tuh-cart-bg);
    box-shadow: var(--tuh-cart-shadow);
    z-index: var(--tuh-z-cart);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--tuh-cart-transition);
    /* CSS Containment - Isola estilos do tema */
    contain: layout style;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: none;
    border-left: 1px solid var(--tuh-cart-border);
}

.tuh-side-cart.active {
    transform: translateX(0);
}

/* ======= Header ======= */
.tuh-side-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--tuh-cart-header-bg);
    border-bottom: 1px solid var(--tuh-cart-border);
    border-top: none;
    border-left: none;
    border-right: none;
    flex-shrink: 0;
    margin: 0;
}

.tuh-side-cart-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tuh-side-cart-header-icon {
    width: 24px;
    height: 24px;
    color: var(--tuh-cart-button);
}

.tuh-side-cart-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--tuh-cart-text);
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.tuh-side-cart-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--tuh-cart-button);
    color: var(--tuh-cart-button-text);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

/* ======= Close Button ======= */
.tuh-side-cart .tuh-side-cart-header .tuh-side-cart-close,
html body .tuh-side-cart-close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--tuh-cart-border, #e5e7eb);
    color: var(--tuh-cart-text-muted, #6b7280);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
    box-shadow: none;
    flex-shrink: 0;
    text-shadow: none;
    text-transform: none;
    font-size: 20px;
    line-height: 1;
}

html body .tuh-side-cart-close:hover {
    background: var(--tuh-cart-header-bg, #f3f4f6);
    color: var(--tuh-cart-text, #1f2937);
}

/* SVG do botão fechar — herda cor do parent */
html body .tuh-side-cart .tuh-side-cart-close svg,
html body #tuh-side-cart-close svg {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    max-width: 16px;
    max-height: 16px;
    stroke: currentColor;
    stroke-width: 2.5;
    color: inherit;
    fill: none;
    display: block;
    visibility: visible;
    opacity: 1;
    overflow: visible;
    transform: none;
    position: static;
}

html body .tuh-side-cart-close svg line {
    stroke: currentColor;
    stroke-width: 2.5;
    fill: none;
    display: inline;
}

/* ======= Content ======= */
.tuh-side-cart-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.tuh-side-cart .tuh-cart-discount-preview {
    text-align: center;
}

.tuh-side-cart .tuh-cart-discount-preview-row {
    width: 100%;
    justify-content: center;
}

.tuh-side-cart .tuh-cart-discount-preview-badge {
    align-self: center;
}

/* Custom Scrollbar */
.tuh-side-cart-content::-webkit-scrollbar {
    width: 6px;
}

.tuh-side-cart-content::-webkit-scrollbar-track {
    background: transparent;
}

.tuh-side-cart-content::-webkit-scrollbar-thumb {
    background: var(--tuh-cart-border);
    border-radius: 3px;
}

.tuh-side-cart-content::-webkit-scrollbar-thumb:hover {
    background: var(--tuh-cart-text-muted);
}

/* ======= Shipping Bar in Side Cart ======= */
.tuh-side-cart .tuh-cart-shipping-bar {
    margin: 16px;
    margin-bottom: 0;
    border-radius: 10px;
}

/* ======= Items Container ======= */
.tuh-side-cart-items {
    padding: 0 20px;
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tuh-side-cart-items .tuh-cart-item {
    margin-bottom: 0;
}

/* ======= Coupon in Side Cart ======= */
.tuh-side-cart-content .tuh-cart-coupon {
    padding: 0 20px;
    margin-bottom: 0;
}

.tuh-cart-coupon-footer {
    padding: 0;
    margin-bottom: 12px;
}

/* ======= Footer ======= */
.tuh-side-cart-footer {
    padding: 16px 20px 20px;
    background: var(--tuh-cart-bg);
    border-top: 1px solid var(--tuh-cart-border);
    border-bottom: none;
    border-left: none;
    border-right: none;
    flex-shrink: 0;
    margin: 0;
    box-shadow: 0 -8px 16px rgba(16, 24, 40, 0.04);
}

.tuh-side-cart-footer .tuh-cart-totals {
    padding-top: 0;
    border-top: none;
    margin-bottom: 12px;
}

.tuh-side-cart-footer .tuh-cart-btn {
    margin-bottom: 0;
}

/* ======= Suggested Products Trigger ======= */
.tuh-suggested-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--tuh-cart-bg, #fff);
    border: 1px solid var(--tuh-cart-border, #e5e7eb);
    border-radius: 10px;
    color: var(--tuh-cart-text-muted, #6b7280);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: auto;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
}

.tuh-suggested-trigger:hover {
    background: var(--tuh-cart-bg, #fff);
    border-color: var(--tuh-cart-button, var(--tuh-primary, #8C52FF));
    color: var(--tuh-cart-button, var(--tuh-primary, #8C52FF));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tuh-suggested-trigger svg {
    flex-shrink: 0;
    color: #f59e0b;
}

/* ======= Density Presets ======= */
.tuh-cart[data-density="compact"] .tuh-side-cart-header {
    padding: 12px 16px;
}

.tuh-cart[data-density="compact"] .tuh-side-cart-header-title {
    font-size: 15px;
}

.tuh-cart[data-density="compact"] .tuh-side-cart-items {
    padding: 0 16px;
    padding-top: 12px;
    gap: 10px;
}

.tuh-cart[data-density="compact"] .tuh-cart-item {
    padding: 12px;
    gap: 10px;
}

.tuh-cart[data-density="compact"] .tuh-cart-qty-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
}

.tuh-cart[data-density="compact"] .tuh-cart-qty-value {
    width: 36px;
    height: 28px;
    font-size: 13px;
}

.tuh-cart[data-density="compact"] .tuh-cart-btn {
    padding: 10px 14px;
    font-size: 14px;
}

.tuh-cart[data-density="compact"] .tuh-cart-buttons-grid {
    gap: 6px;
}

.tuh-cart[data-density="compact"] .tuh-cart-coupon {
    gap: 8px;
    margin-bottom: 10px;
}

.tuh-cart[data-density="compact"] .tuh-side-cart-footer {
    padding: 14px 16px 16px;
}

.tuh-cart[data-density="slim"] .tuh-side-cart-header {
    padding: 10px 14px;
}

.tuh-cart[data-density="slim"] .tuh-side-cart-header-title {
    font-size: 14px;
}

.tuh-cart[data-density="slim"] .tuh-side-cart-count {
    min-width: 18px;
    height: 18px;
    font-size: 10px;
}

.tuh-cart[data-density="slim"] .tuh-side-cart-items {
    padding: 0 14px;
    padding-top: 10px;
    gap: 8px;
}

.tuh-cart[data-density="slim"] .tuh-cart-item {
    padding: 10px;
    gap: 8px;
}

.tuh-cart[data-density="slim"] .tuh-cart-item-name {
    font-size: 13px;
    margin-bottom: 4px;
}

.tuh-cart[data-density="slim"] .tuh-cart-qty-btn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
}

.tuh-cart[data-density="slim"] .tuh-cart-qty-value {
    width: 32px;
    height: 26px;
    font-size: 12px;
}

.tuh-cart[data-density="slim"] .tuh-cart-coupon-footer {
    margin-bottom: 8px;
}

.tuh-cart[data-density="slim"] .tuh-cart-coupon-input {
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 8px;
}

.tuh-cart[data-density="slim"] .tuh-cart-coupon-btn {
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 8px;
}

.tuh-cart[data-density="slim"] .tuh-suggested-trigger {
    background: var(--tuh-cart-bg, #fff);
    border: 1px solid var(--tuh-cart-border, #e5e7eb);
    padding: 6px 10px;
    margin-bottom: 8px;
    justify-content: center;
    color: var(--tuh-cart-text-muted, #6b7280);
    border-radius: 8px;
    box-shadow: none;
}

.tuh-cart[data-density="slim"] .tuh-suggested-trigger:hover {
    background: var(--tuh-cart-bg, #fff);
    border-color: var(--tuh-cart-button, var(--tuh-primary, #8C52FF));
    color: var(--tuh-cart-text, #1f2937);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tuh-cart[data-density="slim"] .tuh-cart-totals-row {
    padding: 6px 0;
    font-size: 12px;
}

.tuh-cart[data-density="slim"] .tuh-cart-discount-preview,
.tuh-cart[data-density="slim"] .tuh-cart-installment-total {
    padding: 8px 10px;
    margin: 8px 0;
}

.tuh-cart[data-density="slim"] .tuh-cart-discount-preview-value {
    font-size: 14px;
}

.tuh-cart[data-density="slim"] .tuh-cart-installment-value {
    font-size: 13px;
}

.tuh-cart[data-density="compact"] .tuh-cart-discount-preview {
    text-align: center;
}

.tuh-cart[data-density="compact"] .tuh-cart-discount-preview-row {
    width: 100%;
    justify-content: center;
}

.tuh-cart[data-density="compact"] .tuh-cart-discount-preview-badge {
    align-self: center;
}

.tuh-cart[data-density="slim"] .tuh-cart-btn-continue {
    padding: 6px 8px;
    font-size: 12px;
    margin-bottom: 8px;
}

.tuh-cart[data-density="slim"] .tuh-cart-buttons-grid {
    gap: 6px;
}

.tuh-cart[data-density="slim"] .tuh-cart-btn {
    padding: 10px 12px;
    font-size: 14px;
}

.tuh-cart[data-density="slim"] .tuh-side-cart-footer {
    padding: 12px 14px 14px;
}

/* ======= Cart Icon Floating ======= */
/* Estilos visuais do botão flutuante estão inline no template (side-cart.php)
   porque dependem de valores PHP (posição, cores do template) */

/* Hide floating button when cart is open - CRITICAL
 * Usando apenas opacity/visibility/transform para permitir transição suave
 * NÃO usar display:none pois conflita com JS show/hide
 */
body.tuh-side-cart-open .tuh-cart-icon-floating,
.tuh-side-cart-open .tuh-cart-icon-floating,
html.tuh-side-cart-open .tuh-cart-icon-floating,
.tuh-cart-icon-floating.tuh-floating-cart-open {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.8) translateY(20px);
}

/* Hide when cart is empty (PHP controlled) */
.tuh-cart-icon-floating.tuh-floating-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.8);
}

/* Ensure floating button is visible by default */
.tuh-cart-icon-floating {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

/* ======= Responsive ======= */
@media (max-width: 480px) {
    .tuh-side-cart {
        max-width: 100%;
    }

    .tuh-side-cart-header {
        padding: 16px;
    }

    .tuh-side-cart-items {
        padding: 0 16px;
    }

    .tuh-side-cart-footer {
        padding: 16px;
    }

    .tuh-side-cart .tuh-cart-shipping-bar {
        margin: 12px;
    }

    .tuh-side-cart .tuh-cart-coupon {
        padding: 0 16px;
    }
}

@media (max-height: 700px) {
    .tuh-side-cart-footer {
        padding: 12px 16px 16px;
    }

    .tuh-cart-coupon {
        gap: 6px;
    }

    .tuh-cart-coupon-input {
        padding: 8px 10px;
        font-size: 12px;
    }

    .tuh-cart-coupon-btn {
        padding: 8px 10px;
        font-size: 12px;
    }

    .tuh-suggested-trigger {
        padding: 6px 10px;
        font-size: 12px;
        margin-bottom: 8px;
    }

    .tuh-cart-btn-continue {
        padding: 6px 8px;
        font-size: 12px;
        margin-bottom: 8px;
    }
}

@media (max-width: 420px) {
    .tuh-cart-buttons-grid {
        grid-template-columns: 1fr;
    }

    .tuh-cart-coupon {
        flex-direction: column;
    }
}

@media (max-width: 360px) {
    .tuh-cart-item-image {
        width: 60px;
        height: 60px;
    }

    .tuh-cart-item-name {
        font-size: 13px;
    }
}

/* ======= Dark Mode Support ======= */
@media (prefers-color-scheme: dark) {
    .tuh-side-cart-overlay {
        background: rgba(0, 0, 0, 0.7);
    }
}

/* ======= Print ======= */
@media print {
    .tuh-side-cart,
    .tuh-side-cart-overlay,
    .tuh-cart-icon-floating {
        display: none;
    }
}

/* ======= Add to Cart Notification ======= */
.tuh-add-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: var(--tuh-z-notification);
    max-width: 380px;
    opacity: 0;
    transition: opacity 0.2s ease;
    border: 1px solid #e5e7eb;
}

.tuh-add-notification.active {
    opacity: 1;
}

.tuh-add-notification-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
}

.tuh-add-notification-text {
    flex: 1;
    font-size: 14px;
    color: #1f2937;
    line-height: 1.4;
}

.tuh-add-notification-cart {
    background: var(--tuh-cart-button, var(--tuh-primary, #8C52FF));
    color: var(--tuh-cart-button-text, #fff);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tuh-add-notification-cart:hover {
    box-shadow: 0 4px 12px rgba(140, 82, 255, 0.3);
}

@media (max-width: 480px) {
    .tuh-add-notification {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }
}
