/* ==============================
   Relai Code Portal
   Matches relaicode.com design
   ============================== */

:root {
    --bg: #07070a;
    --bg-surface: #0c0c14;
    --bg-card: #111119;
    --bg-card-hover: #16161f;
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --text-dim: #555568;
    --accent-blue: #4d7cff;
    --accent-purple: #a855f7;
    --accent-cyan: #22d3ee;
    --gradient-primary: linear-gradient(135deg, #4d7cff 0%, #a855f7 50%, #ec4899 100%);
    --gradient-subtle: linear-gradient(135deg, rgba(77, 124, 255, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    --radius: 12px;
    --radius-lg: 20px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 1.5rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ---- Background effects ---- */

.bg-noise {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.03;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    animation: float 20s ease-in-out infinite;
}

.bg-glow-1 {
    width: 500px;
    height: 500px;
    background: rgba(77, 124, 255, 0.06);
    top: -10%;
    left: -5%;
}

.bg-glow-2 {
    width: 400px;
    height: 400px;
    background: rgba(168, 85, 247, 0.05);
    top: 40%;
    right: -10%;
    animation-delay: -7s;
}

.bg-glow-3 {
    width: 550px;
    height: 550px;
    background: rgba(236, 72, 153, 0.04);
    bottom: -15%;
    left: 30%;
    animation-delay: -13s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -20px) scale(1.05); }
    50% { transform: translate(-20px, 30px) scale(0.95); }
    75% { transform: translate(20px, 20px) scale(1.02); }
}

/* ---- Layout ---- */

.container {
    width: 100%;
    max-width: 480px;
    position: relative;
    z-index: 1;
}

/* ---- Brand ---- */

.brand {
    display: block;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    text-decoration: none;
    margin-bottom: 2rem;
    transition: opacity 0.2s;
}

.brand:hover {
    opacity: 0.8;
}

.brand svg {
    display: block;
    margin: 0 auto;
}

/* ---- Card ---- */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.4;
}

/* ---- Tabs ---- */

.tab-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    padding: 3px;
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    text-align: center;
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    user-select: none;
}

.tab:hover {
    color: var(--text);
}

#tab-login:checked ~ .tabs label[for="tab-login"],
#tab-register:checked ~ .tabs label[for="tab-register"] {
    background: var(--bg-card);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#tab-login:checked ~ .tab-content .tab-panel-register,
#tab-register:checked ~ .tab-content .tab-panel-login {
    display: none;
}

/* ---- Typography ---- */

h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

.optional {
    color: var(--text-dim);
    font-weight: 400;
}

/* ---- Header row ---- */

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.header-row h1 {
    margin-bottom: 0.15rem;
}

.header-row .subtitle {
    margin-bottom: 0;
}

/* ---- Forms ---- */

.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 0.7rem 0.875rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.25s ease;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover {
    border-color: var(--border-hover);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(77, 124, 255, 0.15);
}

input::placeholder {
    color: var(--text-dim);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-feedback {
    font-size: 0.8rem;
    font-weight: 500;
    transition: opacity 0.2s;
}

.form-feedback.success {
    color: #4ade80;
}

.form-feedback.error {
    color: #f87171;
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.25s ease;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    width: 100%;
    margin-top: 0.5rem;
    box-shadow: 0 0 20px rgba(77, 124, 255, 0.2), 0 0 40px rgba(168, 85, 247, 0.1);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px rgba(77, 124, 255, 0.3), 0 0 60px rgba(168, 85, 247, 0.15);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--gradient-subtle);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    background: linear-gradient(135deg, rgba(77, 124, 255, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

/* ---- Links ---- */

.links {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
}

.links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.825rem;
    font-weight: 500;
    transition: color 0.2s;
}

.links a:hover {
    color: var(--accent-blue);
}

/* ---- Alerts ---- */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.alert-info {
    background: rgba(77, 124, 255, 0.1);
    border: 1px solid rgba(77, 124, 255, 0.2);
    color: #80a0ff;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* ==============================
   Account page
   ============================== */

.account {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gradient-primary);
    opacity: 0.15;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-header h2 {
    margin: 0;
}

/* ---- Info rows ---- */

.info-section {
    margin: 0.5rem 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .label {
    color: var(--text-muted);
    font-size: 0.825rem;
    font-weight: 500;
}

.info-row .value {
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
}

.mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    letter-spacing: -0.01em;
}

/* ---- Badges ---- */

.badge {
    padding: 0.2rem 0.7rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: #4ade80;
}

.badge-none {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.badge-canceled, .badge-past_due {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
}

/* ---- Subscription ---- */

.sub-active {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.sub-detail {
    margin-bottom: 1rem;
}

.plan-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.plan-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.plan-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
    opacity: 0.3;
}

.plan-card.featured {
    border-color: rgba(77, 124, 255, 0.2);
    background: linear-gradient(135deg, rgba(77, 124, 255, 0.06) 0%, rgba(168, 85, 247, 0.06) 100%);
}

.plan-card.featured::before {
    opacity: 0.7;
}

.plan-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4ade80;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    margin-bottom: 0.75rem;
    width: fit-content;
}

.plan-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.plan-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.plan-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.plan-price {
    text-align: right;
}

.price-amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
}

.price-period {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin-bottom: 1.25rem;
    flex: 1;
}

.plan-features li {
    padding: 0.35rem 0 0.35rem 1.5rem;
    position: relative;
    font-size: 0.85rem;
    color: var(--text);
}

.plan-features li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.65rem;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-blue);
    box-shadow: 0 0 6px rgba(77, 124, 255, 0.4);
}

/* ---- Download ---- */

.download-cta {
    text-align: center;
    padding: 0.5rem 0;
}

.download-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.btn-download {
    gap: 0.5rem;
    width: auto;
    display: inline-flex;
    margin-bottom: 0.75rem;
}

.download-note {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ---- Preferences ---- */

.pref-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.pref-label {
    font-size: 0.875rem;
    color: var(--text);
    font-weight: 500;
    display: block;
}

.pref-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    display: block;
    margin-top: 0.1rem;
}

/* ---- Toggle switch ---- */

.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    border: 1px solid var(--border);
    transition: all 0.25s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.25s ease;
}

.toggle input:checked + .toggle-slider {
    background: rgba(77, 124, 255, 0.3);
    border-color: rgba(77, 124, 255, 0.4);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: var(--accent-blue);
    box-shadow: 0 0 6px rgba(77, 124, 255, 0.5);
}

/* ---- Sign out ---- */

.sign-out-btn {
    width: 100%;
    justify-content: center;
    color: var(--text-dim);
    border-color: transparent;
}

.sign-out-btn:hover {
    border-color: var(--border);
    color: var(--text-muted);
}

/* ---- Fade-in animation ---- */

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

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

/* ---- Welcome overlay ---- */

.welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.welcome-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    max-width: 480px;
    width: 100%;
    position: relative;
    overflow: hidden;
    text-align: center;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
    opacity: 0.8;
}

.welcome-check {
    margin-bottom: 1rem;
    animation: checkPop 0.5s ease 0.2s both;
}

@keyframes checkPop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.welcome-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.welcome-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.welcome-steps {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.welcome-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 0 16px rgba(77, 124, 255, 0.25);
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.2rem;
}

.step-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.step-email {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: rgba(77, 124, 255, 0.1);
    border: 1px solid rgba(77, 124, 255, 0.2);
    border-radius: 8px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.8rem;
    color: #80a0ff;
    letter-spacing: -0.01em;
}

.welcome-btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.welcome-open-btn {
    width: 100%;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
}

.welcome-download-btn {
    width: 100%;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    font-size: 0.9rem;
    color: #fff;
}

.welcome-dismiss {
    width: 100%;
    justify-content: center;
    margin-top: 0;
    color: var(--text-dim);
}

.welcome-dismiss:hover {
    color: var(--text-muted);
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
    body {
        padding: 2rem 1rem;
    }

    .card, .section {
        padding: 1.25rem;
        border-radius: var(--radius);
    }

    .brand {
        margin-bottom: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .plan-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .plan-price {
        text-align: left;
    }

    .plan-cards {
        grid-template-columns: 1fr;
    }
}
