/* WhatsApp Connection Portal — Glassmorphism + Aurora design system */

:root {
    --color-primary: #4F8EF7;
    --color-pink: #F472B6;
    --color-cyan: #22D3EE;
    --color-indigo: #6366F1;
    --color-success: #34D399;
    --color-warning: #FBBF24;
    --color-danger: #F87171;
    --color-muted: rgba(255, 255, 255, 0.55);
    --color-text: rgba(255, 255, 255, 0.92);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-fallback: #0f172a;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.25);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-weight: 400;
    color: var(--color-text);
    background: var(--glass-fallback);
    line-height: 1.5;
}

body.modal-open {
    overflow: hidden;
}

/* Aurora background */
.aurora-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: linear-gradient(145deg, #0b1020 0%, #111827 40%, #0f172a 100%);
}

.aurora-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    animation: aurora-drift 18s ease-in-out infinite alternate;
}

.aurora-blob--1 {
    width: 55vw;
    height: 55vw;
    max-width: 600px;
    max-height: 600px;
    top: -10%;
    left: -5%;
    background: radial-gradient(circle, var(--color-indigo), transparent 70%);
}

.aurora-blob--2 {
    width: 45vw;
    height: 45vw;
    max-width: 500px;
    max-height: 500px;
    top: 20%;
    right: -8%;
    background: radial-gradient(circle, var(--color-pink), transparent 70%);
    animation-delay: -4s;
}

.aurora-blob--3 {
    width: 40vw;
    height: 40vw;
    max-width: 450px;
    max-height: 450px;
    bottom: -5%;
    left: 25%;
    background: radial-gradient(circle, var(--color-cyan), transparent 70%);
    animation-delay: -8s;
}

.aurora-blob--4 {
    width: 35vw;
    height: 35vw;
    max-width: 400px;
    max-height: 400px;
    bottom: 15%;
    right: 20%;
    background: radial-gradient(circle, var(--color-primary), transparent 70%);
    animation-delay: -12s;
}

@keyframes aurora-drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(3%, 4%) scale(1.08); }
}

.page-wrap {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 2rem 1.25rem 3rem;
    max-width: 960px;
    margin: 0 auto;
}

/* Glass panels */
.glass-card,
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    transition: transform var(--transition), box-shadow var(--transition);
}

@supports (backdrop-filter: blur(20px)) {
    .glass-card,
    .glass-panel {
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
    }
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

/* Auth pages */
.auth-page .page-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2.25rem 2rem;
}

.auth-card__header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-card h1 {
    margin: 0.75rem 0 0.35rem;
    font-size: 1.65rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.auth-footer {
    text-align: center;
    margin: 1.5rem 0 0;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.auth-footer a {
    color: var(--color-cyan);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.logo-mark {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-indigo));
    box-shadow: 0 4px 20px rgba(79, 142, 247, 0.35);
}

.logo-mark svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.logo-mark--sm {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.logo-mark--sm svg {
    width: 22px;
    height: 22px;
}

/* Typography */
h2, h3 {
    margin: 0 0 0.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

.text-muted { color: var(--color-muted); }
.text-sm { font-size: 0.875rem; }
.mono { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 0.85em; }

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-field span {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
}

.form-field input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.25);
    color: var(--color-text);
    font: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-field input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.form-field input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.25);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.35rem;
    border-radius: var(--radius-md);
    border: none;
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.btn--primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-indigo));
    color: #fff;
    box-shadow: 0 4px 16px rgba(79, 142, 247, 0.35);
}

.btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(79, 142, 247, 0.45);
}

.btn--glow:hover {
    box-shadow: 0 0 24px rgba(79, 142, 247, 0.5), 0 6px 24px rgba(99, 102, 241, 0.35);
}

.btn--danger {
    background: linear-gradient(135deg, #ef4444, var(--color-danger));
    color: #fff;
}

.btn--ghost {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--color-text);
}

.btn--ghost.btn--danger {
    color: var(--color-danger);
    border-color: rgba(248, 113, 113, 0.35);
}

.btn--sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert--error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

/* Dashboard */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.top-bar__brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.top-bar__brand strong {
    display: block;
    font-size: 1rem;
}

.dashboard-grid {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 720px) {
    .dashboard-grid {
        grid-template-columns: 1.4fr 1fr;
    }
    .dashboard-card--hero {
        grid-row: span 2;
    }
}

.dashboard-card {
    padding: 1.5rem 1.35rem;
}

.status-panel {
    margin: 1.25rem 0;
}

.status-badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge--sm {
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
}

.status-badge--connected {
    background: rgba(52, 211, 153, 0.2);
    color: var(--color-success);
    box-shadow: 0 0 12px rgba(52, 211, 153, 0.35);
}

.status-badge--pending {
    background: rgba(79, 142, 247, 0.2);
    color: var(--color-cyan);
    animation: pulse-badge 2s ease-in-out infinite;
}

.status-badge--disconnected,
.status-badge--muted {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-muted);
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(34, 211, 238, 0.2); }
    50% { opacity: 0.85; box-shadow: 0 0 16px rgba(34, 211, 238, 0.45); }
}

.status-detail {
    margin: 0.75rem 0 0;
    color: var(--color-muted);
}

.status-meta {
    margin: 1rem 0 0;
    display: grid;
    gap: 0.65rem;
}

.status-meta div {
    display: flex;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.status-meta dt {
    min-width: 110px;
    color: var(--color-muted);
    font-weight: 500;
}

.status-meta dd {
    margin: 0;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.device-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.device-list__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.875rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.modal[hidden] {
    display: none;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
}

.modal__card {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 2rem 1.75rem;
    text-align: center;
    animation: modal-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__close {
    position: absolute;
    top: 0.75rem;
    right: 0.85rem;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition);
}

.modal__close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* QR stage */
.phone-step {
    margin-top: 1.25rem;
    text-align: left;
}

.phone-step__hint {
    margin: 0.5rem 0 1.25rem;
}

.phone-step__hint code {
    font-size: 0.85em;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

.btn--block {
    width: 100%;
}

.qr-stage {
    margin-top: 1.25rem;
}

.qr-frame {
    display: inline-block;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    min-width: 240px;
    min-height: 240px;
    display: grid;
    place-items: center;
}

.qr-frame--pulse {
    animation: qr-pulse 2.5s ease-in-out infinite;
}

@keyframes qr-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(79, 142, 247, 0.4), 0 4px 24px rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 0 0 6px rgba(34, 211, 238, 0.15), 0 4px 24px rgba(0, 0, 0, 0.2); }
}

.qr-image {
    width: 220px;
    height: 220px;
    object-fit: contain;
    border-radius: 8px;
}

.qr-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: #64748b;
    font-size: 0.9rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.qr-hint {
    margin: 1rem 0 0;
    font-size: 0.875rem;
    color: var(--color-muted);
}

/* Success state */
.qr-success {
    padding: 1.5rem 0;
    animation: fade-in 0.4s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.success-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-cyan), var(--color-success));
    display: grid;
    place-items: center;
    box-shadow: 0 0 32px rgba(52, 211, 153, 0.4);
}

.success-icon svg {
    width: 36px;
    height: 36px;
    color: #fff;
}

.success-check {
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
    animation: draw-check 0.5s ease 0.2s forwards;
}

@keyframes draw-check {
    to { stroke-dashoffset: 0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
