/* ───────────────────────────────────────────
   DESIGN TOKENS
─────────────────────────────────────────── */
:root {
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.4);
    --accent: #06b6d4;
    --bg-dark: #0f172a;
    --card-glass: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --emerald: #10b981;
    --rose: #f43f5e;
    --whatsapp: #25d366;
}

/* ───────────────────────────────────────────
   RESET & BASE
─────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

html {
    /* Prevent font size inflation on iOS */
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    /* Allow scrolling on small screens — removed overflow: hidden */
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    color: var(--text-main);
    overflow-x: hidden;
    padding: 1.5rem 0;
}

/* Vertically center when content is shorter than viewport */
@media (min-height: 700px) {
    body {
        align-items: center;
        padding: 1.5rem 0;
    }
}

/* ───────────────────────────────────────────
   ANIMATED BACKGROUND BLOBS
─────────────────────────────────────────── */
.mesh-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: blur(80px);
    opacity: 0.5;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;          /* prevent blobs from causing page scroll */
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: move 20s infinite alternate;
}

/* Scale blobs down on mobile so they don't overflow */
.blob-1 {
    width: clamp(180px, 40vw, 400px);
    height: clamp(180px, 40vw, 400px);
    background: var(--primary);
    top: -60px;
    left: -60px;
    opacity: 0.3;
}

.blob-2 {
    width: clamp(140px, 30vw, 300px);
    height: clamp(140px, 30vw, 300px);
    background: var(--accent);
    bottom: -40px;
    right: -40px;
    opacity: 0.2;
    animation-delay: -5s;
}

@keyframes move {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 60px) scale(1.2); }
}

/* ───────────────────────────────────────────
   LAYOUT
─────────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 480px;
    padding: 0 1rem;          /* horizontal breathing room on mobile */
    z-index: 10;
}

.glass-card {
    background: var(--card-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 2rem;
    padding: clamp(1.25rem, 5vw, 2.25rem);   /* shrinks gracefully */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    /* Ensure card never overflows its container */
    width: 100%;
    overflow: hidden;
}

/* ───────────────────────────────────────────
   TYPOGRAPHY
─────────────────────────────────────────── */
h1 {
    font-size: clamp(1.35rem, 5vw, 1.75rem);
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, var(--text-dim));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    /* Prevent text overflow */
    overflow-wrap: break-word;
}

p.subtitle {
    color: var(--text-dim);
    font-size: clamp(0.75rem, 2.5vw, 0.8125rem);
    margin-bottom: 1.5rem;
}

/* ───────────────────────────────────────────
   TAB SWITCHER
─────────────────────────────────────────── */
.tab-switcher {
    display: flex;
    padding: 0.375rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 1.125rem;
    margin-bottom: 1.75rem;
    border: 1px solid var(--border-glass);
    gap: 0.25rem;
}

.tab-btn {
    flex: 1;
    padding: 0.625rem 0.375rem;
    border-radius: 0.875rem;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: clamp(0.73rem, 2.5vw, 0.8125rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* ───────────────────────────────────────────
   FORM INPUTS
─────────────────────────────────────────── */
.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.phone-input-container {
    display: flex;
    gap: 0.625rem;
    align-items: stretch;
}

.country-code {
    flex-shrink: 0;
    padding: 0.75rem 0.875rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 0.875rem;
    font-weight: 800;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

input,
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 0.875rem;
    padding: 0.875rem 1.125rem;
    color: white;
    font-size: clamp(0.875rem, 3vw, 0.9375rem);
    outline: none;
    transition: all 0.3s ease;
    /* Prevent iOS zoom on focus (font-size must stay ≥ 16px equivalent) */
    min-height: 44px;           /* touch target minimum */
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

/* ───────────────────────────────────────────
   OTP INPUTS
─────────────────────────────────────────── */
.otp-container {
    display: flex;
    justify-content: space-between;
    gap: clamp(0.25rem, 1.5vw, 0.5rem);
    margin: 1.5rem 0;
    width: 100%;
}

.otp-digit {
    flex: 1 1 0;
    min-width: 0;               /* allow shrinking below content size */
    /* Use aspect-ratio to maintain square-ish cells */
    aspect-ratio: 1 / 1.15;
    max-height: 3.75rem;
    text-align: center;
    font-size: clamp(1rem, 4vw, 1.25rem);
    font-weight: 800;
    border-radius: 0.75rem;
    padding: 0;
    line-height: 1;             /* override to prevent overflow */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ───────────────────────────────────────────
   BUTTONS
─────────────────────────────────────────── */
.primary-btn {
    width: 100%;
    border: none;
    border-radius: 1rem;
    padding: clamp(0.875rem, 3vw, 1.125rem);
    font-size: clamp(0.85rem, 3vw, 0.9375rem);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: white;
    min-height: 48px;           /* accessible touch target */
}

.btn-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.btn-wa {
    background: var(--whatsapp);
    font-size: clamp(0.78rem, 2.5vw, 0.875rem);
    padding: 0.875rem;
    margin-top: 0;
}

.btn-voice {
    background: var(--primary);
    font-size: clamp(0.78rem, 2.5vw, 0.875rem);
    padding: 0.875rem;
    margin-top: 0;
}

.btn-gradient:hover,
.btn-wa:hover,
.btn-voice:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* ───────────────────────────────────────────
   LOADER SPINNER
─────────────────────────────────────────── */
.loader {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ───────────────────────────────────────────
   RESEND OPTIONS
─────────────────────────────────────────── */
.resend-options {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.resend-title {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
}

/* WA + Voice 2-col grid */
.resend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Stack to single column on very narrow screens */
@media (max-width: 360px) {
    .resend-grid {
        grid-template-columns: 1fr;
    }
}

/* ───────────────────────────────────────────
   TOAST NOTIFICATION
─────────────────────────────────────────── */
#error-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(244, 63, 94, 0.2);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 0.75rem 1.25rem;
    border-radius: 0.875rem;
    color: #fda4af;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.4s;
    font-size: 0.8125rem;
    z-index: 100;
    /* Constrain width on mobile */
    max-width: calc(100vw - 2rem);
    white-space: normal;
    word-break: break-word;
}

#error-toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ───────────────────────────────────────────
   UTILITIES
─────────────────────────────────────────── */
.hidden { display: none !important; }

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Auth node info box */
.auth-node-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.125rem;
    border-radius: 1.25rem;
    text-align: left;
    margin-top: 1.25rem;
    border: 1px solid var(--border-glass);
}

.auth-node-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-node-value {
    font-size: clamp(0.85rem, 3vw, 0.9375rem);
    font-weight: 600;
    margin-bottom: 0;
    overflow-wrap: break-word;
    word-break: break-all;           /* break long phone strings */
}



.logout-btn {
    background: transparent;
    border: 1px solid var(--border-glass);
    border-radius: 1rem;
    padding: 0.625rem 1.25rem;
    color: var(--text-dim);
    font-weight: 700;
    cursor: pointer;
    margin-top: 2rem;
    transition: all 0.3s;
    font-size: 0.8125rem;
    min-height: 44px;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

/* ───────────────────────────────────────────
   COUPON HUB
─────────────────────────────────────────── */
.coupon-hub {
    margin-top: 2rem;
    text-align: left;
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn 0.6s 0.2s forwards;
}

.hub-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;            /* wrap on tiny screens */
}

.coupon-input-area {
    position: relative;
    margin-bottom: 1.5rem;
}

.coupon-input-area textarea {
    width: 100%;
    min-height: 100px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 1.25rem;
    padding: 1.125rem;
    color: white;
    font-size: clamp(0.85rem, 3vw, 0.9375rem);
    resize: vertical;           /* allow vertical resize only (not horizontal) */
    transition: all 0.3s;
    line-height: 1.6;
}

.coupon-input-area textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
}

.coupon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(100px, 28vw, 130px), 1fr));
    gap: 0.625rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

/* Webkit scrollbar styling */
.coupon-grid::-webkit-scrollbar { width: 4px; }
.coupon-grid::-webkit-scrollbar-track { background: transparent; }
.coupon-grid::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

.coupon-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 1rem;
    padding: clamp(0.625rem, 2.5vw, 1rem);
    position: relative;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    /* Prevent text overflow inside cards */
    overflow: hidden;
    min-width: 0;
}

.coupon-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.coupon-code {
    font-size: clamp(0.78rem, 2.8vw, 0.9375rem);
    font-weight: 800;
    color: white;
    letter-spacing: 0.05em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.coupon-status {
    font-size: clamp(0.56rem, 1.8vw, 0.65rem);
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status colours */
.status-validating { color: var(--accent); }
.status-success    { color: var(--emerald); }
.status-error      { color: var(--rose); }

.pulsing {
    animation: pulseSmall 2s infinite;
}

@keyframes pulseSmall {
    0%, 100% { opacity: 0.7; }
    50%       { opacity: 1; color: var(--primary); }
}

.verify-all-btn {
    margin-top: 1.25rem;
    width: 100%;
}

/* ───────────────────────────────────────────
   COPY OPTIONS ROW
─────────────────────────────────────────── */
.copy-options-row {
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;            /* wrap if needed */
}

.copy-options-row .copy-list-btn-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.copy-options-row .copy-limit-wrap {
    flex: 0 0 auto;
    width: clamp(64px, 18vw, 80px);
}

.copy-limit-wrap input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 1rem;
    padding: 0.75rem 0.5rem;
    color: white;
    text-align: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.copy-list-btn {
    margin-top: 0;
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-dim);
    font-size: clamp(0.75rem, 2.5vw, 0.8125rem);
    font-weight: 700;
    border-radius: 1rem;
    padding: 0.75rem 0.875rem;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-height: 44px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-list-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

/* ───────────────────────────────────────────
   TABLET BREAKPOINT  (481px – 768px)
─────────────────────────────────────────── */
@media (min-width: 481px) {
    body {
        padding: 2rem 0;
    }

    .container {
        padding: 0 1.5rem;
    }
}

/* ───────────────────────────────────────────
   DESKTOP BREAKPOINT  (769px +)
─────────────────────────────────────────── */
@media (min-width: 769px) {
    body {
        padding: 3rem 0;
    }

    .container {
        padding: 0;
    }

    .glass-card {
        border-radius: 2.25rem;
    }
}

/* ───────────────────────────────────────────
   VERY SMALL MOBILE  (< 360px)
─────────────────────────────────────────── */
@media (max-width: 359px) {
    .glass-card {
        padding: 1.125rem;
        border-radius: 1.5rem;
    }

    .otp-container {
        gap: 0.2rem;
    }

    .tab-btn {
        padding: 0.5rem 0.25rem;
        font-size: 0.68rem;
    }

    .coupon-grid {
        grid-template-columns: 1fr 1fr;   /* force 2 cols on tiny phone */
    }
}

/* ───────────────────────────────────────────
   ACCOUNT PICKER
─────────────────────────────────────────── */
.accounts-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    margin-top: 1rem;
}

.account-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 1.25rem;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.account-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: translateX(4px);
}

.acc-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
}

.acc-info {
    flex-grow: 1;
    min-width: 0;
}

.acc-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-phone {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.btn-remove-acc {
    opacity: 0.6;
    background: rgba(244, 63, 94, 0.1);
    color: var(--rose);
    border: none;
    border-radius: 0.75rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    flex-shrink: 0;
    z-index: 5;
}

@media (min-width: 769px) {
    .btn-remove-acc { opacity: 0; }
    .account-item:hover .btn-remove-acc { opacity: 1; }
}

.btn-remove-acc:hover {
    background: var(--rose);
    color: white;
}

.secondary-btn {
    font-size: 0.8125rem !important;
    padding: 0.875rem !important;
}
