/*
 * BitSwap — styles on top of Tailwind CDN
 *
 * Flat, dense, Binance-inspired. The color palette lives in js/theme.js
 * (Tailwind config override); this file handles fonts, typography
 * details, scrollbars, flash animations, and a couple of small utilities.
 */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --up:   #0ECB81;
  --down: #F6465D;
  --yellow: #FCD535;
}

html, body {
  background: #0B0E11;
  color: #EAECEF;
}

body {
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, sans-serif;
  font-feature-settings: "cv11" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

code, kbd, pre, samp,
.font-mono, [class*="font-mono"] {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono",
               Menlo, Consolas, monospace !important;
  font-feature-settings: "tnum" 1, "zero" 1;
  font-variant-numeric: tabular-nums;
}

table, td, th, .tab-num {
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.003em;
}

/* Scrollbars — minimal, slightly visible */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(132, 142, 156, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(132, 142, 156, 0.4);
}

/* Inputs */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23848E9C' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 7.5L10 12l4.5-4.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 30px !important;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 1px;
  border-radius: 2px;
}

/* Price flash — subtle, no fancy easing */
@keyframes flash-up {
  0%, 35% {
    background-color: rgba(14, 203, 129, 0.18);
    color: #0ECB81;
  }
  100% { background-color: transparent; }
}
@keyframes flash-down {
  0%, 35% {
    background-color: rgba(246, 70, 93, 0.18);
    color: #F6465D;
  }
  100% { background-color: transparent; }
}
.flash-up {
  animation: flash-up 750ms ease-out;
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}
.flash-down {
  animation: flash-down 750ms ease-out;
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}

/* Live indicator */
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--up);
  animation: live-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

/* Semantic text + pill utilities — Binance-style colour conventions */
.up    { color: var(--up); }
.down  { color: var(--down); }
.pill-up {
  background: rgba(14, 203, 129, 0.1);
  color: var(--up);
}
.pill-down {
  background: rgba(246, 70, 93, 0.1);
  color: var(--down);
}

/* Tight table row hover */
tbody tr { transition: background-color 120ms ease; }
tbody tr:hover { background-color: rgba(43, 49, 57, 0.35); }

/* Button press feedback */
button { transition: background-color 120ms ease, color 120ms ease,
                     border-color 120ms ease, opacity 120ms ease; }

/* ------- Mobile / iOS PWA adjustments ------- */

/* Respect the iPhone notch when running as a standalone web app */
body {
  padding-top: env(safe-area-inset-top, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Sticky headers need to sit above the notch */
.app-header {
  top: calc(env(safe-area-inset-top, 0) * -1);
}

/* Prevent iOS from auto-zooming into focused inputs */
@media (max-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Tighten the main grid on phones so there's less empty space */
@media (max-width: 640px) {
  main.max-w-7xl,
  main.max-w-5xl,
  main.max-w-4xl {
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-top: 16px !important;
  }
  /* The KYC / Deposit / Withdraw modal outer wrapper gets less overflow padding */
  .fixed.inset-0.p-4 { padding: 12px !important; }
}

/* Chat widget lives in the bottom-right corner — keep it clear of the
   home indicator on iPhones when added as a web app */
@media (max-width: 640px) {
  #chat-widget-toggle {
    bottom: calc(env(safe-area-inset-bottom, 0) + 1rem) !important;
    right: 1rem !important;
  }
  #chat-widget-panel {
    bottom: calc(env(safe-area-inset-bottom, 0) + 5.5rem) !important;
    right: 1rem !important;
    left: 1rem !important;
    width: auto !important;
    max-width: none !important;
  }
}

/* Notifications dropdown: on phones let it span most of the width instead
   of popping out as a narrow column at the right edge */
@media (max-width: 640px) {
  #notif-dropdown {
    position: fixed !important;
    top: calc(env(safe-area-inset-top, 0) + 3.5rem) !important;
    right: 0.75rem !important;
    left: 0.75rem !important;
    width: auto !important;
    max-width: none !important;
  }
}

/* Tables stay scrollable sideways on phones */
@media (max-width: 640px) {
  table { font-size: 12px; }
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .flash-up, .flash-down {
    animation: none !important;
  }
}

/* ── Z-index scale ────────────────────────────────── */
/* 10: header/nav  20: sidebar  30: dropdown/popover  40: modal/overlay  50: toast/lang */
