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

:root {
    --bg-primary:      #ffffff;
    --bg-secondary:    #f8f9fb;
    --bg-card:         #ffffff;
    --bg-card-hover:   #f1f3f7;
    --bg-input:        #f8f9fb;
    --text-primary:    #0b0e14;
    --text-secondary:  #5c667b;
    --text-muted:      #8b93a0;
    --accent-blue:     #0500FF; /* Trust Wallet Blue */
    --accent-blue-hover: #0400cc;
    --accent-green:    #00c076; /* Trust Wallet Green (adjusted for contrast) */
    --border:          #e6e8ec;
    --border-light:    #f1f3f7;
    --error:           #ef4444;
    --success:         #00c076;
    --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: #f0f2f5;
    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: var(--bg-primary);
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 12px 48px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
}

/* ===== PAGES ===== */
.page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    transition: opacity .3s var(--ease), transform .3s 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(-20px); }

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

/* ===== LANGUAGE DROPDOWN ===== */
.lang-dropdown-wrap {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 50;
}
.lang-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: var(--r-full);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: all .2s;
}
.lang-trigger:hover, .lang-trigger.open {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.lang-globe { display: flex; align-items: center; }
.lang-chevron { display: flex; align-items: center; transition: transform .2s; }
.lang-trigger.open .lang-chevron { transform: rotate(180deg); }

.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateY(-5px);
    pointer-events: none;
    transition: all .2s;
}
.lang-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
    text-align: left;
}
.lang-option:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.lang-option.active { color: var(--text-primary); font-weight: 600; }
.lang-flag { font-size: 16px; }
.lang-name { flex: 1; }
.lang-check { color: var(--accent-green); display: flex; align-items: center; }
.lang-check.hidden { visibility: hidden; }

/* ===== LOGO AREA ===== */
.logo-area {
    margin-top: auto;
    margin-bottom: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.logo-img {
    width: 100px;
    height: 100px;
    position: relative;
    z-index: 11;
    background: transparent;
    border: none;
    box-shadow: none;
    object-fit: contain;
}

.welcome-title {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 48px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* ===== BUTTONS ===== */
.welcome-buttons { width: 100%; display: flex; flex-direction: column; gap: 16px; margin-top: auto; }

.btn {
    width: 100%;
    padding: 16px 24px;
    border-radius: var(--r-full);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--accent-blue);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(5, 0, 255, 0.2);
}
.btn-primary:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(5, 0, 255, 0.3);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--accent-blue);
    border: 1px solid var(--border-light);
}
.btn-secondary:hover {
    background: rgba(5, 0, 255, 0.05);
    border-color: rgba(5, 0, 255, 0.2);
}

/* ===== PAGE HEADER ===== */
.page-header { padding: 24px 24px 16px; flex-shrink: 0; display: flex; align-items: center; }
.back-btn {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    margin-left: -8px;
    border-radius: var(--r-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.back-btn:hover { background: var(--bg-secondary); }

/* ===== PAGE BODY ===== */
.page-body { padding: 0 24px 24px; flex: 1; display: flex; flex-direction: column; }
.page-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}
.page-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 32px;
}

/* ===== RESTORE OPTIONS ===== */
.restore-options { display: flex; flex-direction: column; gap: 16px; }
.restore-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
    color: var(--text-primary);
}
.restore-option:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.option-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent-blue);
    background: rgba(5, 0, 255, 0.08);
    border-radius: var(--r-full);
}
.option-text { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.option-title { font-size: 16px; font-weight: 600; }
.option-subtitle { font-size: 14px; color: var(--text-secondary); }
.option-arrow { color: var(--text-muted); }

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

.input-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--r-full);
    padding: 4px;
    margin-bottom: 24px;
}
.tab-btn {
    flex: 1; padding: 10px 16px;
    border: none; background: transparent;
    color: var(--text-secondary);
    font-family: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; border-radius: var(--r-full);
    transition: all .2s;
}
.tab-btn.active  { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.tab-btn:hover:not(.active) { color: var(--text-primary); }

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

.input-label {
    display: block; font-size: 14px; font-weight: 600;
    color: var(--text-primary); margin-bottom: 12px;
}

.seed-textarea {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: all 0.2s;
}
.seed-textarea::placeholder { color: var(--text-muted); }
.seed-textarea:focus {
    border-color: var(--accent-blue);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(5, 0, 255, 0.1);
}
.seed-textarea.error { border-color: var(--error); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); }
.seed-textarea.valid { border-color: var(--success); box-shadow: 0 0 0 3px rgba(0, 192, 118, 0.1); }

.input-hint {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
    min-height: 18px;
}
.input-hint.ok   { color: var(--success); }
.input-hint.warn { color: #f59e0b; }
.input-hint.err  { color: var(--error); }

.help-link {
    display: flex; align-items: center; gap: 8px;
    margin-top: 16px; color: var(--accent-blue);
    font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity .2s;
}
.help-link:hover { opacity: 0.8; }

.error-message {
    margin-top: 16px; padding: 12px 16px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--r-md);
    color: var(--error); font-size: 14px; font-weight: 500;
    display: flex; align-items: center; gap: 10px;
}
.error-message::before { content: "!"; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: var(--error); color: #fff; border-radius: 50%; font-size: 12px; font-weight: bold; }

.hidden { display: none !important; }

.seed-footer { margin-top: auto; padding-top: 24px; }

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.loading-content { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.spinner-ring {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent-blue);
    border-left-color: var(--accent-green);
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
.loading-text { font-size: 16px; color: var(--text-primary); font-weight: 600; }

/* ===== SCROLLBAR ===== */
.page::-webkit-scrollbar { width: 6px; }
.page::-webkit-scrollbar-track { background: transparent; }
.page::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }

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