/* ================================================================
   Waifly Cart — sidebar, checkout modal, coupon, toast
   ================================================================ */

/* ── Cart Overlay ───────────────────────────────────────────── */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 999001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.cart-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

/* ── Cart Sidebar ───────────────────────────────────────────── */
.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, #1a1d30 0%, #1c1f36 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 999002;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.cart-sidebar.open {
    transform: translateX(0);
}

/* Header */
.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}
.cart-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}
.cart-title svg { color: #38b1ed; }
.cart-close {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #aaa;
    transition: all 0.2s;
}
.cart-close:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* Body */
.cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cart-body::-webkit-scrollbar { width: 4px; }
.cart-body::-webkit-scrollbar-track { background: transparent; }
.cart-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

/* Empty state */
.cart-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #666;
    padding: 40px 20px;
    text-align: center;
}
.cart-empty p { font-size: 1rem; color: #888; margin: 0; }
.cart-empty span { font-size: 0.85rem; color: #555; }

/* Cart item */
.cart-items-list { display: flex; flex-direction: column; gap: 10px; }

.cart-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.2s;
}
.cart-item:hover { border-color: rgba(56, 177, 237, 0.2); }

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e8ecf4;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cart-item-price {
    font-size: 0.85rem;
    color: #38b1ed;
    margin-bottom: 8px;
}
.cart-item-price small { color: #666; font-size: 0.78em; }

.cart-servertype-select,
.cart-serverid-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #dce3f0;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-family: inherit;
    margin-top: 4px;
}
.cart-servertype-select option { background: #1c1f36; }

.cart-item-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.cart-qty-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 2px 4px;
}
.qty-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 1rem;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s;
}
.qty-btn:hover { background: rgba(56,177,237,0.15); color: #38b1ed; }
.qty-value { font-size: 0.9rem; font-weight: 600; color: #dce3f0; min-width: 20px; text-align: center; }

.cart-item-total { font-size: 0.9rem; font-weight: 700; color: #fff; }

.cart-item-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 0;
}
.cart-item-remove:hover { color: #e74c3c; background: rgba(231,76,60,0.1); }

/* Coupon */
.cart-coupon-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px;
}

.cart-credits-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px;
    margin-top: 10px;
}
.cart-credits-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #ddd;
    cursor: pointer;
}
.cart-credits-toggle input {
    width: 16px;
    height: 16px;
    accent-color: #38b1ed;
    cursor: pointer;
}
.cart-credits-note {
    font-size: 0.8rem;
    color: #888;
    margin-top: 6px;
}
.coupon-row {
    display: flex;
    gap: 8px;
}
.coupon-row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: #fff;
    padding: 9px 12px;
    font-size: 0.9rem;
    font-family: monospace;
    letter-spacing: 1px;
    transition: border-color 0.2s;
}
.coupon-row input:focus { outline: none; border-color: rgba(56,177,237,0.5); }
.coupon-row input::placeholder { color: #555; letter-spacing: normal; font-family: inherit; }
.coupon-row button {
    background: linear-gradient(135deg, #2d95cc, #38b1ed);
    border: none;
    border-radius: 8px;
    color: #fff;
    padding: 9px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}
.coupon-row button:hover { opacity: 0.9; }
.coupon-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.coupon-feedback {
    font-size: 0.82rem;
    margin-top: 8px;
    min-height: 18px;
}
.coupon-feedback.success { color: #10b981; }
.coupon-feedback.error   { color: #e74c3c; }

/* Summary */
.cart-summary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #9ca3af;
}
.discount-row { color: #10b981; }
.discount-amount { font-weight: 600; }
.total-row {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    margin-top: 2px;
}
.cart-period-note {
    font-size: 0.75rem;
    color: #555;
    font-style: italic;
    line-height: 1.4;
}

/* Footer */
.cart-footer {
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
}
.btn-checkout {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #2d95cc 0%, #38b1ed 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s;
    box-shadow: 0 4px 15px rgba(56,177,237,0.3);
}
.btn-checkout:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(56,177,237,0.45);
}
.btn-checkout:active { transform: translateY(0); }

/* ── Floating Cart Button ────────────────────────────────────── */
.cart-fab {
    position: fixed;
    bottom: calc(28px + env(safe-area-inset-bottom));
    right: 28px;
    z-index: 999000;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d95cc, #38b1ed);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(56,177,237,0.45);
    transition: all 0.25s;
    color: #fff;
}
.cart-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(56,177,237,0.6); }
.cart-fab:active { transform: scale(0.97); }

.cart-fab-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1a1d30;
}

/* ── Add to cart button variant ─────────────────────────────── */
.btn-add-cart {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Extra server qty row ───────────────────────────────────── */
.extra-server-qty-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #9ca3af;
}

/* ── Checkout Modal ─────────────────────────────────────────── */
.checkout-modal-content {
    max-width: 480px;
    width: 100%;
    background: linear-gradient(180deg, #1a1d30 0%, #1c1f36 100%);
}
.checkout-modal-content .popup-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.checkout-modal-content .popup-header h3 {
    color: #fff;
}
.checkout-modal-content .close-popup {
    color: #9ca3af;
}
.checkout-modal-content .close-popup:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.checkout-order-summary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.checkout-items { display: flex; flex-direction: column; gap: 8px; }
.checkout-item-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #cdd5e0;
}
.checkout-discount-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #10b981;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: 8px;
}
.checkout-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    color: #fff;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 8px;
}

.checkout-server-configs,
.checkout-antiv-config {
    margin-bottom: 14px;
}
.checkout-antiv-config label {
    display: block;
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: 6px;
}
.checkout-antiv-config input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #fff;
    padding: 9px 12px;
    font-family: monospace;
    font-size: 0.9rem;
}

/* ── Mandatory legal consents ──────────────────────────────── */
.checkout-legal-consents {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
.checkout-legal-consents .consent-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    cursor: pointer;
}
.checkout-legal-consents .consent-checkbox input[type="checkbox"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: #38b1ed;
    cursor: pointer;
}
.checkout-legal-consents .consent-text {
    font-size: 0.82rem;
    line-height: 1.4;
    color: #9ca3af;
}
.checkout-legal-consents .consent-text a {
    color: #38b1ed;
    text-decoration: underline;
}

.checkout-paypal-wrap { position: relative; }
.checkout-paypal-lock {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 16px;
    background: rgba(15, 17, 26, 0.65);
    backdrop-filter: blur(2px);
    border-radius: 10px;
    color: #9ca3af;
    font-size: 0.82rem;
    cursor: not-allowed;
    z-index: 5;
}
.checkout-paypal-lock.unlocked { display: none; }

#checkout-stripe-btn:disabled,
#checkout-lava-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.checkout-payment-methods { margin-top: 8px; }
.payment-method-label {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 10px;
}
.checkout-methods-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.checkout-method-btn {
    flex: 1;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.88rem;
    color: #9ca3af;
    transition: all 0.2s;
}
.checkout-method-btn:hover { border-color: rgba(56,177,237,0.4); color: #dce3f0; }
.checkout-method-btn.active {
    border-color: #38b1ed;
    background: rgba(56,177,237,0.1);
    color: #38b1ed;
}

.checkout-paypal-container,
.checkout-stripe-container { min-height: 48px; }

.paypal-loading {
    text-align: center;
    color: #666;
    padding: 16px;
    font-size: 0.9rem;
}

/* ── Toast ──────────────────────────────────────────────────── */
.cart-toast {
    position: fixed;
    bottom: calc(100px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 33, 50, 0.95);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: #fff;
    padding: 12px 24px;
    font-size: 0.9rem;
    z-index: 999003;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    max-width: 90vw;
    text-overflow: ellipsis;
    overflow: hidden;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.cart-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.cart-toast-success { border-color: rgba(16,185,129,0.4); }
.cart-toast-error   { border-color: rgba(231,76,60,0.4); }

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .cart-sidebar { width: 100vw; }
    .cart-fab { bottom: 16px; right: 16px; width: 52px; height: 52px; }
}

/* ── Plan icons ──────────────────────────────────────────────── */
.plan-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.plan-icon svg { width: 18px; height: 18px; }
.plan-icon-green  { background: rgba(16,185,129,0.15); color: #10b981; }
.plan-icon-blue   { background: rgba(56,177,237,0.15); color: #38b1ed; }
.plan-icon-purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.plan-icon-cyan   { background: rgba(6,182,212,0.15);  color: #06b6d4; }
.plan-icon-red    { background: rgba(239,68,68,0.15);  color: #ef4444; }
.plan-icon-orange { background: rgba(245,158,11,0.15); color: #f59e0b; }

/* ── Coupon chips ────────────────────────────────────────────── */
.coupon-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 8px;
}
.coupon-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(56,177,237,0.12);
    border: 1px solid rgba(56,177,237,0.3);
    border-radius: 20px;
    padding: 3px 10px 3px 10px;
    font-size: 0.8rem; color: #38b1ed;
    font-weight: 600;
}
.coupon-chip-remove {
    background: none; border: none; cursor: pointer;
    color: #38b1ed; font-size: 1rem; line-height: 1;
    padding: 0; opacity: 0.7;
}
.coupon-chip-remove:hover { opacity: 1; }
.coupon-chip-stack {
    font-size: 0.7rem; color: #10b981;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: 20px; padding: 1px 6px;
}

/* ── Cart type banner ────────────────────────────────────────── */
.cart-type-banner {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 7px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}
.cart-type-banner-sub {
    background: rgba(56, 177, 237, 0.08);
    border: 1px solid rgba(56, 177, 237, 0.2);
    color: #38b1ed;
}
.cart-type-banner-onetime {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}
.cart-type-tag {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(56, 177, 237, 0.15);
    color: #38b1ed;
    border-radius: 20px;
    padding: 2px 9px;
    letter-spacing: 0;
    text-transform: none;
}
.cart-type-tag-onetime {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

/* ── Checkout subscription note ──────────────────────────────── */
.checkout-sub-note {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(56, 177, 237, 0.07);
    border: 1px solid rgba(56, 177, 237, 0.18);
    border-radius: 8px;
    font-size: 0.78rem;
    color: #6db8d9;
    line-height: 1.4;
}
.checkout-sub-note svg { flex-shrink: 0; color: #38b1ed; }

/* ── Second coupon row (stackable) ───────────────────────────── */
.coupon-row-second {
    margin-top: 6px;
    animation: slideDown 0.2s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
