/**
 * Premium Native Side Cart Styling
 * Focus on UX, CRO, Glassmorphism, and smooth transitions
 */

/* 1. Backdrop Overlay */
.pn-sc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999990;
    transition: opacity 0.4s ease, visibility 0.4s;
    opacity: 0;
    visibility: hidden;
}

.pn-sc-overlay.pn-sc-active {
    opacity: 1;
    visibility: visible;
}

/* 2. Side Cart Drawer Drawer */
.pn-sc-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh; /* dvh desconta a barra do navegador no mobile — sem isso o
                       rodapé (botão finalizar) fica abaixo da área visível */
    background-color: #FFFFFF;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
    z-index: 999995;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s;
    transform: translateX(100%);
    visibility: hidden;
}

.pn-sc-drawer.pn-sc-active {
    transform: translateX(0);
    visibility: visible;
}

/* States of drawer visibility helper */
.pn-sc-hidden {
    pointer-events: none;
}

/* 3. Header */
.pn-sc-header {
    padding: 20px;
    border-bottom: 1px solid #EAEAEA;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #FFFFFF;
}

.pn-sc-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pn-sc-title {
    font-size: 18px;
    font-weight: 700;
    color: #222222;
}

.pn-sc-badge {
    background-color: #128C7E;
    color: #FFFFFF;
    font-size: 12px;
    font-weight: bold;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    padding: 0 6px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pn-sc-close-btn {
    background: none;
    border: none;
    color: #666666;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.pn-sc-close-btn:hover {
    background-color: #F5F5F5;
    color: #222222;
}

/* 4. Scrollable Content Wrapper */
.pn-side-cart-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* 5. Empty State styling */
.pn-sc-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
    color: #8C8C8C;
}

.pn-sc-empty-state svg {
    margin-bottom: 16px;
    color: #D3D3D3;
}

.pn-sc-empty-msg {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 24px;
}

.pn-sc-btn-continue {
    background-color: #128C7E;
    color: #FFFFFF;
    border: none;
    padding: 12px 24px;
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(18, 140, 126, 0.15);
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.pn-sc-btn-continue:hover {
    background-color: #0F7569;
}

.pn-sc-btn-continue:active {
    transform: scale(0.98);
}

/* 6. Active Items List */
.pn-sc-items-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 10px 20px;
}

.pn-sc-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pn-sc-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #F5F5F5;
    position: relative;
}

.pn-sc-item:last-child {
    border-bottom: none;
}

/* Item image */
.pn-sc-item-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    border: 1px solid #EAEAEA;
    overflow: hidden;
    flex-shrink: 0;
}

.pn-sc-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Details and meta */
.pn-sc-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Ensures line wrap handles long text */
}

.pn-sc-item-title {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.pn-sc-item-title a {
    color: #222222;
    text-decoration: none;
    transition: color 0.2s ease;
}

.pn-sc-item-title a:hover {
    color: #128C7E;
}

.pn-sc-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.pn-sc-item-qty {
    font-weight: 700;
    color: #128C7E;
    background-color: rgba(18, 140, 126, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
}

.pn-sc-item-price {
    font-weight: 500;
    color: #666666;
}

/* Item deletion */
.pn-sc-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
}

a.remove.pn-sc-remove-btn::before {
    display: none !important;
}

a.remove.pn-sc-remove-btn {
    font-size: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background-color: transparent !important;
    color: #AAAAAA !important;
    transition: color 0.2s ease, background-color 0.2s ease !important;
    cursor: pointer !important;
    padding: 0 !important;
    border: none !important;
    line-height: 0 !important;
    text-decoration: none !important;
}

a.remove.pn-sc-remove-btn:hover {
    color: #FF3B30 !important;
    background-color: #FFF5F5 !important;
}

/* 7. Footer Totals & Checkout CTAs */
.pn-sc-footer {
    background-color: #FAFAFA;
    border-top: 1px solid #EAEAEA;
    padding: 20px;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.02);
}

/* --- Premium Coupon & Shipping Elements --- */
.pn-sc-coupon-wrapper,
.pn-sc-shipping-wrapper {
    margin-top: 20px;
    padding: 16px;
    background-color: #F8FAFC;
    border: 1.5px solid #E2E8F0;
    border-radius: 12px;
}

.pn-sc-coupon-wrapper {
    margin-top: 24px;
}

.pn-sc-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pn-sc-coupon-form,
.pn-sc-shipping-form {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.pn-sc-input {
    flex: 1;
    height: 38px;
    border: 1.5px solid #CBD5E1;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 13.5px;
    color: #1E293B;
    background-color: #FFFFFF;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.pn-sc-input:focus {
    border-color: #128C7E;
    box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.12);
}

.pn-sc-action-btn {
    height: 38px;
    padding: 0 16px;
    background-color: #128C7E;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.pn-sc-action-btn:hover {
    background-color: #0F7569;
}

.pn-sc-action-btn:active {
    transform: scale(0.97);
}

/* Coupon Chips (Recompensas aplicadas) */
.pn-sc-applied-coupons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.pn-sc-coupon-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(18, 140, 126, 0.08);
    border: 1px dashed rgba(18, 140, 126, 0.4);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    color: #0F7569;
}

.pn-sc-remove-coupon-btn {
    color: #0F7569;
    text-decoration: none;
    font-weight: 700;
    font-size: 11px;
    width: 16px;
    height: 16px;
    background-color: rgba(18, 140, 126, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
    line-height: 1;
}

.pn-sc-remove-coupon-btn:hover {
    background-color: #FF3B30;
    color: #FFFFFF;
}

/* Shipping Methods Selector (RPG Console style) */
.pn-sc-shipping-methods-container {
    margin-top: 14px;
    background-color: #FFFFFF;
    border: 1.5px solid #E2E8F0;
    border-radius: 10px;
    padding: 12px;
}

.pn-sc-shipping-methods-title {
    font-size: 11px;
    font-weight: 700;
    color: #64748B;
    text-transform: uppercase;
    display: block;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.pn-sc-shipping-methods-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pn-sc-shipping-method-item {
    border: 1.5px solid #E2E8F0;
    border-radius: 8px;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.pn-sc-shipping-method-item:hover {
    border-color: #CBD5E1;
    background-color: #F8FAFC;
}

.pn-sc-shipping-method-item:has(input[type="radio"]:checked) {
    border-color: #128C7E;
    background-color: rgba(18, 140, 126, 0.03);
}

.pn-sc-shipping-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}

.pn-sc-shipping-radio {
    margin: 0;
    width: 16px;
    height: 16px;
    accent-color: #128C7E;
    cursor: pointer;
}

.pn-sc-shipping-method-text {
    flex: 1;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
}

.pn-sc-method-name {
    color: #334155;
}

.pn-sc-method-cost {
    color: #128C7E;
    font-weight: 700;
}

.pn-sc-shipping-empty {
    font-size: 13px;
    color: #94A3B8;
    margin-top: 10px;
    text-align: center;
}

/* Feedback messages */
.pn-sc-coupon-message,
.pn-sc-shipping-message {
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
    padding-left: 2px;
}

.pn-sc-msg-error {
    color: #EF4444;
}

.pn-sc-msg-success {
    color: #10B981;
}

/* --- Totals Breakdown Footers --- */
.pn-sc-totals-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.pn-sc-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13.5px;
}

.pn-sc-total-row .pn-sc-label {
    color: #64748B;
    font-weight: 600;
}

.pn-sc-total-row .pn-sc-val {
    color: #334155;
    font-weight: 700;
}

.pn-sc-subtotal-row .pn-sc-val,
.pn-sc-coupon-row .pn-sc-val,
.pn-sc-shipping-row .pn-sc-val {
    font-size: 14px;
}

.pn-sc-coupon-row .pn-sc-val {
    color: #EF4444;
}

.pn-sc-grand-total-row {
    border-top: 1px dashed #E2E8F0;
    padding-top: 12px;
    margin-top: 4px;
}

.pn-sc-grand-total-row .pn-sc-label {
    font-size: 15px;
    font-weight: 700;
    color: #1E293B;
}

.pn-sc-grand-total-row .pn-sc-val {
    font-size: 18px;
    font-weight: 800;
    color: #128C7E;
}

.pn-sc-actions-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pn-sc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    height: 48px;
    border-radius: 24px;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

/* Checkout CTA Button */
.pn-sc-btn-checkout {
    background-color: #25D366;
    color: #FFFFFF;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.25);
    border: none;
}

.pn-sc-btn-checkout:hover {
    background-color: #20BA5A;
    box-shadow: 0 6px 18px rgba(37, 211, 102, 0.35);
    color: #FFFFFF !important;
}

.pn-sc-btn-checkout:active {
    transform: translateY(1px);
}

.pn-sc-btn-checkout svg {
    transition: transform 0.2s ease;
}

.pn-sc-btn-checkout:hover svg {
    transform: translateX(2px);
}

/* Viewcart Button */
.pn-sc-btn-viewcart {
    background-color: transparent;
    color: #666666;
    border: 1px solid #D9D9D9;
}

.pn-sc-btn-viewcart:hover {
    background-color: #F0F0F0;
    color: #222222;
}

.pn-sc-btn-viewcart:active {
    transform: scale(0.98);
}

/* Overlay blocker inside drawer while updating */
.pn-sc-drawer.updating::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.6);
    z-index: 10;
    cursor: wait;
    animation: pn-sc-fade 0.2s ease forwards;
}

@keyframes pn-sc-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =================================================================
   AJUSTES MOBILE — drawer compacto e sem bordas aninhadas
   ================================================================= */

/* Bordas triplas: wrapper > container > item. Achata o container do meio,
   deixando só a moldura externa e a borda de cada opção de frete. */
.pn-sc-shipping-methods-container {
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin-top: 10px !important;
}
.pn-sc-shipping-methods-list { display: flex; flex-direction: column; gap: 6px; }
.pn-sc-shipping-method-item { margin: 0 !important; }

/* O overlay some junto com a gaveta para não escurecer a barra inferior */
.pn-sc-overlay { z-index: 999994; }

@media (max-width: 767px) {
    /* Gaveta ocupa a tela toda, sem sobra lateral */
    .pn-sc-drawer { width: 100% !important; }

    /* Compactação: mais itens visíveis e o rodapé sempre alcançável */
    .pn-sc-items-wrapper { padding: 8px 14px !important; }
    .pn-sc-footer { padding: 12px 14px !important; }

    .pn-sc-coupon-wrapper,
    .pn-sc-shipping-wrapper {
        margin-top: 12px !important;
        padding: 12px !important;
        border-radius: 10px !important;
    }
    .pn-sc-coupon-wrapper { margin-top: 14px !important; }
    .pn-sc-section-title { margin-bottom: 8px !important; font-size: 12px !important; }

    /* Campos e botões em alvo de toque confortável (e 16px evita zoom no iOS) */
    .pn-sc-input { height: 44px !important; font-size: 16px !important; }
    .pn-sc-action-btn { height: 44px !important; padding: 0 14px !important; }

    /* Rodapé fixo dentro da gaveta: totais + CTA sempre visíveis */
    .pn-sc-footer { position: sticky; bottom: 0; z-index: 2; }
}

/* Telas baixas (paisagem / aparelhos pequenos): enxuga ainda mais */
@media (max-height: 700px) {
    .pn-sc-coupon-wrapper,
    .pn-sc-shipping-wrapper { margin-top: 10px !important; padding: 10px !important; }
    .pn-sc-footer { padding: 10px 14px !important; }
}
