@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
    --bg-start: #2d1f6b;
    --bg-end: #5b2fc9;
    --surface: rgba(255, 255, 255, 0.08);
    --surface-hover: rgba(255, 255, 255, 0.12);
    --border: rgba(255, 255, 255, 0.18);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
    --accent: #ffd54f;
    --success: #4ade80;
    --error: #f87171;
    --radius: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
    min-height: 100vh;
    color: var(--text);
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

.page {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

/* Sticky checkout bar */
.checkout-bar {
    max-width: 480px;
    margin: 0 auto;
}

.checkout-bar .price-summary {
    margin-bottom: 10px;
}

.checkout-bar .btn-primary {
    margin-bottom: 0;
}

@media (min-width: 769px) {
    .checkout-bar {
        padding: 0 20px 40px;
    }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* Sections */
.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Products */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.product-card:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.35);
}

.product-card.selected {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 24px rgba(255, 255, 255, 0.15);
}

.product-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.product-info .monthly {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.product-price {
    text-align: left;
}

.product-price .final {
    font-size: 1.1rem;
    font-weight: 700;
}

.product-price .original {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: line-through;
}

.product-badge {
    display: inline-block;
    background: var(--accent);
    color: #1a1a1a;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 4px;
}

/* Skeleton */
.skeleton-card {
    height: 72px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    transition: border-color 0.2s;
}

.input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}

.input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
}

.input.valid {
    border-color: var(--success);
}

.input.invalid {
    border-color: var(--error);
}

.input-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

.discount-row {
    display: flex;
    gap: 10px;
}

.discount-row .input {
    flex: 1;
    text-align: right;
}

.discount-message {
    margin-top: 8px;
    font-size: 0.85rem;
    text-align: center;
}

.discount-message.success { color: var(--success); }
.discount-message.error { color: var(--error); }

/* Price summary */
.price-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    animation: slideUp 0.35s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.price-summary.has-discount-highlight {
    border-color: rgba(74, 222, 128, 0.5);
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(255, 213, 79, 0.08));
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.price-row.price-final {
    border-top: 1px solid var(--border);
    margin-top: 8px;
    padding-top: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.price-original {
    text-decoration: line-through;
}

.price-discount {
    color: var(--success);
    font-weight: 600;
}

#finalPrice {
    color: var(--accent);
    font-size: 1.2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #fff;
    color: #2d1f6b;
    box-shadow: var(--shadow);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 2px solid var(--border);
    width: auto;
    flex-shrink: 0;
    padding: 14px 20px;
}

.btn-outline:hover {
    background: var(--surface-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 0.88rem;
    padding: 10px 16px;
}

.btn-ghost:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.35);
}

.btn-sm {
    padding: 10px 18px;
    font-size: 0.88rem;
}

.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* VPN note */
.vpn-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.vpn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Footer */
.footer-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.footer-actions .btn {
    flex: 1;
}

/* Card to card */
.card-to-card {
    margin-top: 16px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.card-number {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 2px;
    margin: 12px 0 4px;
    direction: ltr;
}

.card-holder {
    font-size: 0.85rem;
    margin-bottom: 14px;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 10000;
    max-width: 90%;
    text-align: center;
    animation: toastIn 0.3s ease;
}

.toast.success { background: var(--success); color: #1a1a1a; }
.toast.error { background: var(--error); color: #fff; }
.toast.info { background: #3b82f6; color: #fff; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Personal discount toast */
.discount-toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 440px;
    background: linear-gradient(135deg, #1a3a2a 0%, #2d4a35 100%);
    border: 1px solid rgba(74, 222, 128, 0.5);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    z-index: 10001;
    overflow: hidden;
    animation: discountToastIn 0.4s ease;
}

@keyframes discountToastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.discount-toast.closing {
    animation: discountToastOut 0.3s ease forwards;
}

@keyframes discountToastOut {
    to { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(0.95); }
}

.discount-toast-timer {
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
}

.discount-toast-progress {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent));
    transform: scaleX(1);
    transform-origin: right center;
}

.discount-toast-close {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.discount-toast-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.discount-toast-body {
    display: flex;
    gap: 12px;
    padding: 16px 16px 14px 44px;
    align-items: flex-start;
}

.discount-toast-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.discount-toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--success);
    margin-bottom: 4px;
}

.discount-toast-text {
    font-size: 0.88rem;
    margin-bottom: 4px;
}

.discount-toast-note {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 500;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
}

.loading-subtext {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Responsive — mobile sticky checkout */
@media (max-width: 768px) {
    body {
        padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }

    body.has-discount-checkout {
        padding-bottom: calc(200px + env(safe-area-inset-bottom, 0px));
    }

    .page {
        padding: 20px 16px 24px;
    }

    .checkout-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: none;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
        background: linear-gradient(to top, rgba(45, 31, 107, 0.98) 70%, rgba(45, 31, 107, 0));
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        z-index: 100;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .checkout-bar .price-summary {
        margin-bottom: 10px;
        padding: 12px 14px;
    }

    .checkout-bar .price-row {
        padding: 4px 0;
        font-size: 0.85rem;
    }

    .checkout-bar .price-row.price-final {
        padding-top: 10px;
        margin-top: 6px;
        font-size: 0.95rem;
    }

    .checkout-bar #finalPrice {
        font-size: 1.1rem;
    }

    .checkout-bar .btn-primary {
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
    }
}

@media (max-width: 400px) {
    .logo h1 { font-size: 1.6rem; }
    .product-card { padding: 14px; }
    .discount-row { flex-direction: column; }
    .discount-row .btn { width: 100%; }
}
