/*
  DOFaI Design System — LiquidGlass v3 (Alive)
  Theme: Obsidian Flow / LiquidGlass
  Principle: Absolute Dark Minimalism with High-End Physics
*/

:root {
    /* THE TRINITY PALETTE */
    --color-void: #050505;
    --color-ghost: #F2F2F2;
    --color-neon: #818CF8;
    /* Lighter Indigo (was #6366F1) */
    --color-neon-dark: #6366F1;

    /* Semantic Colors */
    --color-success: #10B981;
    --color-error: #EF4444;

    /* Utils */
    --glass-bg: rgba(5, 5, 5, 0.65);
    --glass-border: rgba(242, 242, 242, 0.08);
    --glass-blur: blur(16px);

    /* Physics */
    --ease-spring: cubic-bezier(0.25, 0.8, 0.25, 1);
    --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body {
    /* Hybrid: Inter for UI, Mono for Data */
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    background-color: var(--color-void);
    color: var(--color-ghost);
    min-height: 100vh;
    overflow: hidden;
}

/* Data/Code Font Utility */
.font-mono,
.balance-value,
.input-field,
.target-value,
.stat-value,
.app-title span {
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.03em;
}

/* ALIVE BACKGROUND (Aurora v2) */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: var(--color-void);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.5;
    mix-blend-mode: screen;
    /* Vibrant colors overlap */
    animation: float 10s infinite ease-in-out alternate;
}

.blob:nth-child(1) {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--color-neon) 0%, transparent 70%);
    top: -150px;
    left: -100px;
    animation-duration: 12s;
}

.blob:nth-child(2) {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #4F46E5 0%, transparent 70%);
    bottom: -100px;
    right: -100px;
    animation-duration: 15s;
    animation-delay: -2s;
    animation-direction: alternate-reverse;
}

.blob:nth-child(3) {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #818CF8 0%, transparent 70%);
    top: 40%;
    left: 30%;
    animation-duration: 18s;
    animation-delay: -5s;
}

/* Extra Blobs for "Alive" feel */
.blob:nth-child(4) {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, #6366F1 0%, transparent 70%);
    bottom: 20%;
    left: 10%;
    animation-duration: 14s;
    animation-delay: -8s;
    opacity: 0.3;
}

.blob:nth-child(5) {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #4338ca 0%, transparent 70%);
    top: 10%;
    right: 20%;
    animation-duration: 20s;
    animation-delay: -1s;
    opacity: 0.4;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }

    33% {
        transform: translate(30px, 50px) rotate(10deg) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) rotate(-5deg) scale(0.9);
    }

    100% {
        transform: translate(10px, -30px) rotate(5deg) scale(1.05);
    }
}

/* Grid Overlay on top of blobs */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -1;
    pointer-events: none;
    opacity: 0.7;
}

/* ACCESS DENIED OVERLAY */
#access-denied {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-void);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

#icon-lock {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* VIEW CONTAINER */
.view-container {
    position: relative;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top) + 12px);
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;

    /* Transition State (Hidden) */
    opacity: 0;
    visibility: hidden;
    /* KPI: Prevents clicks and interaction when hidden */
    transform: scale(0.95);
    /* Subtle scale instead of slide for stability */
    transition: opacity 0.3s ease, transform 0.3s var(--ease-spring), visibility 0.3s;
    will-change: opacity, transform;
    /* Hardware Acceleration */
}

.view.active {
    /* Active State (Visible) */
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    pointer-events: auto;
    z-index: 10;
    transition-delay: 0s;
}

/* NAVIGATION TABS */
.tab-bar {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 400px;
    height: 64px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--color-ghost);
    opacity: 0.4;
    font-family: inherit;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 12px;
    transition: all 0.3s var(--ease-spring);
    position: relative;
    cursor: pointer;
}

.tab-btn.active {
    opacity: 1;
    transform: scale(1.1);
    color: var(--color-neon);
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 20px;
    height: 2px;
    background: var(--color-neon);
    transition: transform 0.3s var(--ease-spring);
}

.tab-btn.active::after {
    transform: translateX(-50%) scaleX(1);
}

/* COMPONENTS */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur) saturate(180%);
    -webkit-backdrop-filter: var(--glass-blur) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    margin-bottom: 16px;
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.app-title span {
    color: var(--color-neon);
    text-shadow: 0 0 15px rgba(99, 102, 241, 0.6);
}

.app-ti.text-neon {
    color: var(--color-neon);
    opacity: 1;
    text-shadow: 0 0 10px rgba(129, 140, 248, 0.6);
    /* Matching new lighter neon */
    font-weight: 600;
}

/* BALANCE SECTION */
.balance-container {
    text-align: center;
    margin: 24px 0;
}

.balance-label {
    font-size: 12px;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.balance-value {
    font-size: 42px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.target-info {
    font-size: 14px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.target-info.visible {
    opacity: 1;
}

.target-label {
    color: #fff;
    opacity: 0.8;
}

.target-value {
    color: var(--color-success);
    font-weight: 500;
}

/* PROGRESS BAR */
.progress-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-top: 16px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.progress-container.visible {
    opacity: 1;
}

.progress-bar {
    height: 100%;
    background: var(--color-neon);
    width: 0%;
    border-radius: 10px;
    transition: width 1s var(--ease-spring);
    box-shadow: 0 0 10px var(--color-neon);
}

/* TYPOGRAPHY UTILS */
h3 {
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 16px;
    font-size: 16px;
}

.text-success {
    color: var(--color-success);
    opacity: 1;
}

.text-neon {
    color: var(--color-neon);
    opacity: 1;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-ghost);
    opacity: 0.2;
    transition: all 0.3s;
}

.status-badge.active .status-dot {
    background: var(--color-neon);
    opacity: 1;
    box-shadow: 0 0 8px var(--color-neon);
}

.status-badge.inactive .status-dot {
    background: var(--color-error);
    opacity: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 12px;
}

.stat-value {
    font-size: 18px;
    font-weight: 500;
    opacity: 0.9;
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    opacity: 0.4;
}

/* Buttons & Inputs */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* Fix: Remove gray tap overlay */
}

/* ... existing body styles ... */

.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-ghost);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.2s, box-shadow 0.2s;
    /* Faster transform for touch */
    border: 1px solid transparent;
    touch-action: manipulation;
    /* Fix: Optimize touch events */
}

/* Only Apply Hover on PC/Mouse to avoid sticky hover on mobile */
@media (hover: hover) {
    .btn:hover {
        transform: translateY(-2px);
        background: rgba(255, 255, 255, 0.08);
    }
}

.btn:active {
    transform: scale(0.96);
    transition-duration: 0.05s;
    /* Instant feedback */
}

.btn-primary {
    background: var(--color-neon);
    color: #fff;
    opacity: 1;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.btn.danger {
    background: var(--color-error);
    /* Solid Red */
    color: #fff;
    opacity: 1;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
    /* Red Glow */
    border: 1px solid transparent;
}

/* Expandable Animation */
.expandable {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-bottom: 0;
    transform: translateY(-10px);
    transition: all 0.4s var(--ease-spring);
}

.expandable.visible {
    max-height: 100px;
    /* Appsroximation */
    opacity: 1;
    margin-bottom: 16px;
    transform: translateY(0);
}


.form-group {
    margin-bottom: 16px;
}

.amount-hint {
    display: block;
    font-size: 11px;
    color: var(--color-neon);
    opacity: 0.7;
    margin-top: 6px;
    min-height: 14px;
    transition: opacity 0.2s;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
}

.input-with-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-btn .input-field {
    flex: 1;
}

.pct-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-ghost);
    opacity: 0.5;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease-spring);
    touch-action: manipulation;
}

.pct-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--color-neon);
    color: var(--color-neon);
    opacity: 1;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.pct-btn:active {
    transform: scale(0.92);
}

.form-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 8px;
    /* FIX: Use color alpha instead of opacity so children can override */
    color: rgba(242, 242, 242, 0.4);
    font-weight: 500;
}

.input-field {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px 14px;
    color: var(--color-ghost);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--color-neon);
    background: rgba(0, 0, 0, 0.4);
}

/* Remove Arrows/Spinners from Number Inputs */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}


/* Range Slider Styles */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    margin: 8px 0;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

input[type=range]:focus::-webkit-slider-runnable-track {
    background: var(--color-neon);
}

/* Toggle */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.switch {
    position: relative;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--color-ghost);
    border-radius: 50%;
    transition: .3s;
}

input:checked+.slider {
    background-color: var(--color-neon);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: #fff;
}

/* Pair Settings */
.pairs-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pair-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.pair-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.02em;
    min-width: 80px;
}

.pair-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pair-control-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pair-control-label {
    font-size: 10px;
    text-transform: uppercase;
    opacity: 0.4;
    letter-spacing: 0.03em;
}

.switch-sm {
    position: relative;
    width: 36px;
    height: 20px;
}

.switch-sm .slider:before {
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
}

.switch-sm input:checked+.slider:before {
    transform: translateX(16px);
}

/* Status Pill (stop-balance indicator) */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: all 0.3s var(--ease-spring);
    border: 1px solid transparent;
}

.status-pill--active {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--color-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.status-pill--danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-error);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
    animation: pill-pulse 2s ease-in-out infinite;
}

.status-pill--off {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: rgba(242, 242, 242, 0.3);
}

@keyframes pill-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.gemini-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.gemini-logo {
    flex-shrink: 0;
}

.gemini-desc {
    font-size: 11px;
    opacity: 0.4;
    line-height: 1.4;
}

.gemini-card.gemini-active {
    border-color: transparent;
    background:
        linear-gradient(var(--glass-bg), var(--glass-bg)) padding-box,
        linear-gradient(135deg, #4285F4, #EA4335, #FBBC05, #34A853) border-box;
    box-shadow:
        0 0 20px rgba(66, 133, 244, 0.15),
        0 0 20px rgba(234, 67, 53, 0.1),
        0 0 20px rgba(52, 168, 83, 0.1);
    animation: gemini-glow 4s ease-in-out infinite;
}

@keyframes gemini-glow {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(66, 133, 244, 0.15),
            0 0 10px rgba(234, 67, 53, 0.1),
            0 0 10px rgba(52, 168, 83, 0.1);
    }
    25% {
        box-shadow:
            0 0 10px rgba(66, 133, 244, 0.1),
            0 0 20px rgba(234, 67, 53, 0.2),
            0 0 10px rgba(251, 188, 5, 0.1);
    }
    50% {
        box-shadow:
            0 0 10px rgba(234, 67, 53, 0.1),
            0 0 20px rgba(251, 188, 5, 0.2),
            0 0 15px rgba(52, 168, 83, 0.15);
    }
    75% {
        box-shadow:
            0 0 10px rgba(251, 188, 5, 0.1),
            0 0 10px rgba(52, 168, 83, 0.15),
            0 0 20px rgba(66, 133, 244, 0.2);
    }
}

.gemini-locked {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
}

.gemini-locked::after {
    content: '🔷 Gemini';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 10px;
    opacity: 0.8;
    pointer-events: none;
}

.claude-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.claude-logo {
    flex-shrink: 0;
}

.claude-tabs {
    display: flex;
    gap: 6px;
}

.claude-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 6px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: var(--color-ghost);
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.3s var(--ease-spring);
    font-family: inherit;
}

.claude-tab.active {
    opacity: 1;
    background: rgba(217, 119, 87, 0.15);
    border-color: rgba(217, 119, 87, 0.4);
    color: #D97757;
    box-shadow: 0 0 12px rgba(217, 119, 87, 0.15);
}

.claude-tab:active {
    transform: scale(0.95);
}

.claude-tab-name {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.claude-tab-desc {
    font-size: 9px;
    opacity: 0.6;
}

.claude-card.claude-active {
    border-color: transparent;
    background:
        linear-gradient(var(--glass-bg), var(--glass-bg)) padding-box,
        linear-gradient(135deg, #D97757, #E8956A, #D97757) border-box;
    box-shadow: 0 0 20px rgba(217, 119, 87, 0.15);
    animation: claude-glow 3s ease-in-out infinite;
}

@keyframes claude-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(217, 119, 87, 0.15); }
    50% { box-shadow: 0 0 30px rgba(217, 119, 87, 0.25); }
}

.claude-locked {
    opacity: 0.4;
    pointer-events: none;
    position: relative;
}

.claude-locked::after {
    content: '🤖 Claude';
    position: absolute;
    top: 8px;
    right: 12px;
    font-size: 10px;
    opacity: 0.8;
    pointer-events: none;
}

.subscription-banner {
    text-align: center;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
    backdrop-filter: var(--glass-blur);
    transition: all 0.3s var(--ease-spring);
}

.subscription-active {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
    color: var(--color-success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.1);
}

.subscription-inactive {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--color-error);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.1);
}

.subscription-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.subscription-row .subscription-banner {
    flex: 1;
    margin-bottom: 0;
}

.subscription-price {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.02em;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--glass-blur);
    color: var(--color-neon);
    white-space: nowrap;
}