/* ══════════════════════════════════════════════════════
   MARS DESIGN SYSTEM v4 — Light Mode Premium
   Inspired by modern class management dashboards
   ══════════════════════════════════════════════════════ */

:root {
  /* Backgrounds — cream/off-white */
  --bg: #F5F5F0;
  --bg-soft: #FAFAF7;
  --card: #FFFFFF;
  --card-hover: #FEFEFE;
  --card-inner: #F8F8F4;
  --input: #F7F7F2;

  /* Borders */
  --border: rgba(0, 0, 0, .06);
  --border-strong: rgba(0, 0, 0, .1);
  --border-hover: rgba(0, 0, 0, .16);

  /* Text — dark for light mode */
  --text-1: #0F1115;
  --text-2: #3D4250;
  --text-3: #6B7280;
  --text-4: #9CA3AF;

  /* Brand MARS */
  --mars: #E5140A;
  --mars-hover: #C91008;
  --mars-soft: rgba(229, 20, 10, .08);
  --mars-glow: rgba(229, 20, 10, .18);

  /* Status — vibrant but soft */
  --green: #10B981;
  --green-soft: rgba(16, 185, 129, .12);
  --green-bar: #34D399;

  --amber: #F59E0B;
  --amber-soft: rgba(245, 158, 11, .12);

  --red: #EF4444;
  --red-soft: rgba(239, 68, 68, .12);
  --red-bright: #FF4757;

  --blue: #3B82F6;
  --blue-soft: rgba(59, 130, 246, .12);

  --purple: #8B5CF6;
  --purple-soft: rgba(139, 92, 246, .12);

  /* Radius — very rounded like inspiration */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-2xl: 28px;
  --r-pill: 9999px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: 'Barlow Condensed', var(--font);

  /* Shadows — soft and elegant */
  --shadow-xs: 0 1px 2px rgba(15, 17, 21, .04);
  --shadow-sm: 0 1px 3px rgba(15, 17, 21, .06), 0 1px 2px rgba(15, 17, 21, .04);
  --shadow-md: 0 4px 12px rgba(15, 17, 21, .06), 0 2px 4px rgba(15, 17, 21, .04);
  --shadow-lg: 0 12px 28px rgba(15, 17, 21, .08), 0 4px 8px rgba(15, 17, 21, .05);
  --shadow-xl: 0 24px 48px rgba(15, 17, 21, .1), 0 8px 16px rgba(15, 17, 21, .06);
  --shadow-card: 0 2px 6px rgba(15, 17, 21, .04), 0 0 0 1px rgba(15, 17, 21, .03);

  /* Motion */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  font-family: var(--font); font-size: 15px; line-height: 1.6;
  color: var(--text-1); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
body { min-height: 100dvh; overflow-x: hidden; background: var(--bg); }
input, button, select, textarea { font-family: inherit; font-size: inherit; outline: none; }
::selection { background: var(--mars); color: white; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .08); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .16); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes slideSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 15%,45%,75% { transform: translateX(-4px); } 30%,60%,90% { transform: translateX(4px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes livePingDot {
  0% { transform: scale(.8); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; min-height: 42px; border-radius: var(--r-md); font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--text-1);
  cursor: pointer; transition: all var(--dur) var(--ease); white-space: nowrap;
}
.btn:hover { background: var(--card-hover); border-color: var(--border-hover); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0) scale(.98); }

.btn-primary { background: var(--text-1); border-color: var(--text-1); color: white; }
.btn-primary:hover { background: #1F2937; border-color: #1F2937; }

.btn-mars { background: var(--mars); border-color: var(--mars); color: white; box-shadow: 0 2px 8px var(--mars-glow); }
.btn-mars:hover { background: var(--mars-hover); box-shadow: 0 6px 16px var(--mars-glow); }

.btn-success { background: var(--green); border-color: var(--green); color: white; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--card-inner); color: var(--text-1); border-color: var(--border); }

.btn-outline-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-outline-danger:hover { background: var(--red-soft); }

.btn-sm { padding: 8px 14px; min-height: 36px; font-size: 12px; border-radius: var(--r-sm); }
.btn-xs { padding: 4px 9px; min-height: 26px; font-size: 11px; border-radius: var(--r-sm); }
.btn-lg { padding: 16px 32px; min-height: 52px; font-size: 15px; border-radius: var(--r-lg); }
.btn-full { width: 100%; }
.btn-icon { width: 42px; height: 42px; min-height: 42px; padding: 0; border-radius: var(--r-md); }

/* ── CARDS — white, rounded, soft shadow ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 22px;
  box-shadow: var(--shadow-card); transition: all var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text-3); }
.card-title-lg { font-size: 15px; font-weight: 700; color: var(--text-1); }

/* ── STATS — spacious, clean ── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 480px) { .stats-grid { gap: 14px; } }
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; } }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow-card); transition: all var(--dur) var(--ease);
  position: relative;
}
@media (min-width: 768px) { .stat-card { padding: 22px; border-radius: var(--r-xl); } }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-value { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1; color: var(--text-1); }
@media (min-width: 768px) { .stat-value { font-size: 38px; } }
.stat-label { font-size: 11px; font-weight: 500; color: var(--text-3); margin-top: 6px; }
@media (min-width: 768px) { .stat-label { font-size: 12px; margin-top: 8px; } }
.stat-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: var(--r-pill); margin-top: 10px; }
.stat-trend-up { background: var(--green-soft); color: var(--green); }
.stat-trend-down { background: var(--red-soft); color: var(--red); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 5px 12px;
  border-radius: var(--r-pill); letter-spacing: .01em;
  white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-mars { background: var(--mars-soft); color: var(--mars); }
.badge-neutral { background: var(--card-inner); color: var(--text-3); border: 1px solid var(--border); }
.badge-admin { background: var(--mars-soft); color: var(--mars); }
.badge-supervisor { background: var(--blue-soft); color: var(--blue); }
.badge-administracion { background: var(--amber-soft, #fef3c7); color: var(--amber, #b45309); }
.badge-rrhh { background: #ede9fe; color: #6d28d9; }
.badge-vigilante { background: var(--green-soft); color: var(--green); }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-inactive { background: var(--card-inner); color: var(--text-3); }

/* Live badge with pulsing dot */
.badge-live {
  background: var(--red-bright); color: white;
  padding: 5px 12px 5px 8px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700;
  border-radius: var(--r-pill);
}
.badge-live::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: white;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .5);
  animation: livePulse 1.5s ease-in-out infinite;
}

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-2); margin-bottom: 8px;
}
.form-input {
  width: 100%; padding: 12px 16px; min-height: 46px; font-size: 16px; font-weight: 500;
  background: var(--input); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); color: var(--text-1);
  transition: all var(--dur-fast) var(--ease);
}
@media (min-width: 768px) { .form-input { font-size: 14px; min-height: 42px; } }
.form-input:focus { border-color: var(--mars); box-shadow: 0 0 0 3px var(--mars-soft); background: var(--card); }
.form-input::placeholder { color: var(--text-4); }
select.form-input {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px;
}
textarea.form-input { resize: vertical; min-height: 90px; line-height: 1.5; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 420px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }

/* ── TABLES ── */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--card);
  box-shadow: var(--shadow-card); -webkit-overflow-scrolling: touch;
}
@media (min-width: 768px) { .table-wrap { border-radius: var(--r-xl); } }
.table { width: 100%; border-collapse: collapse; min-width: 540px; }
.table th {
  text-align: left; padding: 12px 14px; font-size: 10px; font-weight: 600;
  color: var(--text-3); background: var(--card-inner);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
@media (min-width: 768px) { .table th { padding: 14px 20px; font-size: 11px; } }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
@media (min-width: 768px) { .table td { padding: 16px 20px; font-size: 14px; } }
.table tr { transition: background var(--dur-fast); }
.table tr:hover td { background: var(--card-inner); }
.table tr:last-child td { border-bottom: none; }
.table td strong { color: var(--text-1); font-weight: 600; }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15, 17, 21, .4); backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn var(--dur-fast); padding: 0;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 24px; } }
.modal-content {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0; width: 100%; max-width: 560px;
  max-height: 92dvh; overflow-y: auto; box-shadow: var(--shadow-xl);
  animation: slideSheet var(--dur-slow) var(--ease-spring);
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) { .modal-content { border-radius: var(--r-xl); animation-name: scaleIn; max-height: 90dvh; } }
.modal-content.modal-wide { max-width: 760px; }
.modal-content.modal-xl { max-width: 920px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
@media (min-width: 640px) { .modal-header { padding: 22px 26px; } }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-1); }
@media (min-width: 640px) { .modal-title { font-size: 17px; } }
.modal-body { padding: 18px; }
@media (min-width: 640px) { .modal-body { padding: 26px; } }
.modal-footer {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 18px;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--card);
}
@media (min-width: 480px) { .modal-footer { flex-direction: row; gap: 10px; padding: 18px 26px; } }
.modal-footer .btn { flex: 1; min-height: 46px; }

/* ── TOAST ── */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 950;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
@media (max-width: 480px) { .toast-container { left: 16px; right: 16px; top: 16px; } }
.toast {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 18px; display: flex; align-items: center; gap: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-xl);
  animation: fadeUp var(--dur) var(--ease-spring); pointer-events: auto;
  color: var(--text-1);
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--amber); }

/* ── EMPTY STATE ── */
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 56px 28px; text-align: center; }
.empty-icon { font-size: 52px; margin-bottom: 14px; opacity: .2; }
.empty-text { font-size: 15px; color: var(--text-3); line-height: 1.6; }

/* ── LOADING ── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border-strong); border-top-color: var(--mars); border-radius: 50%; animation: spin .5s linear infinite; }

/* Progress bar */
.progress-bar {
  width: 100%; height: 10px;
  background: var(--card-inner); border-radius: var(--r-pill);
  overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; border-radius: var(--r-pill);
  transition: width var(--dur-slow) var(--ease);
}
.progress-fill-green { background: linear-gradient(90deg, #34D399, #10B981); }
.progress-fill-amber { background: linear-gradient(90deg, #FBBF24, #F59E0B); }
.progress-fill-red { background: linear-gradient(90deg, #F87171, #EF4444); }
.progress-fill-blue { background: linear-gradient(90deg, #60A5FA, #3B82F6); }

/* Ring chart */
.ring-chart {
  width: 120px; height: 120px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.ring-chart svg { transform: rotate(-90deg); position: absolute; inset: 0; }
.ring-chart-value {
  font-family: var(--font-display); font-size: 32px; font-weight: 800;
  color: var(--text-1); line-height: 1;
}
.ring-chart-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Avatar */
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card-inner);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--text-2);
  overflow: hidden; flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-ring { box-shadow: 0 0 0 3px var(--card), 0 0 0 4px var(--border); }

/* ── RESPONSIVE ── */
@media (max-width: 479px) { .hide-mobile { display: none !important; } }

/* ── PRINT ── */
@media print {
  body { background: white; color: black; }
  .no-print { display: none !important; }
  .card, .stat-card, .table-wrap { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
