/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary:      #0f111a;
    --bg-secondary:    #151825;
    --bg-card:         #1c1f2e;
    --bg-card-hover:   #25293d;
    --bg-input:        #121420;
    --text-primary:    #ffffff;
    --text-secondary:  #9ca3af;
    --text-muted:      #6b7280;
    --accent-purple:   #9333ea;
    --accent-blue:     #2563eb;
    --accent-gradient: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%);
    --accent:          #7c3aed; /* Middle purple-blue */
    --accent-dim:      rgba(124, 58, 237, 0.15);
    --border:          #2a2f45;
    --border-light:    #374151;
    --btn-light-bg:    #ffffff;
    --btn-light-text:  #0f111a;
    --error:           #ef4444;
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-full: 999px;
    --ease: cubic-bezier(.4,0,.2,1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #05060a;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== POPUP ===== */
.popup-container {
    width: 375px;
    height: 620px;
    background: #05060a;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    box-shadow:
        0 0 0 1px rgba(255,255,255,.06),
        0 32px 64px -16px rgba(0,0,0,.85),
        0 0 100px rgba(124, 58, 237, 0.06);
}

/* ===== WEB3 BACKGROUND ===== */
.web3-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.glow-1 {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(147, 51, 234, 0.1) 0%, transparent 70%);
    filter: blur(60px);
    animation: ambient-move 15s infinite alternate;
}

.glow-2 {
    position: absolute;
    bottom: -10%;
    right: -10%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
    filter: blur(60px);
    animation: ambient-move 12s infinite alternate-reverse;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 30px 30px;
    mask-image: radial-gradient(circle at center, black 0%, transparent 80%);
}

@keyframes ambient-move {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

/* ===== PAGES ===== */
.page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(28px);
    pointer-events: none;
    transition: opacity .32s var(--ease), transform .32s var(--ease);
    overflow-y: auto;
    overflow-x: hidden;
}
.page.active  { opacity: 1; transform: translateX(0); pointer-events: auto; }
.page.exit-left { opacity: 0; transform: translateX(-28px); }

/* ===== PAGE 1: WELCOME ===== */
.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 28px 28px 32px;
    text-align: center;
    gap: 0;
}

/* ===== LANGUAGE DROPDOWN ===== */
.lang-dropdown-wrap {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 50;
}

.lang-trigger {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px 8px 11px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
    white-space: nowrap;
    user-select: none;
}
.lang-trigger:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}
.lang-trigger.open {
    background: var(--bg-card-hover);
    border-color: rgba(147, 51, 234, .4);
    color: var(--text-primary);
}

.lang-globe { display: flex; align-items: center; color: var(--accent); }

.lang-chevron {
    display: flex;
    align-items: center;
    transition: transform .25s var(--ease);
    color: var(--text-muted);
}
.lang-trigger.open .lang-chevron { transform: rotate(180deg); }

/* Dropdown menu */
.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 168px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--r-lg);
    padding: 6px;
    box-shadow:
        0 8px 32px rgba(0,0,0,.6),
        0 2px 8px rgba(0,0,0,.4),
        0 0 0 1px rgba(255,255,255,.04);
    opacity: 0;
    transform: translateY(-6px) scale(.97);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.lang-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    text-align: left;
}
.lang-option:hover { background: rgba(255,255,255,.05); color: var(--text-primary); }
.lang-option.active { color: var(--text-primary); }

.lang-flag { font-size: 18px; line-height: 1; }
.lang-name  { flex: 1; }

.lang-check { color: var(--accent); display: flex; align-items: center; }
.lang-check.hidden { visibility: hidden; }

/* Separator between options */
.lang-option + .lang-option {
    border-top: 1px solid rgba(255,255,255,.04);
}

/* ===== LOGO AREA REDESIGN ===== */
.logo-area {
    position: relative;
    width: 100%;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    perspective: 1000px;
}

/* ===== NEW DESIGN: THE HUB ===== */
.logo-area {
    position: relative;
    width: 100%;
    height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

/* ===== NEW DESIGN: CIRCULAR CYBER ORBIT ===== */
.logo-area {
    position: relative;
    width: 100%;
    height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
    background: radial-gradient(circle at center, rgba(147, 51, 234, 0.05) 0%, transparent 80%);
}

.orbit-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: area-drift 10s ease-in-out infinite alternate;
}

/* Cyber Nodes in Orbit */
.cyber-node {
    position: absolute;
    width: 52px;
    height: 52px;
    background: #0d1117;
    border: 1px solid rgba(147, 51, 234, 0.3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(147, 51, 234, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    /* Orbit Animation */
    animation: main-orbit 20s linear infinite;
}

@keyframes main-orbit {
    from { transform: rotate(0deg) translateX(130px) rotate(0deg); }
    to { transform: rotate(360deg) translateX(130px) rotate(-360deg); }
}

/* Offsets for each node to distribute them in the circle */
.node-btc  { animation-delay: 0s; }
.node-eth  { animation-delay: -3.33s; }
.node-sol  { animation-delay: -6.66s; }
.node-poly { animation-delay: -10s; }
.node-tron { animation-delay: -13.33s; }
.node-base { animation-delay: -16.66s; }

.cyber-node img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    filter: grayscale(0.2) brightness(1.1);
}

.cyber-node::after {
    content: '';
    position: absolute;
    inset: -2px;
    border: 1px solid #2563eb;
    border-radius: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cyber-node:hover {
    transform: scale(1.2) rotate(5deg) !important;
    border-color: #2563eb;
    box-shadow: 0 0 35px rgba(37, 99, 235, 0.4);
    z-index: 20;
    animation-play-state: paused;
}

.cyber-node:hover::after {
    opacity: 1;
    animation: neon-flicker 1s infinite;
}

@keyframes neon-flicker {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

/* Cyber Center Hub */
.cyber-hub {
    position: relative;
    z-index: 10;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: hub-breathe 4s infinite alternate ease-in-out;
}

@keyframes hub-breathe {
    from { transform: scale(0.95); filter: brightness(0.9); }
    to { transform: scale(1.05); filter: brightness(1.1); }
}

.cyber-hub::before {
    content: '';
    position: absolute;
    inset: -12px;
    border: 1px solid rgba(147, 51, 234, 0.2);
    border-radius: 50%;
    animation: pulse-ring 4s infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.5; }
    100% { transform: scale(1.5); opacity: 0; }
}

.logo-img {
    width: 86px;
    height: 86px;
    border-radius: 20px;
    box-shadow: 0 0 40px rgba(147, 51, 234, 0.4);
    background: #05060a;
    position: relative;
    z-index: 11;
    border: 1px solid rgba(147, 51, 234, 0.2);
}

.welcome-title {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 40px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes title-glow {
    from { text-shadow: 0 0 10px rgba(255,255,255,0.1); }
    to { text-shadow: 0 0 20px rgba(147, 51, 234, 0.3); }
}

/* Hide old design elements */
.nebula-bg, .soft-node, .soft-hub, .mesh-gradient, .star-field, .network-cloud, .logo-main-wrapper, .hub-connections { display: none !important; }

/* Hide old orbit elements */
.orbit-ring, .circle-decoration, .star-field { display: none; }

/* ===== BUTTONS: CYBER THEME ===== */
.welcome-buttons { width: 100%; display: flex; flex-direction: column; gap: 12px; }

.btn {
    width: 100%;
    padding: 16px 24px;
    border-radius: 16px;
    border: 1px solid rgba(147, 51, 234, 0.2);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.2px;
}

.btn-primary {
    background: linear-gradient(135deg, #9333ea 0%, #2563eb 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(147, 51, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(147, 51, 234, 0.5);
    filter: brightness(1.1);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
    backdrop-filter: blur(8px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(37, 99, 235, 0.5);
    transform: translateY(-2px);
}

/* ===== PAGE HEADER: CYBER THEME ===== */
.page-header { padding: 20px 20px 10px; flex-shrink: 0; }

.back-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(147, 51, 234, 0.1);
    border-color: rgba(147, 51, 234, 0.3);
}

/* ===== PAGE BODY: CYBER THEME ===== */
.page-body { padding: 10px 24px 28px; flex: 1; display: flex; flex-direction: column; }

.page-title {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.page-desc {
    font-size: 14.5px;
    color: #9ca3af;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* ===== RESTORE OPTIONS: CYBER THEME ===== */
.restore-options { display: flex; flex-direction: column; gap: 12px; }

.restore-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    width: 100%;
    font-family: inherit;
    color: #fff;
    backdrop-filter: blur(10px);
}

.restore-option:hover {
    background: rgba(147, 51, 234, 0.05);
    border-color: rgba(147, 51, 234, 0.3);
    transform: translateX(6px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.option-icon {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #9333ea;
    background: rgba(147, 51, 234, 0.1);
    border-radius: 14px;
}

.option-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.option-title { font-size: 15.5px; font-weight: 700; }
.option-subtitle { font-size: 13px; color: #9ca3af; line-height: 1.4; }
.option-arrow { color: rgba(255, 255, 255, 0.2); flex-shrink: 0; }

/* ===== SEED PAGE ===== */
.seed-body { position: relative; }

.input-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--r-md);
    padding: 3px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.tab-btn {
    flex: 1; padding: 10px 14px;
    border: none; background: transparent;
    color: var(--text-muted);
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; border-radius: 9px;
    transition: all .2s var(--ease);
}
.tab-btn.active  { background: var(--bg-card-hover); color: var(--text-primary); }
.tab-btn:hover:not(.active) { color: var(--text-secondary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.input-label {
    display: block; font-size: 13.5px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 9px;
}

.seed-textarea {
    width: 100%;
    min-height: 140px;
    padding: 20px;
    background: #0d1117;
    border: 1px solid rgba(147, 51, 234, 0.2);
    border-radius: 18px;
    color: #e6edf3;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 14.5px;
    line-height: 1.7;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 15px rgba(0,0,0,0.5);
}

.seed-textarea::placeholder { color: #4b5563; }
.seed-textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1), inset 0 2px 15px rgba(0,0,0,0.5);
}

.seed-textarea.error {
    border-color: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.1);
}

.seed-textarea.valid {
    border-color: #10b981;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.1);
}

/* Word count / hint below textarea */
.input-hint {
    margin-top: 7px;
    font-size: 12px;
    color: var(--text-muted);
    min-height: 16px;
    transition: color .2s;
}
.input-hint.ok   { color: #3ecf8e; }
.input-hint.warn { color: var(--accent); }
.input-hint.err  { color: var(--error); }

/* Help link */
.help-link {
    display: flex; align-items: center; gap: 7px;
    margin-top: 14px; color: var(--text-secondary);
    font-size: 13px; cursor: pointer; transition: color .2s;
}
.help-link:hover { color: var(--text-primary); }

/* ===== ERROR MESSAGE ===== */
.error-message {
    margin-top: 14px; padding: 13px 15px;
    background: rgba(255,77,77,.07);
    border: 1px solid rgba(255,77,77,.18);
    border-radius: var(--r-md);
    color: var(--error); font-size: 13px; font-weight: 500;
    display: flex; align-items: flex-start; gap: 8px;
    animation: shake .38s var(--ease);
}
.error-message::before { content: "⚠"; font-size: 15px; flex-shrink: 0; margin-top: 1px; }

@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-5px); }
    40%      { transform: translateX(5px); }
    60%      { transform: translateX(-3px); }
    80%      { transform: translateX(3px); }
}

.hidden { display: none !important; }

/* ===== FOOTER ===== */
.seed-footer { margin-top: auto; padding-top: 18px; }

/* ===== LOADING OVERLAY: CYBER THEME ===== */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 6, 10, 0.96);
    backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.4s ease;
}

.loading-content { display: flex; flex-direction: column; align-items: center; gap: 24px; }

.spinner-ring {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.05);
    border-top-color: #9333ea;
    animation: spin 0.8s linear infinite;
    position: relative;
}

.spinner-inner {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.03);
    border-bottom-color: #2563eb;
    animation: spin 0.5s linear infinite reverse;
}

.loading-text { font-size: 15px; color: #9ca3af; font-weight: 600; letter-spacing: 0.5px; }

/* ===== SCROLLBAR: CYBER THEME ===== */
.page::-webkit-scrollbar { width: 5px; }
.page::-webkit-scrollbar-track { background: transparent; }
.page::-webkit-scrollbar-thumb { 
    background: linear-gradient(to bottom, #9333ea, #2563eb); 
    border-radius: 10px; 
}

/* ===== RTL ===== */
.rtl { direction: rtl; }
.rtl .page-body,
.rtl .option-text,
.rtl .help-link,
.rtl .error-message { text-align: right; }
.rtl .restore-option { flex-direction: row-reverse; }
.rtl .option-arrow svg { transform: rotate(180deg); }
.rtl .back-btn svg    { transform: rotate(180deg); }
.rtl .help-link       { flex-direction: row-reverse; }
.rtl .error-message   { flex-direction: row-reverse; }
.rtl .seed-textarea   { direction: rtl; text-align: right; }

/* RTL: flip dropdown to left side */
.rtl .lang-dropdown-wrap { right: auto; left: 20px; }
.rtl .lang-menu { right: auto; left: 0; transform-origin: top left; }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
    .popup-container { width: 100vw; height: 100vh; border-radius: 0; }
}
