/* ── WalletDashboard - Dark Mode Premium CSS ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary:   #0a0a14;
  --bg-secondary: #0f0f1e;
  --bg-card:      rgba(255,255,255,0.04);
  --bg-card-hover:rgba(255,255,255,0.07);
  --border:       rgba(255,255,255,0.08);
  --border-glow:  rgba(124,58,237,0.4);

  --accent:       #7c3aed;
  --accent-light: #a855f7;
  --accent-dim:   rgba(124,58,237,0.15);

  --green:        #10b981;
  --green-dim:    rgba(16,185,129,0.15);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.15);
  --yellow:       #f59e0b;
  --yellow-dim:   rgba(245,158,11,0.15);
  --blue:         #3b82f6;
  --blue-dim:     rgba(59,130,246,0.15);

  --text-primary:   #f0f0ff;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  --radius:    12px;
  --radius-lg: 20px;
  --shadow:    0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(124,58,237,0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Background grid ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(124,58,237,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, rgba(124,58,237,0.12) 0%, rgba(59,130,246,0.06) 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}

.header-left { display: flex; align-items: center; gap: 1rem; }

.logo {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 0 20px rgba(124,58,237,0.4);
  flex-shrink: 0;
}

.header h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; }
.header .subtitle { font-size: 0.78rem; color: var(--text-secondary); }

.header-badges { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  border: 1px solid;
}
.badge-live   { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.badge-sim    { background: var(--yellow-dim); border-color: var(--yellow); color: var(--yellow); }
.badge-info   { background: var(--blue-dim); border-color: var(--blue); color: var(--blue); }
.badge-error  { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.badge-purple { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-light); }

.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

#last-update { font-size: 0.72rem; color: var(--text-muted); }

/* ── Layout ── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  position: relative; z-index: 1;
}

.section-title {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.section-title::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  position: relative; overflow: hidden;
}
.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.14);
  transform: translateY(-2px);
}
.card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.card:hover::before { opacity: 0.6; }

/* ── Balance grid ── */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.balance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative; overflow: hidden;
  transition: all 0.2s;
}
.balance-card:hover { background: var(--bg-card-hover); transform: translateY(-2px); }

.balance-card .icon {
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
  display: block;
}
.balance-card .label {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.balance-card .value {
  font-size: 1.8rem; font-weight: 800;
  letter-spacing: -1px; line-height: 1;
}
.balance-card .sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }

.value-positive { color: var(--green); }
.value-negative { color: var(--red); }
.value-neutral  { color: var(--text-primary); }
.value-accent   { color: var(--accent-light); }

@keyframes flash-green {
  0% { background: rgba(16,185,129,0.25); }
  100% { background: transparent; }
}
@keyframes flash-red {
  0% { background: rgba(239,68,68,0.25); }
  100% { background: transparent; }
}
.flash-green { animation: flash-green 0.8s ease-out; }
.flash-red   { animation: flash-red 0.8s ease-out; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card .stat-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); margin-bottom: 0.5rem;
}
.stat-card .stat-value {
  font-size: 1.6rem; font-weight: 800; letter-spacing: -1px;
}
.stat-card .stat-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Grid ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* ── Tabla de posiciones ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.82rem;
}
th {
  padding: 0.6rem 0.8rem;
  text-align: left; font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.03); }

.tag-long  { color: var(--green); font-weight: 700; font-size: 0.7rem; }
.tag-short { color: var(--red);   font-weight: 700; font-size: 0.7rem; }

/* ── Feed ── */
.feed {
  display: flex; flex-direction: column; gap: 0.5rem;
  max-height: 360px; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.feed-item {
  display: flex; gap: 0.75rem; align-items: flex-start;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  transition: background 0.15s;
  font-size: 0.8rem;
}
.feed-item:hover { background: rgba(255,255,255,0.05); }
.feed-ts { 
  color: var(--text-muted); font-size: 0.7rem;
  min-width: 135px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.feed-msg { color: var(--text-primary); }

/* Gemini feed */
.gemini-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  transition: background 0.15s;
}
.gemini-item:hover { background: rgba(255,255,255,0.04); }
.gemini-header {
  display: flex; align-items: center; gap: 0.6rem;
  margin-bottom: 0.35rem; flex-wrap: wrap;
}
.gemini-symbol { font-weight: 700; font-size: 0.8rem; }
.sentiment-badge {
  padding: 0.15rem 0.55rem;
  border-radius: 999px; font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.5px;
}
.sent-alcista { background: var(--green-dim); color: var(--green); }
.sent-bajista { background: var(--red-dim);   color: var(--red); }
.sent-neutral { background: var(--yellow-dim);color: var(--yellow); }
.sent-peligro { background: var(--red-dim);   color: var(--red); border: 1px solid var(--red); }
.agresividad-bar {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.68rem; color: var(--text-muted);
}
.agg-track {
  flex: 1; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.1);
  max-width: 80px;
}
.agg-fill { height: 100%; border-radius: 2px; background: var(--accent); }
.gemini-razon { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.25rem; line-height: 1.4; }
.gemini-ts { font-size: 0.66rem; color: var(--text-muted); margin-top: 0.3rem; }
.gemini-feed-wrap {
  max-height: 400px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

/* ── Retiros (placeholder) ── */
.withdrawal-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  position: relative; overflow: hidden;
}
.withdrawal-section::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent, transparent 20px,
    rgba(255,255,255,0.01) 20px, rgba(255,255,255,0.01) 40px
  );
  pointer-events: none;
}
.withdrawal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.coming-soon {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--yellow);
  padding: 0.25rem 0.75rem;
  border-radius: 999px; font-size: 0.7rem; font-weight: 600;
  letter-spacing: 1px;
}
.withdrawal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.withdrawal-card {
  background: rgba(255,255,255,0.02);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.withdrawal-card .w-icon { font-size: 2rem; }
.withdrawal-card .w-title { font-weight: 700; font-size: 0.9rem; }
.withdrawal-card .w-desc { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.4; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius); font-size: 0.82rem; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.2s;
  text-decoration: none;
}
.btn-disabled {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  cursor: not-allowed;
  border: 1px solid var(--border);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: white;
  box-shadow: 0 4px 15px rgba(124,58,237,0.3);
}
.btn-primary:hover {
  box-shadow: 0 4px 25px rgba(124,58,237,0.5);
  transform: translateY(-1px);
}

/* ── Per-symbol table ── */
.symbol-list {
  display: flex; flex-direction: column; gap: 0.5rem;
  max-height: 250px; overflow-y: auto;
}
.symbol-row {
  display: flex; align-items: center; gap: 0.75rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
}
.symbol-name { font-weight: 700; font-size: 0.8rem; min-width: 80px; }
.wr-bar-wrap {
  flex: 1; height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px; overflow: hidden;
}
.wr-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--green), var(--accent-light));
}
.wr-label { font-size: 0.72rem; color: var(--text-muted); min-width: 40px; text-align: right; }
.pnl-label { font-size: 0.75rem; font-weight: 600; min-width: 80px; text-align: right; }

/* ── Errores ── */
.error-feed { max-height: 220px; overflow-y: auto; }
.error-item {
  background: rgba(239,68,68,0.05);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.4rem;
  font-size: 0.76rem; line-height: 1.4;
}
.error-ts { color: var(--text-muted); font-size: 0.68rem; }
.error-msg { color: var(--red); margin-top: 0.2rem; word-break: break-word; }

/* ── Skeleton loaders ── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  height: 1em; display: inline-block;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── No data ── */
.no-data {
  text-align: center; padding: 2rem;
  color: var(--text-muted); font-size: 0.82rem;
}
.no-data .icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
  .header { padding: 1rem; }
  .container { padding: 1rem; }
}
@media (max-width: 600px) {
  .balance-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid   { grid-template-columns: 1fr 1fr; }
  .header h1    { font-size: 1rem; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
