/**
 * ZooBC Wallet Styles
 */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
}

/* Prevent UI flash before JS decides which screen to show */
body.booting .app-container {
    visibility: hidden;
}

.boot-cover {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

body.booting .boot-cover {
    display: flex;
}

.boot-cover-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ==================== Layout ==================== */

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: block;
    width: 180px;
    max-width: 100%;
    height: auto;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.logo span {
    color: var(--text-color);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-right: 12px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.main-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ==================== Cards ==================== */

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
}

/* ==================== Buttons ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

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

.btn-outline:hover {
    background: var(--bg-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn svg {
    width: 16px;
    height: 16px;
    margin-right: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== Forms ==================== */

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-color);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-checkbox input {
    width: 18px;
    height: 18px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    color: var(--danger-color);
    font-size: 12px;
    margin-top: 4px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group .form-input {
    flex: 1;
}

/* ==================== Seed Phrase ==================== */

.seed-phrase-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-color);
    font-family: monospace;
    font-size: 13px;
}

.seed-phrase-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
}

.seed-phrase-number {
    min-width: 24px;
    text-align: right;
    color: var(--text-muted);
    font-size: 12px;
}

.seed-phrase-word {
    font-weight: 600;
    letter-spacing: 0.2px;
}

.seed-verify-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

@media (max-width: 720px) {
    .seed-phrase-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .seed-phrase-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .seed-verify-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ==================== Balance Display ==================== */

.balance-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: var(--radius-lg);
    padding: 32px;
}

.balance-label {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 8px;
}

.balance-amount {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 4px;
}

.balance-amount .amount-int {
    letter-spacing: -0.02em;
}

.balance-amount .amount-frac {
    font-size: 0.62em;
    vertical-align: top;
    position: relative;
    top: 0.15em;
    opacity: 0.9;
}

.balance-amount .amount-unit {
    font-size: 0.45em;
    font-weight: 600;
    margin-left: 6px;
    opacity: 0.85;
    vertical-align: top;
    position: relative;
    top: 0.35em;
}

.balance-sub {
    font-size: 14px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.balance-sub .amount-frac,
.balance-sub .amount-unit {
    font-size: 0.9em;
    vertical-align: top;
    position: relative;
    top: 0.05em;
}

.balance-refresh {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    user-select: none;
}

.balance-refresh:hover {
    background: rgba(255, 255, 255, 0.22);
}

.refresh-ring {
    width: 18px;
    height: 18px;
}

.refresh-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 3.2;
}

.refresh-ring-fg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.95);
    stroke-width: 3.2;
    stroke-linecap: round;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.refresh-label {
    font-size: 12px;
    font-weight: 700;
    opacity: 0.95;
    min-width: 2ch;
    text-align: right;
}

.balance-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.balance-actions .btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.balance-actions .btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==================== Account Selector ==================== */

.account-selector {
    position: relative;
}

.account-current {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
    cursor: pointer;
}

.account-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-weight: 500;
}

.account-address {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-top: 4px;
    display: none;
    z-index: 100;
}

.account-dropdown.show {
    display: block;
}

.account-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
}

.account-dropdown-item:hover {
    background: var(--bg-color);
}

/* ==================== Transaction List ==================== */

.tx-list {
    list-style: none;
}

.tx-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.tx-item:last-child {
    border-bottom: none;
}

.tx-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
}

.tx-icon.send {
    background: #fef2f2;
    color: var(--danger-color);
}

.tx-icon.receive {
    background: #f0fdf4;
    color: var(--success-color);
}

.tx-details {
    flex: 1;
}

.tx-type {
    font-weight: 500;
}

.tx-address {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

.tx-amount {
    text-align: right;
}

.tx-amount.send {
    color: var(--danger-color);
}

.tx-amount.receive {
    color: var(--success-color);
}

.tx-status {
    font-size: 12px;
    color: var(--text-muted);
}

.tx-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tx-controls .tx-filter {
    width: auto;
}

.tx-controls select.tx-filter {
    min-width: 110px;
    padding: 8px 12px;
    font-size: 13px;
}

.tx-controls label.tx-filter {
    font-size: 13px;
    color: var(--text-muted);
    user-select: none;
}

/* ==================== Chats ==================== */

.chat-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 48px);
    gap: 16px;
}

.chat-sidebar,
.chat-main {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px;
    border-bottom: 1px solid var(--border-color);
}

.chat-sidebar-title {
    font-size: 18px;
    font-weight: 600;
}

.chat-thread-list {
    list-style: none;
    overflow: auto;
}

.chat-thread {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.chat-thread:hover {
    background: var(--bg-color);
}

.chat-thread.active {
    background: rgba(37, 99, 235, 0.08);
}

.chat-thread-title {
    font-weight: 600;
    font-size: 14px;
}

.chat-thread-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.chat-back {
    display: none;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-title {
    font-weight: 700;
    font-size: 14px;
}

.chat-header-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: var(--bg-color);
}

.chat-bubble {
    max-width: 70%;
    padding: 10px 12px;
    border-radius: 14px;
    margin: 6px 0;
    font-size: 14px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble.out {
    margin-left: auto;
    background: rgba(37, 99, 235, 0.14);
    border: 1px solid rgba(37, 99, 235, 0.20);
}

.chat-bubble.in {
    margin-right: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.chat-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

.chat-compose {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
}

.chat-input {
    min-height: 42px;
    max-height: 140px;
    resize: none;
}

.chat-encrypt {
    padding-bottom: 6px;
}

@media (max-width: 900px) {
    .chat-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .chat-sidebar {
        display: block;
    }
    .chat-main {
        display: none;
    }
    .chat-layout.chat-open .chat-sidebar {
        display: none;
    }
    .chat-layout.chat-open .chat-main {
        display: flex;
    }
    .chat-back {
        display: inline-flex;
    }
}

/* ==================== Node List ==================== */

.node-list {
    list-style: none;
}

.node-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.node-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 12px;
}

.node-status.online {
    background: var(--success-color);
}

.node-status.offline {
    background: var(--danger-color);
}

.node-status.unknown {
    background: var(--text-muted);
}

.node-info {
    flex: 1;
    min-width: 0;
}

.node-title {
    font-size: 14px;
    font-weight: 600;
}

.node-url {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.node-name {
    font-size: 12px;
    color: var(--text-muted);
}

.mono-wrap {
    word-break: break-all;
    overflow-wrap: anywhere;
}

.node-latency {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 12px;
}

.item-actions {
    display: flex;
    gap: 8px;
}

.wallet-actions {
    display: flex;
    gap: 8px;
}

.wallet-actions .btn {
    flex: 1;
}

@media (max-width: 640px) {
    .wallet-actions {
        flex-direction: column;
    }
    .item-actions {
        flex-direction: column;
    }
    .node-latency {
        margin-right: 0;
    }
}

/* ==================== Tabs ==================== */

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

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

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

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

/* ==================== Modal ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

#dialogMessage {
    margin: 0 0 16px;
    white-space: pre-wrap;
}

/* ==================== Alerts ==================== */

.alert {
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ==================== Utilities ==================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 18px; }
.font-mono { font-family: monospace; }
.font-bold { font-weight: 600; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

.hidden { display: none; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 18px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.35);
    color: var(--success-color);
}

/* ==================== Responsive ==================== */

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 8px;
    }

    .nav-item {
        padding: 8px 16px;
        white-space: nowrap;
    }

    .sidebar-footer {
        display: none;
    }

    .balance-actions {
        flex-direction: column;
    }
}

/* ==================== Loading Spinner ==================== */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-text {
    margin-top: 12px;
    color: var(--text-muted);
}

/* ==================== Escrow Section ==================== */

.escrow-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 16px;
}

.escrow-toggle input {
    width: 20px;
    height: 20px;
}

.escrow-fields {
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

/* ==================== QR Code ==================== */

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
}

.qr-code {
    background: white;
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.qr-address {
    margin-top: 16px;
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    text-align: center;
    max-width: 300px;
}
