/* ==========================================================================
   ui/shell.css — top bar, side menu, phone bottom bar, login box.
   Used by every page, including the old ones (options page, classic app),
   so every class here starts with tb- / dr- / bn- / ui- to avoid clashes.
   Colours come from /theme.css.
   ========================================================================== */

/* ---------------------------------------------------------------- top bar */
#topbar { display: flex; align-items: center; gap: 10px; padding: 2px 0 14px; position: relative; z-index: 5; flex-wrap: nowrap; justify-content: flex-start; }
#topbar a { text-decoration: none; }
.tb-menu { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--panel); color: var(--text);
           display: grid; place-items: center; box-shadow: var(--shadow); cursor: pointer; flex: none; }
.tb-brand { color: var(--text); display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px;
            letter-spacing: -.03em; flex: none; font-family: var(--disp); }
html body a.tb-brand { color: var(--text); }
.tb-brand em { font-style: normal; color: var(--accent); }
.tb-logo { width: 32px; height: 32px; border-radius: 10px; background: #151515; position: relative; flex: none; }
.tb-logo i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #F25A1D; left: 8px; top: 15px; }
.tb-logo b { position: absolute; width: 6px; height: 16px; border-radius: 2px; background: #fff; left: 17px; top: 8px; }

.tb-nav { display: flex; gap: 4px; margin: 0 auto; background: var(--panel); border-radius: 999px; padding: 4px;
          box-shadow: var(--shadow); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tb-nav::-webkit-scrollbar { display: none; }
.tb-pill { display: flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 12px 6px 8px;
           font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; font-family: var(--disp); }
html body a.tb-pill { color: var(--muted); }
.tb-pill:hover { color: var(--text); background: var(--panel2); }
html body a.tb-pill.on { background: var(--ink); color: #fff; }
.tb-pill svg { flex: none; }

.tb-right { display: flex; align-items: center; gap: 8px; flex: none; }
.tb-mkt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--panel);
          padding: 7px 11px; border-radius: 999px; box-shadow: var(--shadow); white-space: nowrap; font-family: var(--disp); }
.tb-mkt i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.tb-mkt i.on { background: var(--buy); box-shadow: 0 0 0 3px var(--buy-dim); }
.tb-round, .tb-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--panel); border: 0; cursor: pointer;
                        display: grid; place-items: center; color: var(--text); box-shadow: var(--shadow); font-family: var(--disp); }
.tb-avatar { background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; }

/* ---------------------------------------------------------------- scan progress */
.tb-scan { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--panel);
           padding: 7px 11px; border-radius: 999px; box-shadow: var(--shadow); white-space: nowrap; border: 0;
           font-family: var(--disp); cursor: pointer; }
.tb-scan[hidden] { display: none; }
.tb-scan:hover:not(:disabled) { color: var(--text); }
.tb-scan:disabled { cursor: progress; }
.tb-scan i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.tb-scan.run { color: var(--text); }
.tb-scan.run i { background: var(--saffron, #f59e0b); animation: ssPulse 1s ease-in-out infinite; }
@keyframes ssPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, .55); } 50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); } }

.scan-strip { position: relative; height: 0; overflow: hidden; margin: 0 0 0; border-radius: 10px;
              background: var(--panel); box-shadow: var(--shadow); transition: height .2s ease, margin .2s ease; }
.scan-strip.on { height: 30px; margin: -6px 0 12px; }
.scan-strip .ss-fill { position: absolute; inset: 0 auto 0 0; width: 0; transition: width .5s ease;
                       background: linear-gradient(90deg, rgba(245, 158, 11, .22), rgba(245, 158, 11, .38));
                       background-size: 40px 100%; }
.scan-strip.on:not(.done) .ss-fill {
  background-image: linear-gradient(90deg, rgba(245, 158, 11, .20), rgba(245, 158, 11, .36)),
                    repeating-linear-gradient(-45deg, transparent 0 8px, rgba(255, 255, 255, .10) 8px 16px);
  animation: ssMove 1s linear infinite; }
@keyframes ssMove { from { background-position: 0 0, 0 0; } to { background-position: 0 0, 22px 0; } }
.scan-strip.done .ss-fill { background: var(--buy-dim, rgba(16, 185, 129, .25)); }
.scan-strip .ss-txt { position: relative; line-height: 30px; padding: 0 12px; font-family: var(--mono, monospace);
                      font-size: 11.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (prefers-reduced-motion: reduce) {
  .tb-scan.run i, .scan-strip.on:not(.done) .ss-fill { animation: none; }
}
@media (max-width: 820px) { .tb-scan span { display: none; } .tb-scan { padding: 7px; } .scan-strip .ss-txt { font-size: 10.5px; } }

/* labels shrink before anything wraps */
@media (max-width: 1180px) { .tb-pill:not(.on) span { display: none; } .tb-pill:not(.on) { padding: 6px 9px; } }
@media (max-width: 820px) {
  .tb-nav, .tb-mkt span, .tb-hide-sm { display: none; }
  .tb-right { margin-left: auto; }
  .tb-mkt { padding: 7px; }
}

/* ---------------------------------------------------------------- side menu */
.dr-shade { position: fixed; inset: 0; background: rgba(0, 0, 0, .38); opacity: 0; pointer-events: none;
            transition: opacity .2s; z-index: 60; }
.dr { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); background: var(--panel); z-index: 61;
      transform: translateX(-102%); transition: transform .22s ease; display: flex; flex-direction: column;
      padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
      box-shadow: 8px 0 30px rgba(0, 0, 0, .12); font-family: var(--disp); color: var(--text); }
body.dr-open .dr { transform: none; }
body.dr-open .dr-shade { opacity: 1; pointer-events: auto; }
.dr-head { display: flex; align-items: center; gap: 10px; padding: 2px 6px 12px; border-bottom: 1px solid var(--line); }
.dr-head .dr-x { margin-left: auto; }
.dr-user { font-size: 12px; color: var(--muted); padding: 10px 8px 4px; }
.dr-user b { color: var(--text); }
.dr-scroll { overflow-y: auto; flex: 1; padding-bottom: 8px; }
.dr-sec { font-size: 10.5px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; }
.dr a, .dr-row { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 12px; font-size: 13.5px;
                 font-weight: 600; color: var(--text); text-decoration: none; }
html body .dr a { color: var(--text); }
.dr a:hover { background: var(--panel2); }
html body .dr a.on { background: var(--accent-soft); color: var(--accent); }
.dr a small { margin-left: auto; font-weight: 500; color: var(--dim); font-size: 11px; }
.dr svg { flex: none; opacity: .85; }
.dr-row { justify-content: space-between; cursor: pointer; }
.dr-kill { margin-top: 6px; width: 100%; border: 1px solid var(--sell); color: var(--sell); background: transparent;
           border-radius: 12px; padding: 10px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: var(--disp); }
.dr-kill.on { background: var(--sell); color: #fff; }
.dr-note { font-size: 11px; color: var(--dim); padding: 6px 4px 0; line-height: 1.4; }

/* the on/off switch */
.ui-switch { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.ui-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
                    background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.ui-switch.on { background: var(--accent); }
.ui-switch.on::after { transform: translateX(16px); }

/* ---------------------------------------------------------------- phone bottom bar */
.bn { display: none; }
@media (max-width: 820px) {
  .bn { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        background: var(--glass); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
        border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); font-family: var(--disp); }
  .bn a, .bn button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600;
                      color: var(--muted); background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: none; font-family: inherit; }
  html body .bn a { color: var(--muted); }
  html body .bn a.on { color: var(--accent); }
  .bn a.on .bn-i { background: var(--accent-soft); }
  .bn-i { width: 44px; height: 28px; border-radius: 999px; display: grid; place-items: center; transition: background .15s; }
  body.has-bn { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------- login */
.ui-login { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: flex; align-items: center;
            justify-content: center; z-index: 80; font-family: var(--disp); }
.ui-login-card { background: var(--panel); color: var(--text); border-radius: 22px; padding: 24px; width: min(360px, 92vw);
                 display: flex; flex-direction: column; gap: 12px; }
.ui-login-card h3 { font-size: 19px; }
.ui-login-card p { color: var(--muted); font-size: 12.5px; }
.ui-login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.ui-login-card input { padding: 11px 13px; font-size: 14px; background: var(--panel2); color: var(--text);
                       border: 1px solid var(--line); border-radius: 12px; }
.ui-login-err { color: var(--sell); font-size: 12.5px; min-height: 16px; }
.ui-login-card button { border: 0; border-radius: 999px; padding: 11px; font-weight: 700; background: var(--accent); color: #fff; cursor: pointer; }

/* small toast for actions (close position, kill switch) */
.ui-toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
            background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13px;
            font-weight: 600; z-index: 90; font-family: var(--disp); box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 92vw; }
@media (min-width: 821px) { .ui-toast { bottom: 28px; } }

/* dark mode: keep the black logo tile visible on the dark page */
html[data-theme="dark"] .tb-logo { box-shadow: 0 0 0 1px #3A3A41; }


/* ---- closed trades: result colour bar + side arrow + why (30-Oct) ---- */
tr.tr-win  > td:first-child { box-shadow: inset 3px 0 0 var(--buy); }
tr.tr-loss > td:first-child { box-shadow: inset 3px 0 0 var(--sell); }
tr.tr-flat > td:first-child { box-shadow: inset 3px 0 0 var(--mut, #888); }
.sd { display: inline-block; width: 1.1em; font-size: 10px; vertical-align: 1px; }
.sd-l { color: var(--buy); }
.sd-s { color: var(--sell); }
td.why { max-width: 340px; min-width: 160px; }
td.why .why-in, td.why .why-out { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.why .why-in { font-size: 12.5px; }
td.why .why-out { font-size: 11px; opacity: .6; margin-top: 1px; }
.tr-key { font-size: 11.5px; opacity: .75; display: flex; gap: 12px; flex-wrap: wrap; }
.tr-key i { display: inline-block; width: 3px; height: 11px; vertical-align: -1px; margin-right: 4px; }
.why-sm { display: none; }
@media (max-width: 640px) {
  td.why { display: none; }
  .why-sm { display: block; font-weight: 400; font-size: 11.5px; opacity: .7; margin-top: 2px;
            white-space: normal; max-width: 210px; line-height: 1.3; }
}
