/* TradeFer - Estilos globales */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2230;
  --card: #1a2133;
  --card2: #212d42;
  --border: #2a3a55;
  --text: #e6edf3;
  --text2: #8b949e;
  --text3: #6e7681;
  --blue: #1d6fe8;
  --blue2: #2979ff;
  --green: #26a641;
  --green2: #2ee85a;
  --red: #c0392b;
  --red2: #e74c3c;
  --yellow: #d4a017;
  --yellow2: #f1c40f;
  --purple: #8b5cf6;
  --teal: #0abde3;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  min-height: 100vh;
  overscroll-behavior: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.app-header {
  background: var(--bg2);
  padding: 14px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #1d6fe8, #8b5cf6);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #fff;
  letter-spacing: -1px;
}
.header-title { font-size: 22px; font-weight: 800; color: #fff; line-height: 1; }
.header-subtitle { font-size: 11px; color: var(--text2); margin-top: 2px; line-height: 1.3; }
.btn-exit {
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); padding: 7px 14px; border-radius: 8px;
  font-size: 13px; cursor: pointer; transition: all .2s;
}
.btn-exit:hover { color: var(--text); border-color: var(--blue); }

/* ===== MAIN SCROLL ===== */
.main-content { flex: 1; overflow-y: auto; padding: 0 0 100px; }

/* ===== SECTIONS ===== */
.section { padding: 16px 16px 0; }
.section-label {
  font-size: 11px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px;
}

/* ===== BADGE SEÑAL (pills como en las fotos) ===== */
.badge {
  padding: 6px 14px; border-radius: 20px; font-size: 12px;
  font-weight: 800; letter-spacing: .8px; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.badge.buy  { background: #1a7a3a; color: #2ee85a; border: 1.5px solid #2ee85a; }
.badge.sell { background: #7a1a2a; color: #ff6b6b; border: 1.5px solid #e74c3c; }
.badge.lateral { background: #7a6a00; color: #f1c40f; border: 1.5px solid #f1c40f; }

/* ===== MERCADOS ===== */
.market-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.market-scroll::-webkit-scrollbar { display: none; }
.market-btn {
  flex-shrink: 0; padding: 8px 18px;
  border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border); background: var(--card);
  color: var(--text2); cursor: pointer; transition: all .2s; white-space: nowrap;
}
.market-btn.active {
  background: var(--blue); border-color: var(--blue);
  color: #fff; box-shadow: 0 0 12px rgba(29,111,232,.4);
}

/* ===== ACTIVO INPUT ===== */
.asset-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin: 12px 16px 0; border: 1px solid var(--border);
}
.asset-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.asset-card-title { font-size: 16px; font-weight: 700; }
.asset-card-hint { font-size: 11px; color: var(--text3); }
.asset-input-wrap { position: relative; }
.asset-input {
  width: 100%; background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 16px; color: var(--text); outline: none; transition: border .2s;
}
.asset-input:focus { border-color: var(--blue); }
.asset-input::placeholder { color: var(--text3); }

/* Autocomplete */
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); z-index: 200; overflow: hidden;
  box-shadow: var(--shadow); display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
  padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--border);
  font-size: 14px; transition: background .15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg3); }
.autocomplete-item span { font-size: 11px; color: var(--text3); margin-left: 8px; }

/* Quick pairs */
.quick-pairs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.quick-pair {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 11px; font-size: 12px; font-weight: 600;
  color: var(--text2); cursor: pointer; transition: all .2s;
}
.quick-pair:hover { border-color: var(--blue); color: var(--text); }

/* Analyze btn */
.btn-analyze {
  width: 100%; margin-top: 12px; padding: 15px;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700; color: #fff;
  cursor: pointer; transition: all .2s; letter-spacing: .3px;
}
.btn-analyze:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(29,111,232,.5); }
.btn-analyze:active { transform: translateY(0); }
.btn-analyze:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ===== ACCIONES RÁPIDAS ===== */
.quick-actions { display: flex; gap: 10px; margin: 12px 16px 0; }
.quick-action-btn {
  flex: 1; padding: 12px 8px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s;
  border: 1.5px solid; text-align: center;
}
.qa-alert {
  background: rgba(212,160,23,.1); border-color: var(--yellow);
  color: var(--yellow2);
}
.qa-alert:hover { background: rgba(212,160,23,.2); }
.qa-copy {
  background: var(--card); border-color: var(--border);
  color: var(--text2);
}
.qa-copy:hover { border-color: var(--blue); color: var(--text); }

/* ===== SIGNAL BANNER ===== */
.signal-banner {
  margin: 14px 16px 0; border-radius: var(--radius);
  padding: 22px 18px 18px; text-align: center;
  position: relative; overflow: hidden;
}
.signal-banner.buy  { background: linear-gradient(160deg,#0a2e1a,#0f3d22); border: 2px solid #26a641; }
.signal-banner.sell { background: linear-gradient(160deg,#2e0a0a,#3d0f0f); border: 2px solid #c0392b; }
.signal-banner.lateral { background: linear-gradient(160deg,#1a1a0a,#2a2a10); border: 2px solid #d4a017; }

.signal-label { font-size: 11px; font-weight: 800; letter-spacing: 2px; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; }

/* Flecha grande animada */
.signal-arrow {
  font-size: 72px; line-height: 1; margin-bottom: 4px;
  animation: pulse-arrow 1.8s ease-in-out infinite;
  display: block;
}
.signal-banner.buy    .signal-arrow { color: #2ee85a; text-shadow: 0 0 30px rgba(46,232,90,.6); }
.signal-banner.sell   .signal-arrow { color: #ff6b6b; text-shadow: 0 0 30px rgba(255,107,107,.6); }
.signal-banner.lateral .signal-arrow { color: #f1c40f; text-shadow: 0 0 30px rgba(241,196,15,.5); }
@keyframes pulse-arrow {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.12); opacity: .85; }
}

.signal-name {
  font-size: 32px; font-weight: 900; letter-spacing: 2px; margin-bottom: 10px;
}
.signal-banner.buy    .signal-name { color: #2ee85a; }
.signal-banner.sell   .signal-name { color: #ff6b6b; }
.signal-banner.lateral .signal-name { color: #f1c40f; }

.signal-desc { font-size: 13px; color: var(--text2); line-height: 1.6; }

.signal-strength {
  display: inline-block; margin-top: 10px;
  font-size: 12px; font-weight: 700;
  padding: 4px 14px; border-radius: 12px;
}
.signal-banner.buy    .signal-strength { background: rgba(46,232,90,.15);  color: #2ee85a; border: 1px solid #2ee85a; }
.signal-banner.sell   .signal-strength { background: rgba(255,107,107,.15); color: #ff6b6b; border: 1px solid #ff6b6b; }
.signal-banner.lateral .signal-strength { background: rgba(241,196,15,.15); color: #f1c40f; border: 1px solid #f1c40f; }

/* Mini flecha inline para historial y timeframes */
.arrow-up   { color: #2ee85a; font-weight: 900; font-size: 15px; }
.arrow-down { color: #ff6b6b; font-weight: 900; font-size: 15px; }
.arrow-side { color: #f1c40f; font-weight: 900; font-size: 15px; }

/* ===== TIEMPO ESTIMADO (NUEVO) ===== */
.time-card {
  margin: 12px 16px 0; background: var(--card);
  border-radius: var(--radius); border: 1.5px solid var(--purple);
  padding: 16px; position: relative; overflow: hidden;
}
.time-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--purple), var(--teal));
}
.time-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.time-card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.time-card-icon { color: var(--purple); font-size: 18px; }
.time-notify-btn {
  background: rgba(139,92,246,.15); border: 1px solid var(--purple);
  color: var(--purple); padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; gap: 5px;
}
.time-notify-btn.active {
  background: var(--purple); color: #fff;
  box-shadow: 0 0 12px rgba(139,92,246,.4);
}
.time-notify-btn:hover { background: rgba(139,92,246,.3); }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.time-item {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 10px 12px; border: 1px solid var(--border);
}
.time-item-tf { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; margin-bottom: 4px; }
.time-item-val { font-size: 13px; font-weight: 600; color: var(--purple); }
.time-recommended {
  margin-top: 10px; padding: 12px;
  background: rgba(139,92,246,.1); border-radius: var(--radius-sm);
  border: 1px solid rgba(139,92,246,.3);
  font-size: 13px; line-height: 1.5;
}
.time-recommended strong { color: var(--purple); }
.time-countdown {
  margin-top: 8px; text-align: center;
  font-size: 13px; color: var(--text2);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.time-countdown .timer { color: var(--teal); font-weight: 700; font-size: 15px; }

/* ===== RESUMEN TABLA ===== */
.summary-card {
  margin: 12px 16px 0; background: var(--card);
  border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden;
}
.summary-header { padding: 13px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.summary-header h3 { font-size: 15px; font-weight: 700; }
.summary-header span { font-size: 11px; color: var(--text3); }
.summary-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 16px; border-bottom: 1px solid rgba(42,58,85,.5);
}
.summary-row:last-child { border-bottom: none; }
.summary-row-label { font-size: 13px; color: var(--text2); }
.summary-row-val { font-size: 13px; font-weight: 700; color: var(--text); }

/* ===== TABS INDICADORES ===== */
.indicator-section { margin: 12px 16px 0; }
.indicator-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin-bottom: 12px; }
.indicator-tabs::-webkit-scrollbar { display: none; }
.ind-tab {
  flex-shrink: 0; padding: 8px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 600; border: 1.5px solid var(--border);
  background: var(--card); color: var(--text2); cursor: pointer; transition: all .2s;
  white-space: nowrap;
}
.ind-tab.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.ind-panel { display: none; }
.ind-panel.active { display: block; }

/* ===== INDICADOR CARD ===== */
.ind-card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 16px; margin-bottom: 10px;
}
.ind-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.ind-card-name { font-size: 14px; font-weight: 700; }
.ind-card-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }
.badge {
  padding: 5px 12px; border-radius: 20px; font-size: 12px;
  font-weight: 700; letter-spacing: .5px; flex-shrink: 0;
}
.badge.buy { background: var(--green); color: #fff; }
.badge.sell { background: var(--red); color: #fff; }
.badge.lateral { background: var(--yellow); color: #000; }
.ind-values { display: flex; flex-direction: column; gap: 6px; }
.ind-val-row { display: flex; justify-content: space-between; font-size: 13px; }
.ind-val-label { color: var(--text3); }
.ind-val-num { font-weight: 600; color: var(--text); }

/* Bar visual */
.bar-wrap { margin-top: 8px; }
.bar-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; display: flex; justify-content: space-between; }
.bar-track { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }
.bar-fill.buy { background: linear-gradient(90deg, var(--green), var(--green2)); }
.bar-fill.sell { background: linear-gradient(90deg, var(--red), var(--red2)); }
.bar-fill.neutral { background: linear-gradient(90deg, var(--blue), var(--blue2)); }

/* ===== MAPA DE TIEMPO ===== */
.tf-section { margin: 12px 16px 0; }
.tf-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.tf-card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 10px;
}
.tf-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tf-name { font-size: 15px; font-weight: 700; }
.tf-strength { font-size: 12px; color: var(--text3); }
/* Flecha dentro de cada tf-card */
.tf-arrow {
  font-size: 22px; font-weight: 900; margin-right: 6px; vertical-align: middle;
}
.tf-indicators { font-size: 12px; color: var(--text2); line-height: 1.6; }
.tf-dot { color: var(--text3); margin: 0 3px; }
/* Tiempo en tf-card */
.tf-duration {
  margin-top: 8px; padding: 7px 10px;
  background: rgba(139,92,246,.08); border-radius: 6px;
  border-left: 3px solid var(--purple);
  font-size: 12px; color: var(--purple); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}

/* ===== MACRO USA ===== */
.macro-section { margin: 12px 16px 0; }
.macro-card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 8px;
}
.macro-label { font-size: 12px; color: var(--text3); font-weight: 600; margin-bottom: 3px; }
.macro-value { font-size: 20px; font-weight: 800; color: var(--text); }
.macro-date { font-size: 11px; color: var(--text3); margin-top: 2px; }
.macro-change { font-size: 11px; font-weight: 600; margin-top: 3px; }
.macro-change.up { color: var(--green2); }
.macro-change.down { color: var(--red2); }
.macro-usda {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 8px;
}
.macro-usda .macro-label-big { font-size: 13px; font-weight: 700; }
.macro-usda p { font-size: 12px; color: var(--text2); margin-top: 4px; line-height: 1.5; }

/* ===== HISTORIAL ===== */
.history-section { margin: 12px 16px 0; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.history-item {
  background: var(--card); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.history-left { }
.history-symbol { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.history-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ===== ALERTAS ===== */
.alerts-section { margin: 12px 16px 0; }
.alert-item {
  background: var(--card); border-radius: var(--radius-sm);
  border: 1px solid var(--border); padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.alert-info .alert-symbol { font-size: 14px; font-weight: 700; }
.alert-info .alert-cond { font-size: 12px; color: var(--text3); margin-top: 2px; }
.btn-remove {
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); padding: 6px 14px; border-radius: 7px;
  font-size: 13px; cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn-remove:hover { border-color: var(--red); color: var(--red2); }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; min-width: 260px; max-width: 360px; }
.toast {
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px;
  font-size: 14px; color: var(--text);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
  animation: slideIn .3s ease; pointer-events: all;
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--blue); }
.toast.time { border-color: var(--purple); }
.toast i { font-size: 16px; flex-shrink: 0; }
.toast.success i { color: var(--green2); }
.toast.error i { color: var(--red2); }
.toast.info i { color: var(--blue2); }
.toast.time i { color: var(--purple); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== LOADING ===== */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 24px; color: var(--text2); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SECTION TITLE ===== */
.sec-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.sec-subtitle { font-size: 11px; color: var(--text3); }

/* ===== RESPONSIVE DESKTOP ===== */
@media (min-width: 600px) {
  #app { max-width: 540px; }
  .time-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  #app { max-width: 480px; }
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 32px 20px; color: var(--text3); }
.empty-state i { font-size: 36px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; line-height: 1.5; }
