/**
 * Market Experts Checkout Popup Panel
 * Slide-out panel with cart summary and upsells
 */

:root {
    --mep-primary: #3b82f6;
    --mep-secondary: #8b5cf6;
    --mep-accent: #06b6d4;
    --mep-success: #22c55e;
    --mep-danger: #ef4444;
    --mep-text-white: #ffffff;
    --mep-text-gray: #94a3b8;
    --mep-text-dim: #64748b;
    --mep-bg-dark: #030712;
    --mep-bg-panel: #0a0f1a;
    --mep-border: rgba(255, 255, 255, 0.08);
    --mep-border-light: rgba(255, 255, 255, 0.12);
    --mep-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #06b6d4 100%);
    --mep-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ==================== OVERLAY ==================== */

.me-checkout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.me-checkout-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ==================== POPUP PANEL ==================== */

.me-checkout-popup {
    position: fixed;
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: 420px;
    max-width: calc(100vw - 24px);
    background: var(--mep-bg-panel);
    border: 1px solid var(--mep-border);
    border-radius: 28px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    transform: translateX(calc(100% + 24px));
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--mep-font);
    box-shadow:
        -20px 0 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    overflow: hidden;
}

.me-checkout-popup.active {
    transform: translateX(0);
}

/* ==================== HEADER ==================== */

.me-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--mep-border);
    background: linear-gradient(180deg, rgba(20, 30, 50, 0.95) 0%, rgba(10, 15, 26, 0.9) 100%);
    flex-shrink: 0;
    border-radius: 28px 28px 0 0;
}

.me-popup-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Logo with count badge */
.me-popup-logo-wrap {
    position: relative;
    flex-shrink: 0;
}

.me-popup-logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.25);
}

.me-popup-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--mep-gradient);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 100px;
    border: 2px solid var(--mep-bg-panel);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.me-popup-title > span {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--mep-text-white);
}

/* Close Button - Sleek Arrow Style */
.me-popup-close,
button.me-popup-close {
    position: relative;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 14px !important;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    padding: 0 !important;
}

.me-popup-close::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.me-popup-close:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: translateX(3px);
}

.me-popup-close:hover::before {
    opacity: 1;
}

.me-popup-close:active {
    transform: translateX(1px) scale(0.98);
}

/* Arrow icon pointing right (close/dismiss) */
.me-close-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
}

.me-close-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 4px;
    width: 12px;
    height: 2px;
    background: var(--mep-text-gray);
    border-radius: 2px;
    transform: translateY(-50%);
    transition: all 0.3s ease;
}

.me-close-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 3px;
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--mep-text-gray);
    border-right: 2px solid var(--mep-text-gray);
    transform: translateY(-50%) rotate(45deg);
    transition: all 0.3s ease;
}

.me-popup-close:hover .me-close-icon::before,
.me-popup-close:hover .me-close-icon::after {
    border-color: var(--mep-text-white);
    background: var(--mep-text-white);
}

/* ==================== CONTENT ==================== */

.me-popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling */
.me-popup-content::-webkit-scrollbar {
    width: 5px;
}

.me-popup-content::-webkit-scrollbar-track {
    background: transparent;
}

.me-popup-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.me-popup-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* Empty State */
.me-popup-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: var(--mep-text-gray);
    flex: 1;
}

.me-popup-empty svg {
    margin-bottom: 24px;
    opacity: 0.4;
}

.me-popup-empty h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--mep-text-white);
    margin-bottom: 10px;
}

.me-popup-empty p {
    font-size: 0.95rem;
    margin-bottom: 28px;
}

/* ==================== CART ITEMS ==================== */

.me-popup-items {
    margin-bottom: 20px;
}

.me-popup-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--mep-border);
    border-radius: 20px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.me-popup-item:hover {
    border-color: var(--mep-border-light);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

/* Remove Button */
.me-popup-item-remove,
button.me-popup-item-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.9) !important;
    border: 2px solid var(--mep-bg-panel) !important;
    border-radius: 50% !important;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    z-index: 5;
    padding: 0 !important;
}

.me-popup-item:hover .me-popup-item-remove {
    opacity: 1;
    transform: scale(1);
}

.me-popup-item-remove:hover {
    background: rgba(239, 68, 68, 1) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
}

.me-popup-item:last-child {
    margin-bottom: 0;
}

/* Product Image - No border/box */
.me-popup-item-image {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    overflow: hidden;
    flex-shrink: 0;
}

.me-popup-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
}

.me-popup-item-info {
    flex: 1;
    min-width: 0;
}

.me-popup-item-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--mep-text-white);
    margin-bottom: 6px;
    line-height: 1.3;
}

.me-popup-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--mep-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.me-popup-badge.sixmonth {
    background: rgba(139, 92, 246, 0.15);
    color: var(--mep-secondary);
}

.me-popup-badge.annual {
    background: rgba(34, 197, 94, 0.15);
    color: var(--mep-success);
}

.me-popup-badge.merch {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.me-popup-item-variant {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 4px;
}

.me-popup-item-qty {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.me-popup-item-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--mep-text-white);
    white-space: nowrap;
}

/* ==================== UPSELLS (Collapsible) ==================== */

.me-popup-upsells {
    margin-bottom: 16px;
    width: 100%;
    display: block;
    box-sizing: border-box;
}

/* Toggle button — matches checkout button style */
.me-popup-upsells-toggle,
button.me-popup-upsells-toggle {
    width: 100% !important;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 20px;
    box-sizing: border-box;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 50%, #059669 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    color: #fff;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow:
        0 4px 16px -4px rgba(34, 197, 94, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.me-popup-upsells-toggle:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 25px -6px rgba(34, 197, 94, 0.55),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.me-popup-upsells-toggle:active {
    transform: translateY(0);
}

.me-popup-upsells-toggle.open {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 50%, #047857 100%);
}

.me-popup-upsells-toggle-left {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.01em;
}

.me-popup-upsells-toggle-left svg {
    flex-shrink: 0;
}

.me-popup-upsells-chevron {
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.me-popup-upsells-toggle.open .me-popup-upsells-chevron {
    transform: rotate(180deg);
    color: #fff;
}

/* Collapsible body */
.me-popup-upsells-body {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin 0.3s ease;
    border-radius: 12px;
    margin-top: 0;
}

.me-popup-upsells-body.open {
    max-height: 500px;
    padding: 12px 14px 14px;
    margin-top: 10px;
    border: 1px solid rgba(34, 197, 94, 0.12);
    background: rgba(34, 197, 94, 0.03);
}

/* Upsells List */
.me-popup-upsells-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.me-popup-upsell {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 13px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--mep-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    color: inherit;
    text-align: left;
}

.me-popup-upsell:hover {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.4);
}

.me-popup-upsell.best-value {
    border-color: rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(139, 92, 246, 0.06));
}

.me-popup-upsell.best-value:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    border-color: rgba(139, 92, 246, 0.6);
}

.me-popup-upsell-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.me-popup-upsell-info strong {
    font-size: 0.82rem;
    color: var(--mep-text-white);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.me-popup-best-tag {
    display: inline-flex;
    font-size: 0.55rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 100px;
    background: var(--mep-gradient);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.me-popup-upsell-info span {
    font-size: 0.75rem;
    color: var(--mep-text-gray);
}

.me-popup-upsell-savings {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 100px;
    background: rgba(34, 197, 94, 0.15);
    color: var(--mep-success);
    white-space: nowrap;
}

.me-popup-crypto-note {
    font-size: 0.68rem;
    color: var(--mep-text-dim);
    margin-top: 10px;
    margin-bottom: 0;
    text-align: center;
}

/* ==================== TOTALS ==================== */

.me-popup-totals {
    padding: 18px 0 0;
    border-top: 1px solid var(--mep-border);
    margin-top: auto;
}

.me-popup-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 0.95rem;
    color: var(--mep-text-gray);
}

.me-popup-total-row.total {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--mep-text-white);
    padding-top: 14px;
    margin-top: 6px;
    border-top: 1px solid var(--mep-border);
}

/* Discount row */
.me-popup-discount-row {
    color: #10b981;
}

.me-popup-discount-row .me-discount-amount {
    color: #10b981;
    font-weight: 600;
}

/* Gift Card row */
.me-popup-gc-row {
    color: #8b5cf6;
}

.me-popup-gc-row .me-gc-amount {
    color: #8b5cf6;
    font-weight: 600;
}

/* Coupon tag (used in discount & GC rows) */
.me-coupon-tag {
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    color: inherit;
    padding: 2px 7px;
    border-radius: 4px;
    margin-left: 5px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    letter-spacing: 0.01em;
}

/* Shipping row */
.me-popup-shipping-row {
    color: var(--mep-text-gray);
}

.me-popup-shipping-row #me-popup-shipping {
    font-size: 0.85rem;
    color: #94a3b8;
}

/* ==================== FOOTER ==================== */

.me-popup-footer {
    padding: 20px 24px 24px;
    border-top: 1px solid var(--mep-border);
    background: linear-gradient(180deg, rgba(10, 15, 26, 0.9) 0%, rgba(20, 30, 50, 0.95) 100%);
    flex-shrink: 0;
    border-radius: 0 0 28px 28px;
}

.me-popup-login-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 14px;
    margin-bottom: 16px;
    font-size: 0.78rem;
    color: var(--mep-text-gray);
}

.me-popup-login-notice svg {
    flex-shrink: 0;
    color: var(--mep-primary);
}

/* Buttons */
.me-popup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 28px;
    border-radius: 16px;
    font-family: inherit;
    font-size: 1.02rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    border: none;
}

.me-popup-btn-primary {
    background: var(--mep-gradient);
    color: #fff;
    box-shadow:
        0 4px 20px -4px rgba(59, 130, 246, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.me-popup-btn-primary:hover {
    transform: translateY(-3px);
    box-shadow:
        0 12px 35px -8px rgba(59, 130, 246, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.me-popup-btn-primary:active {
    transform: translateY(-1px);
}

.me-popup-btn-outline {
    background: transparent;
    border: 1px solid var(--mep-border-light);
    color: var(--mep-text-white);
}

.me-popup-btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Continue Shopping Button */
.me-popup-continue,
button.me-popup-continue {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px !important;
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 14px !important;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--mep-text-gray) !important;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.me-popup-continue::before {
    content: '←';
    font-size: 1.1rem;
    transition: transform 0.3s ease;
}

.me-popup-continue::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.me-popup-continue:hover {
    color: var(--mep-text-white) !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
    transform: translateX(-3px);
}

.me-popup-continue:hover::before {
    transform: translateX(-4px);
}

.me-popup-continue:hover::after {
    opacity: 1;
}

.me-popup-continue:active {
    transform: translateX(-1px) scale(0.99);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 480px) {
    .me-checkout-popup {
        top: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: 100vw;
        border-radius: 0;
    }

    .me-popup-header {
        border-radius: 0;
        padding: 16px 18px;
    }

    .me-popup-footer {
        border-radius: 0;
        padding: 18px;
    }

    .me-popup-content {
        padding: 18px;
    }

    .me-popup-item {
        padding: 14px;
        gap: 14px;
        border-radius: 16px;
    }

    .me-popup-item-image {
        width: 50px;
        height: 50px;
        border-radius: 12px;
    }

    .me-popup-item-image img {
        border-radius: 12px;
    }

    .me-popup-upsells-toggle {
        padding: 6px 14px;
    }

    .me-popup-upsells-body.open {
        padding: 10px 12px 12px;
    }

    .me-popup-btn {
        padding: 14px 22px;
        font-size: 0.98rem;
        border-radius: 14px;
    }
}

/* ==================== WOOCOMMERCE STORE NOTICE ==================== */
.woocommerce-store-notice.demo_store {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    top: auto !important;
    width: auto;
    max-width: 600px;
    margin: 0;
    padding: 10px 20px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    color: #94a3b8;
    font-size: 0.82rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    text-align: center;
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(139, 92, 246, 0.06);
    animation: storeNoticeFadeIn 0.4s ease;
}

.woocommerce-store-notice.demo_store a {
    color: #a78bfa;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.woocommerce-store-notice.demo_store a:hover {
    color: #c4b5fd;
}

.woocommerce-store-notice.demo_store .woocommerce-store-notice__dismiss-link {
    display: inline-flex;
    align-items: center;
    margin-left: 12px;
    padding: 2px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s;
}

.woocommerce-store-notice.demo_store .woocommerce-store-notice__dismiss-link:hover {
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

@keyframes storeNoticeFadeIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 640px) {
    .woocommerce-store-notice.demo_store {
        left: 12px;
        right: 12px;
        transform: none;
        max-width: none;
        font-size: 0.78rem;
        padding: 10px 14px;
    }

    @keyframes storeNoticeFadeIn {
        0% { opacity: 0; transform: translateY(10px); }
        100% { opacity: 1; transform: translateY(0); }
    }
}
