/* Control de Asistencia — estilos globales SaaS oscuro */
:root {
  --bg-primary: #0b1220;
  --bg-secondary: #111827;
  --bg-card: #151c2c;
  --border: #243044;
  --text-primary: #e8eef7;
  --text-secondary: #9aa8bc;
  --primary: #2dd4bf;
  --primary-hover: #14b8a6;
  --primary-muted: rgba(45, 212, 191, 0.12);
  --success: #22c55e;
  --success-muted: rgba(34, 197, 94, 0.14);
  --warning: #f59e0b;
  --warning-muted: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-muted: rgba(239, 68, 68, 0.14);
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  --transition: 0.18s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

/* ——— App shell ——— */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), width var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-height);
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand .brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.6rem 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-section {
  margin-top: 0.85rem;
  padding: 0 0.65rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.15rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-muted);
  color: var(--primary);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--primary);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.55rem 0.25rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.user-chip .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-muted);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 0.75rem;
}

.content {
  flex: 1;
  padding: 1.25rem;
}

/* ——— Cards ——— */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-subtitle {
  margin: 0.2rem 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}

.kpi-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi-meta {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

/* ——— Tables ——— */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data-table th,
table.data-table td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
}

/* ——— Forms ——— */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.8rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-muted);
}

.form-control::placeholder {
  color: #6b7a90;
}

.form-hint {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.form-error {
  margin-top: 0.3rem;
  font-size: 0.78rem;
  color: var(--danger);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
  text-decoration: none;
  line-height: 1.2;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--primary);
  color: #042f2e;
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #042f2e;
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger-muted);
  border-color: transparent;
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

.btn-success {
  background: var(--success-muted);
  color: var(--success);
}

.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

/* ——— Badges ——— */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--success-muted);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-muted);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-muted);
  color: var(--danger);
}

.badge-info {
  background: var(--primary-muted);
  color: var(--primary);
}

.badge-neutral {
  background: rgba(154, 168, 188, 0.14);
  color: var(--text-secondary);
}

/* ——— Page helpers ——— */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.page-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.page-header p {
  margin: 0.25rem 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar .search {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.flash-success {
  background: var(--success-muted);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--success);
}

.flash-error,
.flash-danger {
  background: var(--danger-muted);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.flash-warning {
  background: var(--warning-muted);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--warning);
}

.flash-info {
  background: var(--primary-muted);
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--primary);
}

/* ——— Toasts ——— */
.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: toast-in 0.22s ease;
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-warning {
  border-left: 3px solid var(--warning);
}

.toast-info {
  border-left: 3px solid var(--primary);
}

.toast-body {
  flex: 1;
  font-size: 0.88rem;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 1.1rem;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ——— Error pages ——— */
.error-page {
  min-height: 70vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem 1rem;
}

.error-page .code {
  font-size: 3.5rem;
  font-weight: 750;
  color: var(--primary);
  letter-spacing: -0.03em;
  margin: 0;
}

.error-page h1 {
  margin: 0.5rem 0;
  font-size: 1.35rem;
}

.error-page p {
  color: var(--text-secondary);
  max-width: 420px;
  margin: 0 auto 1.25rem;
}

/* ——— Utilities ——— */
.text-muted {
  color: var(--text-secondary);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ——— Sidebar collapsed (tablet) ——— */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-section,
body.sidebar-collapsed .sidebar .nav-item span {
  display: none;
}

body.sidebar-collapsed .sidebar .nav-item {
  justify-content: center;
  padding: 0.65rem;
}

body.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 0;
}

/* ——— Responsive ——— */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-105%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .app-main {
    margin-left: 0;
  }

  body.sidebar-collapsed .app-main {
    margin-left: 0;
  }

  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-width);
  }

  body.sidebar-collapsed .sidebar .brand-text,
  body.sidebar-collapsed .sidebar .nav-section,
  body.sidebar-collapsed .sidebar .nav-item span {
    display: initial;
  }

  body.sidebar-collapsed .sidebar .nav-item {
    justify-content: flex-start;
    padding: 0.55rem 0.75rem;
  }

  .grid-2,
  .grid-3,
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 0.9rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 0.75rem;
  }

  .topbar-title {
    font-size: 0.95rem;
  }

  .user-chip .user-name {
    display: none;
  }

  .page-header h1 {
    font-size: 1.15rem;
  }
}

@media (min-width: 360px) and (max-width: 480px) {
  .btn {
    padding: 0.55rem 0.85rem;
  }

  table.data-table th,
  table.data-table td {
    padding: 0.6rem 0.7rem;
    font-size: 0.84rem;
  }
}

@media (min-width: 1600px) {
  .content {
    padding: 1.5rem 1.75rem;
  }
}

@media (min-width: 1920px) {
  .content {
    max-width: 1680px;
  }
}
