/* ═══════════════════════════════════════════════════════
   UJO JOURNAL — Premium Dark Theme
   ═══════════════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
    --bg:        #080c14;
    --bg2:       #0d1220;
    --surface:   #111827;
    --surface2:  #1a2236;
    --border:    #1f2d45;
    --border2:   #263347;
    --text:      #f0f4ff;
    --muted:     #7a8aaa;
    --muted2:    #4a5568;

    --accent:    #7c6cf0;
    --accent2:   #a78bfa;
    --accent-glow: rgba(124,108,240,0.3);

    --green:     #10b981;
    --green-dim: rgba(16,185,129,0.12);
    --red:       #ef4444;
    --red-dim:   rgba(239,68,68,0.12);
    --yellow:    #f59e0b;
    --yellow-dim:rgba(245,158,11,0.12);
    --blue:      #3b82f6;

    --font-pixel: 'Press Start 2P', monospace;
    --font-body:  'Inter', sans-serif;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;

    --topbar-h: 56px;
    --nav-h:    64px;
    --shadow:   0 4px 24px rgba(0,0,0,0.5);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }
input, select, textarea {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 11px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select option { background: var(--surface); }

/* ── Topbar ── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    padding-top: calc(40px + env(safe-area-inset-top, 20px));
    height: calc(var(--topbar-h) + 40px + env(safe-area-inset-top, 20px));
    background: rgba(8,12,20,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}
.topbar-brand { display: flex; align-items: baseline; gap: 6px; }
.topbar-logo {
    font-family: var(--font-pixel);
    font-size: 0.85em;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.topbar-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.xp-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(124,108,240,0.12);
    border: 1px solid rgba(124,108,240,0.25);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent2);
}
.xp-pill i { font-size: 10px; color: var(--yellow); }

/* ── Page Content ── */
.page-content {
    padding: 16px;
    max-width: 540px;
    margin: 0 auto;
}
.page-content.has-nav {
    padding-top: calc(var(--topbar-h) + 45px + 16px);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0) + 70px);
}

/* ── Bottom Nav ── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--nav-h) + 15px);
    background: rgba(8,12,20,0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + 24px);
}
.bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--r-md);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: color 0.2s;
    min-width: 48px;
}
.bnav-item i { font-size: 22px; transition: all 0.2s; }
.bnav-item.active { color: var(--accent2); }
.bnav-item.active i { transform: translateY(-2px); filter: drop-shadow(0 0 8px var(--accent)); }
.bnav-item:active { opacity: 0.7; }

/* ── Flash Messages ── */
.flash-wrap { position: fixed; top: calc(var(--topbar-h) + 8px); left: 8px; right: 8px; z-index: 200; display: flex; flex-direction: column; gap: 6px; }
.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    opacity: 1;
    transition: opacity 0.4s;
    border: 1px solid;
}
.flash-success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: #6ee7b7; }
.flash-danger   { background: rgba(239,68,68,0.1);  border-color: rgba(239,68,68,0.3);  color: #fca5a5; }
.flash-warning  { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: #fde68a; }
.flash-info     { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: #93c5fd; }
.flash-close { margin-left: auto; background: none; border: none; color: inherit; font-size: 16px; line-height: 1; cursor: pointer; opacity: 0.7; }

/* ── Image Zoom Modal ── */
.img-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 500;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.img-modal.open { display: flex; }
.img-modal img { max-width: 95vw; max-height: 90vh; object-fit: contain; border-radius: var(--r-md); }

/* ── Cards & Surfaces ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
}
.card-body { padding: 16px; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 18px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--accent-glow); transform: translateY(-1px); }
.btn-success {
    background: linear-gradient(135deg, #059669, var(--green));
    color: #fff;
    box-shadow: 0 4px 16px rgba(16,185,129,0.3);
}
.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.3);
}
.btn-ghost {
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-full { width: 100%; }

/* ── Form elements ── */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}
.form-control {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    padding: 11px 14px;
    font-size: 14px;
    width: 100%;
    transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--accent); outline: none; }

/* ── Tags / Badges ── */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
}
.tag-accent { background: rgba(124,108,240,0.12); color: var(--accent2); border: 1px solid rgba(124,108,240,0.2); }
.tag-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(16,185,129,0.25); }
.tag-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }
.tag-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,158,11,0.25); }

/* ── Index / Home page ── */
.home-hero {
    text-align: center;
    padding: 20px 0 24px;
}
.home-hero-title {
    font-family: var(--font-pixel);
    font-size: 0.8em;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}
.home-hero-sub { font-size: 13px; color: var(--muted); }

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}
.menu-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
}
.menu-card:hover, .menu-card:active {
    border-color: var(--accent);
    background: var(--surface2);
    transform: translateY(-2px);
}
.menu-card-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.menu-card-label { font-size: 12px; font-weight: 700; color: var(--text); }
.menu-card-sub { font-size: 10px; color: var(--muted); }

/* ── Journal ── */
.journal-wrapper { }

/* ── Stats bar ── */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.stat-cell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px 8px;
    text-align: center;
}
.stat-val { font-size: 22px; font-weight: 800; line-height: 1; }
.stat-lbl { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Trade card ── */
.trade-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
    margin-bottom: 12px;
    transition: transform 0.15s;
}
.trade-card:active { transform: scale(0.99); }
.trade-card-header { padding: 14px 14px 12px; }

.trade-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.3px;
}
.badge-buy  { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.badge-sell { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(239,68,68,0.3); }

.trade-instrument { font-size: 17px; font-weight: 800; color: var(--text); }
.trade-date { font-size: 11px; color: var(--muted); margin-top: 2px; }

.trade-pnl-pos { font-size: 22px; font-weight: 800; color: var(--green); }
.trade-pnl-neg { font-size: 22px; font-weight: 800; color: var(--red); }
.trade-pnl-neu { font-size: 22px; font-weight: 800; color: var(--muted); }

.trade-screenshot {
    width: 100%; display: block;
    max-height: 200px; object-fit: cover;
    border-top: 1px solid var(--border);
}

.trade-prices {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}
.price-cell {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 8px 10px;
}
.price-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.price-value { font-size: 13px; font-weight: 700; }

.trade-footer { padding: 0 14px 10px; }

.trade-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border-top: 1px solid var(--border);
}
.t-act {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px 4px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s;
    color: inherit;
    text-decoration: none;
    width: 100%;
}
.t-act:not(:last-child) { border-right: 1px solid var(--border); }
.t-act:hover { background: rgba(255,255,255,0.04); }
.t-view { color: var(--accent2); }
.t-edit { color: var(--yellow); }
.t-del  { color: var(--red); }

/* ── Setups ── */
.setup-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
    margin-bottom: 14px;
    transition: transform 0.15s;
}
.setup-card:active { transform: scale(0.99); }
.setup-shot {
    width: 100%;
    display: block;
    object-fit: cover;
    max-height: 220px;
    cursor: zoom-in;
}
.setup-no-img {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg2);
    color: var(--muted2);
    font-size: 13px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}
.setup-body { padding: 14px; }
.setup-name { font-size: 16px; font-weight: 800; color: var(--text); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.setup-meta { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.setup-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.setup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border-top: 1px solid var(--border);
}

/* ── Assistant Chat ── */
.chat-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h) - var(--nav-h) - 32px);
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.msg-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent), #6d5de0);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
}
.msg-bot {
    align-self: flex-start;
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 16px 16px 16px 4px;
    white-space: pre-wrap;
}
.msg-error {
    align-self: flex-start;
    background: var(--red-dim);
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--r-md);
    font-size: 12px;
}
.msg-time { font-size: 11px; color: var(--muted2); margin-top: 3px; text-align: right; }
.msg-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface2);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.msg-row { display: flex; gap: 8px; align-items: flex-end; }
.msg-row.user { flex-direction: row-reverse; }

.chat-input-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-top: 10px;
}
.chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    resize: none;
    max-height: 100px;
    line-height: 1.5;
    padding: 0;
}
.chat-input::placeholder { color: var(--muted2); }
.chat-send-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
.chat-send-btn:active { transform: scale(0.93); }
.chat-send-btn:disabled { opacity: 0.5; }

/* ── Vote / Poll ── */
.vote-wrap { }
.vote-info-box {
    background: linear-gradient(135deg, rgba(124,108,240,0.1), rgba(167,139,250,0.08));
    border: 1px solid rgba(124,108,240,0.2);
    border-radius: var(--r-xl);
    padding: 16px;
    margin-bottom: 16px;
}
.vote-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--yellow);
    font-weight: 700;
    margin-bottom: 14px;
}
.vote-instrument-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px;
    margin-bottom: 12px;
}
.vote-community {
    background: var(--surface2);
    border-radius: var(--r-md);
    padding: 12px;
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    text-align: center;
}
.community-val { font-size: 14px; font-weight: 700; color: var(--text); }
.community-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; text-transform: uppercase; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    background: var(--surface);
    border: 1px dashed var(--border2);
    border-radius: var(--r-xl);
}
.empty-icon { font-size: 3em; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

/* ── Utilities ── */
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent2); }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── Loading spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* ── Pulse animation ── */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }
.pulse { animation: pulse 2s ease-in-out infinite; }

/* ── Slide in ── */
@keyframes slideUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
.slide-up { animation: slideUp 0.25s ease both; }

/* ── Filter panel ── */
.filter-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px;
    margin-bottom: 14px;
    animation: slideUp 0.2s ease;
}
