/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --card-bg: #161b22;
  --card-border: #21262d;
  --sidebar-bg: #010409;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent-green: #00c853;
  --accent-red: #ff1744;
  --accent-blue: #2979ff;
  --accent-yellow: #ffd600;
  --sidebar-width: 220px;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.6;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-green);
  border-bottom: 1px solid var(--card-border);
  letter-spacing: -0.02em;
}

.sidebar nav {
  padding: 1rem 0;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.nav-link:hover {
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent-green);
  border-left-color: var(--accent-green);
  background: rgba(0, 200, 83, 0.07);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.75rem 2rem;
  min-width: 0;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 1.75rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ===== STAT CARDS (KPI row) ===== */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.stat-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-card .value.green { color: var(--accent-green); }
.stat-card .value.blue  { color: var(--accent-blue); }

/* ===== SECTION TITLES ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.section-header a {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.section-header a:hover { color: var(--accent-blue); }

/* ===== MARKET CARDS ===== */
.markets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.market-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s;
  text-decoration: none;
  color: inherit;
}

.market-card:hover {
  border-color: var(--accent-blue);
  text-decoration: none;
}

.market-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.market-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}

.market-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* ===== PROBABILITY BAR ===== */
.probability-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.probability-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
}

.prob-yes { color: var(--accent-green); font-weight: 600; }
.prob-no  { color: var(--accent-red);   font-weight: 600; }

.probability-bar {
  height: 6px;
  background: var(--accent-red);
  border-radius: 3px;
  overflow: hidden;
}

.probability-bar-fill {
  height: 100%;
  background: var(--accent-green);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Large version for market detail */
.probability-bar.large {
  height: 14px;
  border-radius: 6px;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-green  { background: rgba(0,200,83,0.15);   color: var(--accent-green); }
.badge-red    { background: rgba(255,23,68,0.15);  color: var(--accent-red); }
.badge-blue   { background: rgba(41,121,255,0.15); color: var(--accent-blue); }
.badge-gray   { background: rgba(139,148,158,0.15); color: var(--text-muted); }
.badge-yellow { background: rgba(255,214,0,0.15);  color: var(--accent-yellow); }

/* Category badges */
.cat-Índices      { background: rgba(41,121,255,0.15); color: #6ea6ff; }
.cat-Acciones     { background: rgba(0,200,83,0.15);   color: var(--accent-green); }
.cat-Commodities  { background: rgba(255,214,0,0.15);  color: var(--accent-yellow); }
.cat-Crypto       { background: rgba(175,82,222,0.2);  color: #c98fff; }
.cat-Divisas      { background: rgba(255,149,0,0.15);  color: #ffa040; }

/* ===== TABLES ===== */
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: rgba(255,255,255,0.03);
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--card-border);
}

tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(33,38,45,0.6);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== TRADE ROWS ===== */
.user-alias {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.amount { font-weight: 600; }
.amount-positive { color: var(--accent-green); }
.amount-negative { color: var(--accent-red); }

/* ===== PORTFOLIO TABLE ===== */
.pnl-positive { color: var(--accent-green); font-weight: 600; }
.pnl-negative { color: var(--accent-red);   font-weight: 600; }

/* ===== CATEGORY FILTER PILLS ===== */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.filter-pill {
  padding: 0.35em 0.85em;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  background: var(--card-bg);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.filter-pill:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  text-decoration: none;
}

.filter-pill.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}

/* ===== MARKET DETAIL ===== */
.market-detail-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.market-detail-card h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.market-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.market-meta span { display: flex; align-items: center; gap: 0.3rem; }

.market-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
}

.market-stat {
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.market-stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.market-stat .value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

/* ===== PORTFOLIO SUMMARY ===== */
.portfolio-summary {
  display: flex;
  gap: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.portfolio-summary .stat { text-align: center; }

.portfolio-summary .stat .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.portfolio-summary .stat .value {
  font-size: 1.35rem;
  font-weight: 700;
}

/* ===== BACK LINK ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1rem;
}

.back-link:hover { color: var(--text); text-decoration: none; }

/* ===== STATUS BADGE ===== */
.status-active   { color: var(--accent-green); }
.status-resolved { color: var(--text-muted); }
.status-closed   { color: var(--accent-red); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: static;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--card-border);
    overflow-x: auto;
  }

  .sidebar nav {
    display: flex;
    flex-direction: row;
    padding: 0;
  }

  .nav-link {
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .nav-link.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent-green);
  }

  .app-layout { flex-direction: column; }
  .main-content { margin-left: 0; padding: 1rem; }

  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .markets-grid { grid-template-columns: 1fr; }
  .market-stats-row { grid-template-columns: 1fr; }

  thead th, tbody td { padding: 0.5rem 0.6rem; }
}

@media (max-width: 480px) {
  .dashboard-stats { grid-template-columns: 1fr; }
  .portfolio-summary { flex-direction: column; gap: 0.75rem; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .markets-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
}
