/* ===== BUTTONS ===== */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  transition: transform var(--ease-micro), filter var(--ease-micro);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:active {
  transform: scale(0.97);
  filter: brightness(0.9);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-brighter), var(--accent));
  box-shadow: 0 2px 8px rgba(68, 138, 255, 0.30), inset 0 1px 0 rgba(255,255,255,0.12);
  color: #fff;
  height: 52px;
  border-radius: var(--radius-button);
  width: 100%;
}

.btn-secondary {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  height: 52px;
  border-radius: var(--radius-button);
  width: 100%;
  border: 1px solid #FFFFFF12;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 400;
  height: 44px;
  border-radius: var(--radius-button);
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-icon svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

/* ===== CHIPS ===== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-raised);
  border: 1px solid #FFFFFF12;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--ease-micro), color var(--ease-micro);
  touch-action: manipulation;
}

.chip:active {
  transform: scale(0.96);
}

.chip.active, .chip.selected {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.error {
  border-color: var(--bearish);
  color: var(--bearish);
  box-shadow: 0 0 8px var(--bearish-dim);
}

.chip-icon {
  width: 14px;
  height: 14px;
}

.chip-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ===== BADGES ===== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-bullish {
  background: #00E67620;
  color: var(--bullish);
  border: 1px solid #00E67640;
}

.badge-bearish {
  background: #FF525220;
  color: var(--bearish);
  border: 1px solid #FF525240;
}

.badge-neutral {
  background: #8A8A9A20;
  color: var(--neutral);
  border: 1px solid #8A8A9A40;
}

.badge-risk {
  background: #FFB74D20;
  color: var(--caution);
  border: 1px solid #FFB74D40;
}

.badge-risk::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFB74D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ===== SIGNAL STRENGTH ===== */

.signal-strength {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.signal-bar {
  width: 4px;
  border-radius: 1px;
  transition: background var(--ease-state);
}

.signal-bar:nth-child(1) { height: 8px; }
.signal-bar:nth-child(2) { height: 12px; }
.signal-bar:nth-child(3) { height: 16px; }

.signal-strength.strong .signal-bar { background: var(--bullish); }
.signal-strength.moderate .signal-bar:nth-child(1),
.signal-strength.moderate .signal-bar:nth-child(2) { background: var(--bullish); }
.signal-strength.moderate .signal-bar:nth-child(3) { background: var(--text-muted); }
.signal-strength.weak .signal-bar:nth-child(1) { background: var(--caution); }
.signal-strength.weak .signal-bar:nth-child(2),
.signal-strength.weak .signal-bar:nth-child(3) { background: var(--text-muted); }

.signal-label {
  font-size: 9px;
  color: rgba(255,255,255,0.30);
  margin-left: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ===== CARDS ===== */

.card {
  background: var(--bg-surface);
  border-radius: var(--radius-card);
  border: 1px solid #FFFFFF08;
  padding: var(--space-base);
}

.card-raised {
  background: var(--bg-surface-raised);
}

/* ===== EXPANDABLE SECTION ===== */

.expandable {
  border-top: 1px solid #FFFFFF08;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
}

.expandable-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: var(--space-sm) 0;
  -webkit-user-select: none;
  user-select: none;
}

.expandable-header .type-h3 {
  flex: 1;
}

.expandable-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--ease-state);
  flex-shrink: 0;
}

.expandable.open .expandable-chevron {
  transform: rotate(180deg);
}

.expandable-content {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  opacity: 0;
  transition: grid-template-rows var(--ease-state), opacity 150ms ease-out 50ms;
}

.expandable-content > * {
  overflow: hidden;
}

.expandable.open .expandable-content {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* ===== TOGGLE GROUP ===== */

.toggle-group {
  display: flex;
  background: var(--bg-surface-raised);
  border-radius: var(--radius-button);
  height: 40px;
  padding: 3px;
  gap: 2px;
}

.toggle-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--ease-state), color var(--ease-state), box-shadow var(--ease-state);
  white-space: nowrap;
  padding: 0 8px;
  touch-action: manipulation;
}

.toggle-option.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 4px #00000040;
}

/* ===== TEXT INPUT ===== */

.text-input {
  height: 48px;
  width: 100%;
  background: var(--bg-surface-raised);
  border: 1px solid #FFFFFF12;
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  padding: 0 16px;
  transition: border-color var(--ease-micro);
}

.text-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.text-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.text-input:focus {
  border-color: var(--accent);
}

/* ===== SEARCH INPUT ===== */

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input-wrapper .text-input {
  padding-left: 42px;
  padding-right: 42px;
}

.search-input-wrapper .clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-surface);
  color: var(--text-muted);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.search-input-wrapper .text-input:not(:placeholder-shown) + .clear-btn,
.search-input-wrapper .clear-btn.visible {
  display: flex;
}

/* ===== NAV BAR ===== */

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--screen-padding);
  height: 48px;
  position: relative;
  flex-shrink: 0;
}

.nav-bar .nav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.nav-bar .nav-left,
.nav-bar .nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  z-index: 1;
}

/* ===== ACTION BAR ===== */

.action-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-surface);
  border-top: 1px solid #FFFFFF08;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--space-base);
  flex-shrink: 0;
  z-index: 50;
}

.action-bar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 16px;
  transition: color var(--ease-micro);
  touch-action: manipulation;
}

.action-bar-btn:active {
  color: var(--accent);
}

.action-bar-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.action-bar-btn svg {
  width: 22px;
  height: 22px;
}

.action-bar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
}

/* ===== MODAL ===== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
  z-index: 100;
  display: none;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.modal-overlay.visible {
  display: block;
  opacity: 1;
}

.modal-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  max-height: 70%;
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.modal-overlay.visible .modal-sheet {
  transform: translateY(0);
}

.modal-grabber {
  width: 36px;
  height: 4px;
  background: var(--text-muted);
  border-radius: var(--radius-pill);
  margin: var(--space-sm) auto var(--space-base);
}


/* ===== SECTION LABEL ===== */

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

/* ===== PRICE ROW ===== */

.price-row {
  display: flex;
  gap: var(--space-base);
  margin: var(--space-base) 0;
}

.price-col {
  flex: 1;
  text-align: center;
}

.price-col .price-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.price-col .price-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
}

/* ===== TOAST ===== */

.toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-button);
  border: 1px solid #FFFFFF12;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
