/* ═══════════════════════════════════════════════
   NexusPanel Dashboard — Dark Luxury Theme
   Font: Syne (headings) + DM Sans (body)
═══════════════════════════════════════════════ */

:root {
  --bg:         #0b0d14;
  --surface-1:  #111420;
  --surface-2:  #181b28;
  --surface-3:  #1e2233;
  --border:     #ffffff0f;
  --border-mid: #ffffff18;
  --text-1:     #f0f2ff;
  --text-2:     #8b90a7;
  --text-3:     #545870;
  --accent:     #6366f1;
  --accent-2:   #8b5cf6;
  --cyan:       #22d3ee;
  --amber:      #f59e0b;
  --green:      #10b981;
  --red:        #ef4444;
  --sidebar-w:  252px;
  --sidebar-w-collapsed: 68px;
  --topbar-h:   64px;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.45);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.6);
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text-1);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  height: 100%;
  overflow: hidden;
}

/* ─── APP SHELL ─────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  transition: grid-template-columns var(--transition);
}
.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* ─── SIDEBAR ────────────────────────────────── */
.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: width var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  gap: 8px;
}

.logo { display: flex; align-items: center; gap: 10px; overflow: hidden; flex: 1; }
.logo-mark svg { width: 32px; height: 32px; flex-shrink: 0; }
.logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--text-1);
  white-space: nowrap;
  transition: opacity var(--transition), width var(--transition);
}

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 6px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-1); background: var(--surface-3); }
.sidebar-toggle svg { width: 20px; height: 20px; }

/* Sidebar collapsed states */
.sidebar-collapsed .logo-text { opacity: 0; width: 0; }
.sidebar-collapsed .nav-label { opacity: 0; width: 0; }
.sidebar-collapsed .nav-badge { display: none; }
.sidebar-collapsed .user-info { opacity: 0; width: 0; }
.sidebar-collapsed .user-menu-btn { display: none; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--text-1); }
.nav-item.active {
  background: linear-gradient(135deg, #6366f118, #8b5cf610);
  color: var(--accent);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon svg { width: 20px; height: 20px; }
.nav-label { flex: 1; overflow: hidden; transition: opacity var(--transition), width var(--transition); }
.nav-badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  transition: opacity var(--transition);
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.user-card:hover { background: var(--surface-3); }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: 12px; font-weight: 800;
  color: white; flex-shrink: 0;
}
.user-info {
  flex: 1; overflow: hidden;
  transition: opacity var(--transition), width var(--transition);
}
.user-name { display: block; font-size: 13px; font-weight: 600; color: var(--text-1); }
.user-role { display: block; font-size: 11px; color: var(--text-3); }
.user-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); display: flex; padding: 2px;
}
.user-menu-btn svg { width: 16px; height: 16px; }

/* ─── MAIN CONTENT ────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ─── TOPBAR ─────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--topbar-h);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.mobile-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-2);
}
.mobile-menu-btn svg { width: 22px; height: 22px; }

.page-breadcrumb { display: flex; align-items: center; gap: 6px; }
.breadcrumb-root { font-family: 'Syne', sans-serif; font-weight: 600; color: var(--text-3); font-size: 13px; }
.breadcrumb-sep svg { width: 16px; height: 16px; color: var(--text-3); display: block; }
.breadcrumb-current { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--text-1); font-size: 14px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { width: 15px; height: 15px; color: var(--text-3); flex-shrink: 0; }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--text-1); font-family: 'DM Sans', sans-serif;
  font-size: 13px; width: 180px;
}
.search-box input::placeholder { color: var(--text-3); }

.topbar-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  color: var(--text-2);
  display: flex; align-items: center;
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.topbar-btn:hover { background: var(--surface-3); color: var(--text-1); }
.topbar-btn svg { width: 18px; height: 18px; }
.notif-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--red); border-radius: 50%;
  border: 2px solid var(--surface-1);
}

.topbar-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-size: 11px; font-weight: 800; color: white;
  cursor: pointer;
}

/* ─── PAGE CONTENT ────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
.page-content::-webkit-scrollbar { width: 5px; }
.page-content::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

/* ─── DASHBOARD LAYOUT ─────────────────────── */
.dashboard { display: flex; flex-direction: column; gap: 20px; }

/* ─── KPI SECTION ─────────────────────────── */
.kpi-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.kpi-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}
.kpi-title { font-size: 12px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-icon-wrap {
  width: 36px; height: 36px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.kpi-icon-wrap svg { width: 18px; height: 18px; }

.kpi-value {
  font-family: 'Syne', sans-serif;
  font-size: 28px; font-weight: 800;
  color: var(--text-1);
  line-height: 1.1;
  margin-bottom: 10px;
}
.kpi-footer { display: flex; align-items: center; gap: 8px; }
.kpi-change {
  display: flex; align-items: center; gap: 2px;
  font-size: 12px; font-weight: 600; border-radius: 99px;
  padding: 2px 8px;
}
.kpi-change.positive { background: #10b98120; color: var(--green); }
.kpi-change.negative { background: #ef444420; color: var(--red); }
.kpi-change svg { flex-shrink: 0; }
.kpi-period { font-size: 11px; color: var(--text-3); }

/* ─── CHARTS ROW ─────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
}

.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}
.chart-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700;
  color: var(--text-1); margin-bottom: 2px;
}
.chart-subtitle { font-size: 12px; color: var(--text-3); }

.chart-legend { display: flex; gap: 12px; align-items: center; }
.legend-item {
  font-size: 12px; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.legend-item::before {
  content: ''; width: 24px; height: 3px;
  border-radius: 2px; display: inline-block;
}
.legend-primary::before { background: #6366f1; }
.legend-secondary::before { background: #22d3ee; border-top: 2px dashed #22d3ee; }

.chart-body { width: 100%; overflow: hidden; }
.area-chart-wrap, .bar-chart-wrap { width: 100%; }
.area-svg, .bar-svg { width: 100%; display: block; }

.chart-label { fill: var(--text-3); font-size: 11px; font-family: 'DM Sans', sans-serif; }
.chart-dot { transition: r 0.15s; cursor: pointer; }
.chart-dot:hover { r: 5; }
.bar-rect { transition: opacity 0.15s; cursor: pointer; }
.bar-rect:hover { opacity: 0.8; }

/* Donut */
.donut-body { display: flex; flex-direction: column; align-items: center; }
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.donut-svg { width: 170px; height: 170px; }
.donut-segment { transition: stroke-width 0.15s; cursor: pointer; }
.donut-segment:hover { stroke-width: 32; }
.donut-center-label { fill: var(--text-3); font-size: 11px; font-family: 'DM Sans', sans-serif; }
.donut-center-value {
  fill: var(--text-1);
  font-size: 20px;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
}

.donut-legend { list-style: none; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.donut-legend-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--text-2); }
.legend-val { font-weight: 700; color: var(--text-1); font-family: 'Syne', sans-serif; }

/* ─── BOTTOM ROW ─────────────────────────── */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}

.right-column { display: flex; flex-direction: column; gap: 16px; }

/* ─── TABLE CARD ─────────────────────────── */
.table-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700;
  color: var(--text-1);
}
.card-action { font-size: 12px; color: var(--accent); text-decoration: none; }
.card-action:hover { text-decoration: underline; }

.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 16px;
  font-size: 11px; font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px;
  font-size: 13px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }

.tx-id { font-family: 'Syne', sans-serif; font-weight: 600; color: var(--text-1); font-size: 12px; }
.user-cell { display: flex; align-items: center; gap: 8px; color: var(--text-1); font-weight: 500; }
.mini-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 6px;
  font-size: 10px; font-weight: 800;
  color: white; display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
}
.amount-cell { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--text-1); }
.date-cell { color: var(--text-3); font-size: 12px; }

.status-badge {
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 600; text-transform: capitalize;
}
.status-completado { background: #10b98118; color: var(--green); }
.status-pendiente  { background: #f59e0b18; color: var(--amber); }
.status-fallido    { background: #ef444418; color: var(--red); }

/* ─── BAR CHART SMALL ─────────────────────── */
.chart-bar-small { padding: 16px 20px; }

/* ─── ACTIVITY CARD ──────────────────────── */
.activity-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.live-badge {
  font-size: 10px; font-weight: 700;
  color: var(--red); letter-spacing: 0.08em;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:0.4 } }

.activity-list { list-style: none; padding: 4px 0; }
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--surface-2); }

.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-top: 5px;
}
.activity-content { flex: 1; line-height: 1.4; }
.activity-user { font-weight: 600; color: var(--text-1); font-size: 13px; }
.activity-action { color: var(--text-2); font-size: 12px; }
.activity-time { font-size: 11px; color: var(--text-3); white-space: nowrap; margin-top: 2px; }

/* ─── NOT FOUND ──────────────────────────── */
.not-found { text-align: center; padding: 80px 20px; }
.not-found h1 { font-family: 'Syne', sans-serif; font-size: 96px; font-weight: 800; color: var(--surface-3); }
.not-found p { color: var(--text-2); }

/* ─── BLAZOR ERROR UI ────────────────────── */
#blazor-error-ui {
  background: #1e1b2e;
  border-top: 1px solid var(--accent);
  color: var(--text-1);
  padding: 12px 20px;
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 1000;
  display: none;
}
#blazor-error-ui .reload { color: var(--accent); }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ─── SCROLLBAR ────────────────────────── */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--surface-3); }

/* ─── MOBILE ──────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

@media (max-width: 1100px) {
  .kpi-section { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed; left: -100%; top: 0; bottom: 0;
    width: var(--sidebar-w) !important;
    transition: left var(--transition);
    z-index: 200;
  }
  .app-shell.mobile-open .sidebar { left: 0; }
  .app-shell.mobile-open .mobile-overlay { display: block; }
  .mobile-menu-btn { display: flex; }
  .search-box input { width: 120px; }
  .kpi-section { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 16px; }
}

@media (max-width: 480px) {
  .kpi-section { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .search-box { display: none; }
}

/* ─── ENTRANCE ANIMATIONS ─────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kpi-card      { animation: fadeUp 0.4s ease both; }
.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.10s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.20s; }
.chart-card    { animation: fadeUp 0.4s 0.25s ease both; }
.table-card    { animation: fadeUp 0.4s 0.30s ease both; }
.activity-card { animation: fadeUp 0.4s 0.35s ease both; }
