/* ══════════════════════════════════════════════════════════════════
   SATH Dashboard Design System
   ══════════════════════════════════════════════════════════════════ */

/* ── Base font size (escala rem → Tailwind + custom CSS) ─────────── */
html { font-size: 17px; }

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --sath-primary:       #4361ee;
  --sath-primary-dark:  #3451d1;
  --sath-secondary:     #805dca;
  --sath-success:       #00ab55;
  --sath-danger:        #e7515a;
  --sath-warning:       #e2a03f;
  --sath-info:          #2196f3;
  --sath-text-muted:    #506690;
  --sath-border:        #1b2e4b;
  --sath-card-bg:       #0e1726;
  --sath-card-bg-2:     #162032;
  --sath-radius:        10px;
  --sath-radius-lg:     16px;
  --sath-shadow-card:   0 2px 12px rgba(0,0,0,.25);
}

/* ── Stat cards ─────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  border-radius: var(--sath-radius-lg);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--sath-shadow-card);
  transition: transform .25s, box-shadow .25s;
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}

.stat-card.purple { background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%); }
.stat-card.cyan   { background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%); }
.stat-card.orange { background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%); }
.stat-card.green  { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }

.stat-card-inner { position: relative; z-index: 1; }

.stat-card-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 16px;
}

.stat-label  { font-size: 14px; font-weight: 600; color: rgba(255,255,255,.8); margin-bottom: 4px; }
.stat-value  { font-size: 40px; font-weight: 900; color: #fff; line-height: 1; }
.stat-sub    { font-size: 13px; color: rgba(255,255,255,.65); margin-top: 6px; }

.stat-icon-wrap {
  width: 48px; height: 48px;
  background: rgba(255,255,255,.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}

.stat-card::after {
  content: '';
  position: absolute; right: -20px; bottom: -20px;
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(255,255,255,.08); pointer-events: none;
}
.stat-card::before {
  content: '';
  position: absolute; right: 30px; bottom: -40px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,.05); pointer-events: none;
}

/* ── Dashboard panel ─────────────────────────────────────────────── */
.sath-panel {
  background: var(--sath-card-bg);
  border-radius: var(--sath-radius-lg);
  border: 1px solid var(--sath-border);
  box-shadow: var(--sath-shadow-card);
  overflow: hidden;
  margin-bottom: 24px;
}

.sath-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--sath-border);
}

.sath-panel-title {
  font-size: 16px; font-weight: 700; color: #e0e6ed;
  display: flex; align-items: center; gap: 8px;
}

.sath-panel-title-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sath-primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,.25);
  flex-shrink: 0;
}

.sath-panel-body { padding: 20px 22px; }

/* ── Dashboard 2-column grid ─────────────────────────────────────── */
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── Dashboard badges ────────────────────────────────────────────── */
.sath-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.sath-badge::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor;
}

.sath-badge-primary   { background: rgba(67,97,238,.15);  color: #818cf8; }
.sath-badge-success   { background: rgba(0,171,85,.15);   color: #34d399; }
.sath-badge-warning   { background: rgba(226,160,63,.15); color: #fbbf24; }
.sath-badge-info      { background: rgba(33,150,243,.15); color: #60a5fa; }
.sath-badge-danger    { background: rgba(231,81,90,.15);  color: #f87171; }
.sath-badge-secondary { background: rgba(128,93,202,.15); color: #a78bfa; }

/* ── Dashboard page header ───────────────────────────────────────── */
.sath-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}

.sath-page-title { font-size: 22px; font-weight: 800; color: #e0e6ed; }
.sath-page-title small {
  display: block; font-size: 13px; font-weight: 400;
  color: var(--sath-text-muted); margin-top: 2px;
}

.sath-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--sath-text-muted); margin-bottom: 0;
}
.sath-breadcrumb a { color: var(--sath-text-muted); transition: color .2s; }
.sath-breadcrumb a:hover { color: var(--sath-primary); }
.sath-breadcrumb .sep { opacity: .4; }
.sath-breadcrumb .current { color: #e0e6ed; font-weight: 600; }

/* ── Spinner ─────────────────────────────────────────────────────── */
.sath-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--sath-border);
  border-top-color: var(--sath-primary);
  border-radius: 50%;
  animation: sath-spin .65s linear infinite;
  flex-shrink: 0;
}

.sath-loading-center {
  display: flex; justify-content: center; align-items: center;
  padding: 48px; flex-direction: column; gap: 12px;
}
.sath-loading-center p { font-size: 13px; color: var(--sath-text-muted); }

/* ── Dashboard table ─────────────────────────────────────────────── */
.sath-table-wrap { overflow-x: auto; }

.sath-table { width: 100%; border-collapse: collapse; }

.sath-table thead tr { border-bottom: 1px solid var(--sath-border); }

.sath-table thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--sath-text-muted);
  white-space: nowrap;
  background: var(--sath-card-bg-2);
}

.sath-table tbody tr {
  border-bottom: 1px solid var(--sath-border);
  transition: background .15s;
}
.sath-table tbody tr:last-child { border-bottom: none; }
.sath-table tbody tr:hover { background: rgba(67,97,238,.04); }

.sath-table tbody td {
  padding: 11px 16px;
  font-size: 14px;
  color: #e0e6ed;
  vertical-align: middle;
}

/* ── Pulse animation for live indicator ───────────────────────────── */
@keyframes sath-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}
@keyframes sath-spin { to { transform: rotate(360deg); } }
@keyframes sath-btn-spin { to { transform: rotate(360deg); } }

.sath-pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #00ab55;
  animation: sath-pulse 2s infinite;
  display: inline-block;
}

.sath-refresh-icon-spin { animation: sath-btn-spin .7s linear infinite; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card  { padding: 16px 18px; }
  .stat-value { font-size: 28px; }
}

/* ── Select styling ─────────────────────────────────────────────────── */

.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234361ee' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.9rem;
    padding-right: 2rem !important;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select:focus {
    outline: none;
    border-color: #4361ee !important;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.form-select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.dark .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234361ee' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* Extra-small select for inline table use */
.form-select.text-xs {
    font-size: 0.72rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    padding-left: 0.5rem;
    border-radius: 0.35rem;
}

/* ── Action button grid ──────────────────────────────────────────────── */

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.72rem;
    line-height: 1.3;
    border-radius: 0.3rem;
    white-space: nowrap;
}
/* Transiciones suaves al cambiar tema */
#sath-bar-chart,
#sath-donut-chart,
.sath-panel,
.stat-card {
  transition: background-color 0.25s ease,
  border-color 0.25s ease,
  color 0.25s ease;
}

/* Forzar consistencia en modo oscuro */
.dark .sath-panel {
  background-color: #0f172a !important;
  border-color: #1e293b !important;
}

.dark .sath-table thead {
  background-color: #1e293b !important;
}

.dark .stat-card.purple {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
}

.dark .stat-card.orange {
  background: linear-gradient(135deg, #d97706 0%, #ea580c 100%) !important;
}

.dark .stat-card.cyan {
  background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%) !important;
}

.dark .stat-card.green {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important;
}

/* ── Modo claro ──────────────────────────────────────────────────── */
body:not(.dark) {
  --sath-border:        #e2e8f0;
  --sath-card-bg:       #ffffff;
  --sath-card-bg-2:     #f8fafc;
  --sath-text-muted:    #64748b;
  --sath-shadow-card:   0 2px 12px rgba(0,0,0,.08);
}

body:not(.dark) .sath-panel {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
}

body:not(.dark) .sath-panel-title { color: #1e293b; }
body:not(.dark) .sath-panel-header { border-color: #e2e8f0; }

body:not(.dark) .sath-table thead th {
  background-color: #f8fafc !important;
  color: #64748b;
}

body:not(.dark) .sath-table tbody tr { border-color: #e2e8f0; }
body:not(.dark) .sath-table tbody tr:hover { background: rgba(67,97,238,.04); }
body:not(.dark) .sath-table tbody td { color: #1e293b; }

body:not(.dark) .sath-page-title { color: #1e293b; }
body:not(.dark) .sath-breadcrumb { color: #64748b; }
body:not(.dark) .sath-breadcrumb .current { color: #1e293b; }

body:not(.dark) .sath-badge-primary   { background: rgba(67,97,238,.1);  color: #4361ee; }
body:not(.dark) .sath-badge-success   { background: rgba(0,171,85,.1);   color: #059669; }
body:not(.dark) .sath-badge-warning   { background: rgba(226,160,63,.1); color: #d97706; }
body:not(.dark) .sath-badge-info      { background: rgba(33,150,243,.1); color: #0891b2; }
body:not(.dark) .sath-badge-secondary { background: rgba(128,93,202,.1); color: #7c3aed; }

/* ══════════════════════════════════════════════════════════════════
   SATH Preloader  ·  Tech HUD style
   ══════════════════════════════════════════════════════════════════ */

#sath-preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060818;
  overflow: hidden;
}

/* Animated grid background */
.sath-pre-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(67,97,238,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67,97,238,.07) 1px, transparent 1px);
  background-size: 56px 56px;
  animation: sath-pre-grid-move 8s linear infinite;
}
@keyframes sath-pre-grid-move {
  from { background-position: 0 0; }
  to   { background-position: 56px 56px; }
}

/* Central glow */
.sath-pre-glow {
  position: absolute;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(67,97,238,.18) 0%, rgba(128,93,202,.08) 50%, transparent 70%);
  animation: sath-pre-glow-pulse 3.5s ease-in-out infinite;
}
@keyframes sath-pre-glow-pulse {
  0%, 100% { transform: scale(1);   opacity: .7; }
  50%       { transform: scale(1.25); opacity: 1; }
}

/* Horizontal scan line */
.sath-pre-scan {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(67,97,238,.7) 50%, transparent 100%);
  animation: sath-pre-scan-move 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sath-pre-scan-move {
  0%   { top: -2px;   opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { top: 100%;  opacity: 0; }
}

/* Corner brackets */
.sath-pre-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  opacity: .35;
}
.sath-pre-corner--tl { top: 28px;    left: 28px;  border-top:    2px solid #4361ee; border-left:   2px solid #4361ee; }
.sath-pre-corner--tr { top: 28px;    right: 28px; border-top:    2px solid #4361ee; border-right:  2px solid #4361ee; }
.sath-pre-corner--bl { bottom: 28px; left: 28px;  border-bottom: 2px solid #4361ee; border-left:   2px solid #4361ee; }
.sath-pre-corner--br { bottom: 28px; right: 28px; border-bottom: 2px solid #4361ee; border-right:  2px solid #4361ee; }

/* Central content */
.sath-pre-box {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  text-align: center;
}

/* Spinning rings + CPU icon */
.sath-pre-icon-wrap {
  position: relative;
  width: 88px;
  height: 88px;
}
.sath-pre-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #4361ee;
  border-right-color: rgba(67,97,238,.25);
  animation: sath-pre-spin 1.4s linear infinite;
}
.sath-pre-ring-2 {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: #805dca;
  border-left-color: rgba(128,93,202,.25);
  animation: sath-pre-spin 2.2s linear infinite reverse;
}
.sath-pre-icon-inner {
  position: absolute;
  inset: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4361ee;
  animation: sath-pre-icon-glow 2.5s ease-in-out infinite;
}
@keyframes sath-pre-spin { to { transform: rotate(360deg); } }
@keyframes sath-pre-icon-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(67,97,238,.5)); }
  50%       { filter: drop-shadow(0 0 14px rgba(67,97,238,1)) drop-shadow(0 0 28px rgba(128,93,202,.5)); }
}

/* SATH title */
.sath-pre-title {
  font-size: clamp(52px, 10vw, 80px);
  font-weight: 900;
  letter-spacing: 0.2em;
  color: #fff;
  line-height: 1;
  animation: sath-pre-title-glow 3s ease-in-out infinite;
}
@keyframes sath-pre-title-glow {
  0%, 100% { text-shadow: 0 0 20px rgba(67,97,238,.5), 0 0 50px rgba(67,97,238,.15); }
  50%       { text-shadow: 0 0 40px rgba(67,97,238,.9), 0 0 80px rgba(128,93,202,.4), 0 0 120px rgba(67,97,238,.2); }
}

.sath-pre-subtitle {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  font-weight: 500;
}

/* Progress bar */
.sath-pre-bar-track {
  width: min(360px, 78vw);
  height: 3px;
  background: rgba(255,255,255,.07);
  border-radius: 99px;
  overflow: hidden;
}
.sath-pre-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #4361ee, #805dca, #4361ee);
  background-size: 200% 100%;
  box-shadow: 0 0 12px rgba(67,97,238,.8);
  animation:
    sath-pre-bar-grow   2.8s cubic-bezier(.4,0,.2,1) forwards,
    sath-pre-bar-shine  1.4s linear infinite;
}
@keyframes sath-pre-bar-grow {
  0%   { width: 0%; }
  35%  { width: 55%; }
  65%  { width: 78%; }
  85%  { width: 91%; }
  100% { width: 100%; }
}
@keyframes sath-pre-bar-shine {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Status text */
.sath-pre-status {
  font-size: 11.5px;
  color: rgba(255,255,255,.3);
  letter-spacing: 0.12em;
  font-family: 'Courier New', monospace;
  min-height: 1.4em;
  animation: sath-pre-blink 1.1s step-end infinite;
}
@keyframes sath-pre-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Preloader — modo claro ──────────────────────────────────────── */
[data-pre-light] #sath-preloader {
  background: #f0f4ff;
}
[data-pre-light] .sath-pre-grid {
  background-image:
    linear-gradient(rgba(67,97,238,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67,97,238,.12) 1px, transparent 1px);
}
[data-pre-light] .sath-pre-glow {
  background: radial-gradient(circle, rgba(67,97,238,.14) 0%, rgba(128,93,202,.06) 50%, transparent 70%);
}
[data-pre-light] .sath-pre-scan {
  background: linear-gradient(90deg, transparent 0%, rgba(67,97,238,.5) 50%, transparent 100%);
}
[data-pre-light] .sath-pre-corner {
  opacity: .5;
}
[data-pre-light] .sath-pre-title {
  color: #1e293b;
  animation: sath-pre-title-glow-light 3s ease-in-out infinite;
}
@keyframes sath-pre-title-glow-light {
  0%, 100% { text-shadow: 0 0 20px rgba(67,97,238,.3), 0 0 40px rgba(67,97,238,.08); }
  50%       { text-shadow: 0 0 32px rgba(67,97,238,.6), 0 0 64px rgba(128,93,202,.2); }
}
[data-pre-light] .sath-pre-subtitle {
  color: rgba(30,41,59,.45);
}
[data-pre-light] .sath-pre-bar-track {
  background: rgba(67,97,238,.12);
}
[data-pre-light] .sath-pre-bar-fill {
  box-shadow: 0 0 10px rgba(67,97,238,.5);
}
[data-pre-light] .sath-pre-status {
  color: rgba(30,41,59,.45);
}
[data-pre-light] .sath-pre-icon-inner {
  color: #4361ee;
}
