:root {
    --modal-bg: #ffffff;
    --text-main: #111111;
    --text-muted: #888888;
    --badge-bg: #eef4ff;
    --badge-text: #4d8aff;
    --hover-bg: #f4f6f8;
    --btn-bg: #f2f3f5;
    --grid-bg: #f4f5f7;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-family);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0f2f5;
    position: relative;
    overflow: hidden;
}

.background-blur {
    position: absolute;
    top: -20px; left: -20px; right: -20px; bottom: -20px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: -1;
}

/* =========================================
   MODAL BASE 
   Changed height to fit-content so it wraps 
   the content naturally instead of stretching.
   ========================================= */
.modal {
    width: 100%;
    max-width: 380px; 
    background: var(--modal-bg);
    border-radius: 24px;
    padding: 24px 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    position: relative;
    z-index: 1;
    height: fit-content; /* Fixes the "too far down" issue */
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    flex-direction: column;
    width: 100%;
}

.view.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.2s;
}
.icon-btn:hover { background: var(--hover-bg); }

/* ================= VIEW 1 STYLES ================= */
.wallet-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px; /* Tight spacing right above search bar */
    /* Removed flex-grow: 1 so it doesn't push the search bar down */
}

.wallet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    cursor: pointer;
}

.wallet-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.wallet-name {
    font-size: 15px;
    font-weight: 400;
    color: var(--text-main);
}

.badge {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    background-color: var(--badge-bg);
    color: var(--badge-text);
    letter-spacing: 0.02em;
}

.wallet-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background-color: #fcfcfc; 
}

.wallet-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Fake Search Button */
.search-fake-btn {
    background-color: var(--btn-bg);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s;
}
.search-fake-btn:hover { background-color: #e5e7eb; }

.fake-placeholder {
    color: #555;
    font-size: 15px;
    flex-grow: 1;
}

.shortcut {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    background: #ffffff;
    padding: 2px 8px;
    border-radius: 6px;
}

.modal-footer {
    text-align: center;
    font-size: 13px;
    color: #888;
    padding-top: 20px;
    flex-shrink: 0;
}
.modal-footer .brand { color: var(--text-main); font-weight: 500; }


/* ================= VIEW 2 STYLES ================= */
/* For the "All Wallets" view, we DO need it to stretch to allow scrolling */
#view-all {
    height: 500px; /* Fixed height only for the grid view */
}

.search-real-input {
    background-color: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-shrink: 0;
}
.search-real-input:focus-within { border-color: #a0a0a0; }

.search-real-input input {
    border: none;
    background: transparent;
    flex-grow: 1;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-main);
    outline: none;
}

.wallet-grid-container {
    flex-grow: 1;
    overflow-y: auto;
    margin: 0 -6px;
    padding: 0 6px;
}
.wallet-grid-container::-webkit-scrollbar { width: 6px; }
.wallet-grid-container::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

.wallet-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding-bottom: 10px;
}

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--grid-bg);
    border-radius: 18px;
    padding: 14px 8px;
    cursor: pointer;
    text-align: center;
    aspect-ratio: 1 / 1;
    text-decoration: none;
}
.grid-item:hover { background-color: #e5e7eb; }

.grid-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.grid-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.grid-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 2px;
}
/* ================= VIEW 3 STYLES ================= */
#view-connecting {
    height: 520px; /* Slightly shorter than the grid view */
}

.connecting-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-top: -20px; /* Slight upward shift to balance the layout */
}

/* Spinner Setup */
.spinner-container {
    position: relative;
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
}

/* The spinning ring - matched to your exact screenshot style */
.spinner-ring {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    /* Blue arc on top, transparent everywhere else */
    border: 2.5px solid transparent;
    border-top-color: #3b82f6; 
    animation: spin 1.5s linear infinite; /* Slow, continuous spin */
}

/* The icon inside the spinner */
.connecting-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #fcfcfc;
}

.connecting-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Spin Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Text Layout */
.connecting-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.connecting-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: #777;
    margin-bottom: 24px;
}

/* Try Again Button */
.try-again-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #111;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.2s;
}

.try-again-btn:hover {
    background-color: var(--hover-bg);
}

/* Bottom "Get Wallet" Prompt */
.get-wallet-prompt {
    background-color: var(--btn-bg);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#prompt-text {
    font-size: 14px;
    color: #555;
}

.get-btn {
    background-color: var(--badge-bg);
    color: var(--badge-text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background-color 0.2s;
}

.get-btn:hover {
    background-color: #e0e7ff;
}
/* ================= VIEW 4 STYLES ================= */
#view-import {
    height: 520px;
}

/* Tabs */
.import-tabs {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: #9ca3af; /* Gray for inactive */
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px; /* Overlap the border */
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn.active {
    color: #111111;
    border-bottom: 2px solid #111111;
}

/* Content Area */
.import-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Warning Box */
.warning-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background-color: #fffbeb; /* Light orange */
    border: 1px solid #fcd34d; /* Orange border */
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 20px;
}

.warning-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.warning-box p {
    font-size: 13px;
    color: #b45309; /* Dark orange text */
    line-height: 1.4;
}

/* Input Fields */
.tab-content {
    display: none;
    flex-direction: column;
    flex-grow: 1;
}

.tab-content.active {
    display: flex;
}

.input-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.input-desc {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.import-input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 16px;
    font-size: 15px;
    font-family: inherit;
    color: #111;
    resize: none;
    outline: none;
    height: 120px; /* For textarea */
    line-height: 1.5;
}

.import-input:focus {
    border-color: #9ca3af;
}

.import-input::placeholder {
    color: #9ca3af;
}

/* Submit Button */
.connect-submit-btn {
    margin-top: auto; /* Pushes button to bottom */
    background-color: #111111;
    color: #ffffff;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.2s;
}

.connect-submit-btn:hover {
    background-color: #333333;
}