/* ==========================================================================
   Base Layout & Overlay
   ========================================================================== */

body.wisecart-open {
    overflow: hidden;
}

.wisecart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

body.wisecart-open .wisecart-overlay {
    opacity: 1;
    visibility: visible;
}

.wisecart-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100%;
    background-color: #ffffff;
    box-shadow: -6px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    flex-direction: column;
}

body.wisecart-open .wisecart-container {
    transform: translateX(0);
}

.wisecart-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1d1d1d;
}


/* ==========================================================================
   Cart Header
   ========================================================================== */

.wisecart-header {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border-bottom: 1px solid #e5e7eb;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-sizing: border-box;
}

.wisecart-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.wisecart-close-btn {
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    padding: 0;
}

.wisecart-close-btn:hover {
    background: #e5e7eb;
    color: #374151;
    transform: rotate(90deg);
}

.wisecart-close-btn svg {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   Cart Body & Items
   ========================================================================== */

.wisecart-form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.wisecart-body {
    padding: 1.5rem;
    flex-grow: 1;
    overflow-y: auto;
}

.wisecart-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.wisecart-item:last-child {
    border-bottom: none;
}

.wisecart-item-image img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.wisecart-item-details {
    flex-grow: 1;
    min-width: 0;
}

.wisecart-item-name {
    font-weight: 600;
    color: #1f2937;
    text-decoration: none;
    display: block;
    margin-bottom: 0.25rem;
    font-size: 1rem;
    line-height: 1.4;
}

.wisecart-item-name:hover {
    color: #3b82f6;
}

.wisecart-item-quantity-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.wisecart-item .quantity .qty {
    width: 60px;
    padding: 0.25rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
}

.wisecart-item-price {
    font-weight: 600;
    color: #16a34a;
    font-size: 1.1rem;
}

.wisecart-item-remove a.remove {
    color: #ccc;
    text-decoration: none;
    font-size: 26px;
    line-height: 1;
    transition: color 0.2s;
}

.wisecart-item-remove a.remove:hover {
    color: #d9534f;
}


/* ==========================================================================
   Empty Cart
   ========================================================================== */

.wisecart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 2rem;
    height: 100%;
    box-sizing: border-box;
}

.wisecart-empty-icon {
    width: 64px;
    height: 64px;
    color: #d1d5db;
    margin-bottom: 1rem;
}

.wisecart-empty h3 {
    color: #6b7280;
    font-size: 1.25rem;
    margin: 0 0 1rem 0;
}

.wisecart-shop-button {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.wisecart-shop-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    opacity: 1;
}

/* ==========================================================================
   Cart Footer & Buttons
   ========================================================================== */

.wisecart-footer {
    padding: 1.5rem;
    border-top: 1px solid #e9e9e9;
    background-color: #f9fafb;
    flex-shrink: 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.wisecart-coupon-form {
    display: flex;
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

.wisecart-coupon-form .input-text {
    flex-grow: 1;
    border: 1px solid #ddd;
    padding: 0.75rem;
    border-radius: 8px;
}

.wisecart-coupon-form .button {
    padding: 0.75rem 1.25rem;
    border: none;
    background-color: #333;
    color: white;
    border-radius: 8px;
    cursor: pointer;
}

.wisecart-totals {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid #e5e7eb;
}

.wisecart-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wisecart-actions .button {
    display: block;
    width: 100%;
    text-align: center;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.wisecart-checkout-button {
    background-color: var(--wc-checkout-bg, #28a745);
    color: var(--wc-checkout-text, #ffffff);
}

.wisecart-checkout-button:hover {
    opacity: 0.85;
    transform: translateY(-2px);
}

.wisecart-continue-button {
    background-color: var(--wc-continue-bg, #e9ecef);
    color: var(--wc-continue-text, #343a40);
}

.wisecart-continue-button:hover {
    background-color: #e2e6ea;
}


/* ==========================================================================
   Floating Action Button (Trigger)
   ========================================================================== */

.wisecart-trigger {
    position: fixed;
    z-index: 99997;
    cursor: pointer;
    min-width: 64px;
    height: 64px;
    padding: 0 22px;
    border-radius: var(--wc-button-radius, 50px);
    background-color: var(--wc-button-bg, #1f2937);
    color: var(--wc-icon-color, #ffffff);
    border: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.wisecart-trigger:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.wisecart-trigger:active {
    transform: scale(1.02);
}

.wisecart-trigger-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.wisecart-trigger-text {
    font-size: 16px;
    font-weight: 600;
}

.wisecart-trigger--icon_only .wisecart-trigger-text {
    display: none;
}

.wisecart-trigger--text_only .wisecart-trigger-icon {
    display: none;
}

.wisecart-trigger-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 26px;
    height: 26px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--wc-count-bg, #ef4444), #dc2626);
    color: var(--wc-count-text, #ffffff);
    font-size: 13px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: wisecart-count-pulse 2s ease-in-out infinite;
}

.wisecart-count-hidden {
    display: none !important;
}

.wisecart-trigger--bottom-right {
    bottom: 25px;
    right: 25px;
}

.wisecart-trigger--bottom-left {
    bottom: 25px;
    left: 25px;
}

.wisecart-trigger--middle-right {
    top: 50%;
    right: 25px;
    transform: translateY(-50%);
}

.wisecart-trigger--middle-right:hover {
    transform: translateY(-50%) scale(1.1);
}

.wisecart-trigger--middle-left {
    top: 50%;
    left: 25px;
    transform: translateY(-50%);
}

.wisecart-trigger--middle-left:hover {
    transform: translateY(-50%) scale(1.1);
}

.wisecart-trigger--top-right {
    top: 25px;
    right: 25px;
}

.wisecart-trigger--top-left {
    top: 25px;
    left: 25px;
}

/* ==========================================================================
   Checkout View & Scrolling Fix
   ========================================================================== */

#wisecart-checkout-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: white;
}

.wisecart-checkout-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.wisecart-back-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 14px;
    padding: 0.5rem 0;
}

.wisecart-checkout-wrapper {
    flex-grow: 1;
    overflow-y: auto; /* This enables scrolling for the checkout form area */
    padding: 1.5rem;
}

/* Unbreakable Layout Fix: Forces a single-column layout */
.wisecart-checkout-wrapper .col2-set,
.wisecart-checkout-wrapper .col2-set .col-1,
.wisecart-checkout-wrapper .col2-set .col-2,
.wisecart-checkout-wrapper .form-row-first,
.wisecart-checkout-wrapper .form-row-last {
    width: 100% !important;
    float: none !important;
    padding: 0 !important;
    margin-right: 0 !important;
}

.wisecart-checkout-wrapper #order_review_heading,
.wisecart-checkout-wrapper #order_review {
    width: 100% !important;
    float: none !important;
}

/* ==========================================================================
   Order Success Message
   ========================================================================== */

.wisecart-success-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-radius: 16px;
    margin: 1.5rem;
    animation: wisecart-success-slide-in 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(22, 163, 74, 0.1);
    border: 1px solid #bbf7d0;
    position: relative;
    overflow: hidden;
    height: 100%;
    box-sizing: border-box;
    justify-content: center;
}

.wisecart-success-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: wisecart-success-shine 2s ease-in-out 0.5s;
}

.wisecart-success-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    animation: wisecart-success-bounce 1s ease-out;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.3);
    position: relative;
}

.wisecart-success-icon::before {
    content: '✓';
    color: white;
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
}

.wisecart-success-icon::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(34, 197, 94, 0.3);
    animation: wisecart-success-pulse 2s ease-out infinite;
}

.wisecart-success-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #15803d;
    margin: 0 0 0.75rem 0;
    animation: wisecart-fade-in-up 0.6s ease-out 0.3s both;
    letter-spacing: -0.02em;
}

.wisecart-success-text {
    font-size: 1rem;
    color: #166534;
    line-height: 1.6;
    margin: 0;
    animation: wisecart-fade-in-up 0.6s ease-out 0.5s both;
    max-width: 350px;
}

/* ==========================================================================
   Loading States & Animations
   ========================================================================== */

.wisecart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    color: #6b7280;
    font-size: 1rem;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.wisecart-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    margin-right: 0.75rem;
    animation: wisecart-spinner 1s linear infinite;
}

@keyframes wisecart-spinner {
    to {
        transform: rotate(360deg);
    }
}

@keyframes wisecart-count-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

@keyframes wisecart-success-slide-in {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes wisecart-success-bounce {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }

    60% {
        transform: scale(1.15) rotate(10deg);
        opacity: 1;
    }

    80% {
        transform: scale(0.95) rotate(-5deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes wisecart-success-pulse {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(1.4);
        opacity: 0;
    }
}

@keyframes wisecart-success-shine {
    from {
        left: -100%;
    }

    to {
        left: 100%;
    }
}

@keyframes wisecart-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Mobile Optimizations
   ========================================================================== */

@media (max-width: 480px) {
    .wisecart-container {
        max-width: 100vw;
        width: 100vw;
    }

    .wisecart-header,
    .wisecart-body,
    .wisecart-footer,
    .wisecart-checkout-wrapper {
        padding: 1rem;
    }
}