/* imt.css — shared variables + header dropdown + page primitives */
/* Light-mode defaults. Dark overrides in night-mode.css (IMT section). */

:root {
  --imt-primary:       #04abf2;
  --imt-primary-hover: #43c6f9;
  --imt-success:       #16a34a;
  --imt-error:         #c23321;
  --imt-bg-card:       #fff;
  --imt-bg-soft:       #f5f7fa;
  --imt-fg:            #202020;
  --imt-fg-muted:      #666;
  --imt-fg-dim:        #9ca3af;
  --imt-border:        #e6e6e6;
  --imt-muted:         #9ca3af;
}

#imt-toast-host { position: fixed; right: 24px; bottom: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.imt-toast { padding: 12px 16px; border-radius: 8px; color: #fff; opacity: 0; transform: translateY(10px); transition: all .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 360px; }
.imt-toast--show    { opacity: 1; transform: translateY(0); }
.imt-toast--success { background: var(--imt-success); }
.imt-toast--error   { background: var(--imt-error); }
.imt-toast--info    { background: var(--imt-primary); }
.imt-tx-modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 9998; }
.imt-tx-modal__inner { background: var(--imt-bg-card); color: var(--imt-fg); padding: 24px; border-radius: 12px; min-width: 320px; max-width: 480px; border: 1px solid var(--imt-border); }
.imt-tx-modal__status { font-size: 16px; margin-bottom: 12px; }
.imt-tx-modal__link { color: var(--imt-primary); display: inline-block; margin-bottom: 16px; }
.imt-tx-modal__close { background: var(--imt-primary); color: #fff; border: 0; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.imt-connect-btn { background: var(--imt-primary); color: #fff; border: 0; padding: 8px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; transition: filter .15s; }
.imt-connect-btn:hover { filter: brightness(1.1); }
.imt-connect-btn--connected { background: transparent; border: 1px solid var(--imt-primary); color: var(--imt-primary); }
.imt-balance { display: inline-flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.imt-balance__value { font-weight: 600; color: var(--imt-fg); }
.imt-balance__usd { color: var(--imt-fg-muted); font-size: .85em; }
.imt-page { max-width: 1100px; margin: 0 auto; padding: 24px 16px; display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .imt-page { grid-template-columns: 1fr 1fr; } }
.imt-card { background: var(--imt-bg-card); border: 1px solid var(--imt-border); border-radius: 16px; padding: 20px; }
.imt-card__title { margin: 0 0 12px; font-size: 18px; font-weight: 700; color: var(--imt-fg); }
.imt-card--span2 { grid-column: 1 / -1; }
.imt-trade-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.imt-trade-tabs__btn { flex: 1; padding: 10px; background: transparent; border: 1px solid var(--imt-border); color: var(--imt-fg); cursor: pointer; border-radius: 8px; }
.imt-trade-tabs__btn--active { background: var(--imt-primary); border-color: var(--imt-primary); color: #fff; }
.imt-input { width: 100%; padding: 12px; background: var(--imt-bg-card); border: 1px solid var(--imt-border); color: var(--imt-fg); border-radius: 8px; font-size: 16px; box-sizing: border-box; }
.imt-button { width: 100%; padding: 14px; background: var(--imt-primary); color: #fff; border: 0; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 16px; }
.imt-button:disabled { opacity: .6; cursor: not-allowed; }
.imt-button--sell { background: var(--imt-error); }
.imt-link { color: var(--imt-primary); text-decoration: none; }
.imt-table { width: 100%; border-collapse: collapse; }
.imt-table th, .imt-table td { padding: 8px; border-bottom: 1px solid var(--imt-border); text-align: left; font-size: 14px; color: var(--imt-fg); }
.imt-table th { color: var(--imt-fg-muted); }
.imt-qr { background: #fff; padding: 8px; border-radius: 8px; display: inline-block; }
.imt-trade-preview { color: var(--imt-fg-muted); margin: 8px 0 12px; }

/* ── Header IMT dropdown ──────────────────────────────────────────────── */
.header-imt-area { position: relative; cursor: pointer; user-select: none; }
.imt-header-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 9990;
  background: var(--imt-bg-card); border: 1px solid var(--imt-border);
  border-radius: 12px; padding: 14px; min-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.imt-hdd__row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0; font-size: 13px;
}
.imt-hdd__label { color: var(--imt-fg-muted); min-width: 72px; }
.imt-hdd__val { color: var(--imt-fg); flex: 1; font-weight: 600; }
.imt-hdd__monospace { font-family: ui-monospace, monospace; font-size: 12px; }
.imt-hdd__addr { border-bottom: 1px solid var(--imt-border); padding-bottom: 8px; margin-bottom: 4px; }
.imt-hdd__copy {
  background: none; border: 1px solid var(--imt-border); color: var(--imt-fg-muted);
  border-radius: 4px; padding: 1px 5px; cursor: pointer; font-size: 11px; line-height: 1.4;
}
.imt-hdd__copy:hover { border-color: var(--imt-primary); color: var(--imt-primary); }
.imt-hdd__actions {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 10px; border-top: 1px solid var(--imt-border); padding-top: 10px;
}
.imt-hdd__cta {
  display: block; text-align: center; padding: 7px 10px;
  border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; transition: opacity .15s;
}
.imt-hdd__cta:hover { opacity: .85; }
.imt-hdd__cta--link {
  background: transparent; border: 1px solid var(--imt-primary);
  color: var(--imt-primary);
}
.imt-hdd__cta--btn {
  background: var(--imt-primary); border: 0; color: #fff;
}
.imt-hdd__cta--buy {
  background: #16a34a; color: #fff;
}

/* /imt dashboard — "Connected:" label + monospace address pill */
.imt-connected-label {
  font-size: 12px;
  color: var(--imt-fg-dim);
}
.imt-address-pill {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--imt-fg);
  background: var(--imt-bg-soft);
  border: 1px solid var(--imt-border);
  border-radius: 6px;
  padding: 3px 8px;
}

/* ── Mobile polish ────────────────────────────────────────────────────
 * Mobile-friendly tap targets, no horizontal overflow, MetaMask-app deep
 * link affordance. Web3 mobile flows redirect into the wallet's in-app
 * browser, so the connect button needs an obvious mobile state. */
.imt-connect-btn {
  min-height: 40px;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.imt-connect-btn--mobile {
  background: #f6851b; /* MetaMask brand orange */
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.imt-connect-btn--mobile::before {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  background: #fff;
  -webkit-mask: radial-gradient(circle, currentColor 40%, transparent 41%) center/100% 100% no-repeat;
          mask: radial-gradient(circle, currentColor 40%, transparent 41%) center/100% 100% no-repeat;
  border-radius: 50%;
  flex: 0 0 auto;
}
.imt-connect-btn--mobile:hover { background: #e07717; filter: none; }

@media (max-width: 600px) {
  /* Stack any inline action rows so they don't overflow on narrow screens. */
  .imt-page { padding: 16px 10px; gap: 16px; }
  .imt-card { padding: 14px; border-radius: 12px; }
  .imt-card__title { font-size: 16px; }
  .imt-table th, .imt-table td { font-size: 13px; padding: 6px 4px; }
  .imt-input, .imt-button { font-size: 16px; min-height: 44px; } /* iOS won't auto-zoom on >=16px */
  .imt-trade-tabs__btn { padding: 12px 8px; min-height: 44px; }
  .imt-action { padding: 12px 14px; }
  /* Make the transactions IMT tile stack cleanly on phones. */
  .imt-tx-tile { flex-direction: column; align-items: stretch !important; padding: 16px !important; gap: 12px !important; }
  .imt-tx-tile > div:first-child { justify-content: flex-start; }
  .imt-tx-tile > div:last-child { justify-content: space-between; gap: 10px !important; }
  .imt-tx-tile #imt-tx-balance { text-align: left !important; }
  .imt-tx-tile .imt-tx-tile__btn,
  .imt-tx-tile .imt-connect-btn { flex: 1 1 auto; text-align: center; justify-content: center; }
}

@media (hover: none) and (pointer: coarse) {
  /* Disable hover transforms on touch devices — they cause sticky-hover bugs. */
  .imt-action:hover { transform: none; box-shadow: none; }
}
