/* ═══════════════════════════════════════════════════════
   RUTY — Brand Override Layer para Material Dashboard 3
   Brand: #7DC242 verde | Sidebar: bg-gradient-dark (MD)
   ═══════════════════════════════════════════════════════ */

:root {
  --green:         #7DC242;
  --green-dark:    #2D6A2D;
  --green-mid:     #5a9e30;
  --green-light:   #EBF5E1;
  --green-xlight:  #F4FAF0;

  --bg:        #F7F8F6;
  --white:     #FFFFFF;
  --surface-2: #FAFAFA;

  --text:       #111827;
  --text-2:     #374151;
  --text-muted: #6B7280;
  --text-faint: #9CA3AF;

  --border:   #E5E7EB;
  --border-2: #F3F4F6;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow:    0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .06), 0 2px 4px rgba(0, 0, 0, .04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .08), 0 4px 8px rgba(0, 0, 0, .04);

  --red:        #DC2626;
  --red-bg:     #FEF2F2;
  --red-border: #FECACA;

  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --font-ui:   'Inter', system-ui, sans-serif;
  --font-mono: 'Courier New', monospace;
}

/* ─── Login page main ───────────────────────────────── */

.ruty-main-login {
  min-height: 100vh;
}

/* ─── Login inputs ──────────────────────────────────── */

.ruty-login-input {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
}

.ruty-login-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(125, 194, 66, .2);
}

.ruty-login-input::placeholder { color: var(--text-faint); }

/* ─── Sidebar user avatar ───────────────────────────── */

.ruty-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--green-mid));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

/* ─── Sidebar active nav item ───────────────────────── */

.sidenav .nav-link.ruty-nav-active {
  background: rgba(125, 194, 66, .18) !important;
  border-radius: 8px;
}

/* ─── Material Dashboard color overrides ────────────── */

/* Primary → RUTY green */
.bg-gradient-primary {
  background-image: linear-gradient(195deg, #7DC242 0%, #5a9e30 100%) !important;
}

.btn-primary {
  background-color: var(--green) !important;
  border-color: var(--green) !important;
  box-shadow: 0 2px 8px rgba(125, 194, 66, .3) !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--green-mid) !important;
  border-color: var(--green-mid) !important;
  box-shadow: 0 4px 14px rgba(125, 194, 66, .4) !important;
}

/* Form controls */
.form-control, .form-select {
  padding: 10px 14px;
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
}

.form-control:focus, .form-select:focus {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 0.2rem rgba(125, 194, 66, .25) !important;
}

/* Checkboxes + switches */
.form-check-input:checked {
  background-color: var(--green) !important;
  border-color: var(--green) !important;
}

.form-check-input:focus {
  box-shadow: 0 0 0 0.25rem rgba(125, 194, 66, .25) !important;
}

/* Table hover */
.table-hover > tbody > tr:hover > * {
  background-color: var(--green-xlight);
}

/* Badge success */
.badge.text-bg-success {
  background-color: #DCFCE7 !important;
  color: #15803D !important;
}

/* ─── Card extras ───────────────────────────────────── */

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

/* ─── Tables ────────────────────────────────────────── */

.table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  white-space: nowrap;
  text-align: left !important;
}

.table-sm thead th {
  padding: 0.25rem 0.5rem !important;
}

.table-sm tbody td {
  padding: 0.25rem 0.5rem !important;
}

/* Selects con aspecto de dropdown (flecha visible) */
select.form-control,
select.form-select {
  appearance: auto !important;
  -webkit-appearance: auto !important;
  background-image: none !important;
  cursor: pointer;
}

.table td {
  vertical-align: middle;
  color: var(--text-2);
}

#tablaEmpleados td {
  font-size: 12px;
}

#tablaConceptos td {
  font-size: 12px;
}

#tablaConceptos .badge {
  font-size: 10px;
  padding: 3px 7px;
}

.row-inactive td { opacity: .5; }

/* ─── Columnas ordenables ────────────────────────────── */

.th-sortable {
  cursor: pointer;
  user-select: none;
}
.th-sortable:hover {
  color: var(--text-2) !important;
}
.sort-icon {
  font-size: 13px;
  vertical-align: middle;
  opacity: .3;
  transition: opacity .15s;
  margin-left: 2px;
}
.th-sortable:hover .sort-icon,
.th-sortable.sort-active .sort-icon {
  opacity: 1;
}
.th-sortable.sort-active {
  color: var(--green-dark) !important;
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

/* ─── Page Header ───────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin: 0;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Stat Cards ────────────────────────────────────── */

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  height: 100%;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--green-mid));
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-number {
  font-size: 42px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -2px;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ─── Incidencias Table ─────────────────────────────── */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sticky employee columns */
.table-incidencias {
  border-collapse: separate;
  border-spacing: 0;
}

.inc-col-sticky {
  position: sticky;
  z-index: 2;
  background: var(--white);
}

.table-incidencias thead .inc-col-sticky {
  z-index: 3;
  background: #0E1512;
  color: rgba(255, 255, 255, .9);
}

.inc-col-1 { left: 0;     min-width: 68px;  max-width: 68px;  text-align: center; white-space: nowrap; }
.inc-col-2 { left: 68px;  min-width: 110px; max-width: 130px; }
.inc-col-3 { left: 178px; min-width: 120px; max-width: 150px; border-right: 2px solid #999 !important; box-shadow: 3px 0 8px rgba(0,0,0,.15); }

/* Grilla estilo Excel */
.table-incidencias th,
.table-incidencias td {
  border-right: 1px solid #d0d0d0;
  border-bottom: 1px solid #d0d0d0;
}
.table-incidencias thead th {
  border-top: 1px solid #bbb;
}
.table-incidencias th:first-child,
.table-incidencias td:first-child {
  border-left: 1px solid #d0d0d0;
}

/* Sin border-radius en el header — look Excel */
.table-incidencias thead tr th:first-child { border-radius: 0; }
.table-incidencias thead tr th:last-child  { border-radius: 0; }

/* Filas alternadas */
.table-incidencias tbody tr:nth-child(even) td { background: #f7f9f7; }
.table-incidencias tbody tr:nth-child(even) .inc-col-sticky { background: #f7f9f7; }

/* Hover */
.table-incidencias tbody tr:hover td { background: #f0f5ee; }
.table-incidencias tbody tr:hover .inc-col-sticky { background: #f0f5ee; }

/* Fila activa (celda enfocada) */
.table-incidencias tbody tr.fila-activa td { background: #e6f3d6 !important; }
.table-incidencias tbody tr.fila-activa .inc-col-sticky { background: #e6f3d6 !important; }

.table-incidencias .col-concepto {
  background: var(--green);
  color: #fff;
  text-align: center;
  min-width: 95px;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.3;
}

.table-incidencias thead th {
  white-space: normal;
}
.table-incidencias thead th.inc-col-1 {
  white-space: nowrap;
}

.table-incidencias-container {
  padding: 10px 12px 0;
}

.table-incidencias tbody td {
  font-size: 12px;
}

.inc-search-bar {
  padding: 12px 16px 8px;
  max-width: 320px;
}

.table-incidencias .col-obs {
  background: var(--green);
  color: #fff;
  text-align: center;
  min-width: 180px;
}

.obs-field {
  width: 100%;
  min-width: 160px;
}

.table-incidencias .cell-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: center;
}

.table-incidencias .cell-valor {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* Celda editable: el input llena toda la celda */
.table-editable .cell-input { padding: 0; }

.cell-field {
  width: 100%;
  padding: 5px 6px;
  border: none;
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-align: center;
  background: transparent;
  color: var(--text);
  display: block;
}

.cell-field:focus {
  outline: none;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--green);
}

/* Celda pre-cargada desde mes anterior */
.cell-precargada {
  background: #fffde7 !important;
}
.cell-precargada:focus {
  background: #fff9c4 !important;
  box-shadow: inset 0 0 0 2px #f9a825 !important;
}

/* ─── Icon buttons ──────────────────────────────────── */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
  padding: 0;
}

.btn-icon:hover {
  background: var(--border-2);
  color: var(--text);
}

.btn-icon .material-symbols-rounded {
  font-size: 18px;
}

.btn-icon-danger { color: #dc3545; }
.btn-icon-danger:hover { background: #fde8ea; color: #b02a37; }

.btn-icon-success { color: #198754; }
.btn-icon-success:hover { background: #d1e7dd; color: #146c43; }

.table-search-bar {
  padding: 12px 16px 8px;
}

/* ─── Form extras ───────────────────────────────────── */

.card-body label {
  font-weight: 600;
}

.form-hint {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 5px;
}

.form-actions-sticky {
  position: sticky;
  bottom: 0;
  background: var(--white);
  padding: 14px 16px;
  border-top: 1px solid var(--border-2);
  margin-top: 12px;
  z-index: 10;
}

.form-empresa-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-2);
}

.required { color: var(--red); }

/* ─── Período Cards ─────────────────────────────────── */

.periodo-list { padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }

.periodo-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: var(--green-xlight);
  border: 1px solid rgba(125, 194, 66, .2);
  border-radius: var(--radius);
  flex-wrap: wrap;
  gap: 12px;
  transition: all .2s;
}

.periodo-card:hover {
  border-color: var(--green);
  box-shadow: 0 4px 16px rgba(125, 194, 66, .12);
  transform: translateX(3px);
}

.periodo-info { display: flex; align-items: center; gap: 14px; }

.periodo-mes {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.periodo-card-cerrado {
  background: var(--surface-2);
  border-color: var(--border);
  opacity: .85;
}

/* Celda modificada en formulario de corrección */
.cell-modificada {
  background: #fff3cd !important;
  font-weight: 600;
}

/* ─── Error Pages ───────────────────────────────────── */

.error-page {
  text-align: center;
  padding: 60px 20px;
  max-width: 400px;
}

.error-code {
  font-size: 96px;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
  margin-bottom: 16px;
  letter-spacing: -4px;
}

.error-page h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
}

.error-page p { color: var(--text-muted); margin-bottom: 24px; }

/* ─── Empty State ───────────────────────────────────── */

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state p { margin-bottom: 6px; }

/* ─── Sidebar toggle ────────────────────────────────── */

/* Botón hamburguesa en la navbar */
.ruty-sidenav-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.ruty-sidenav-toggle:hover {
  background: var(--green-light);
  color: var(--green-dark);
}

/* Transición suave al colapsar/expandir */
.sidenav { transition: max-width .3s ease !important; }
.main-content { transition: margin-left .3s ease !important; }
.nav-link-text { transition: opacity .2s ease, width .2s ease !important; }

/* Cuando el sidebar está colapsado: ocultar labels de sección (Gestión, Cuenta) */
.g-sidenav-hidden .sidenav .nav-item.mt-3,
.g-sidenav-hidden .sidenav h6 {
  opacity: 0;
  height: 0;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}

/* Header blanco: ocultar completamente cuando está colapsado */
.g-sidenav-hidden .sidenav .sidenav-header {
  display: none !important;
}

/* Al hover el sidebar colapsado, restaurar los labels */
.g-sidenav-hidden .sidenav:hover .sidenav-header {
  display: block !important;
}
.g-sidenav-hidden .sidenav:hover .nav-item.mt-3,
.g-sidenav-hidden .sidenav:hover h6 {
  opacity: 1;
  height: auto;
  margin-top: 1rem !important;
  padding: inherit !important;
  overflow: visible;
}

/* ─── Code ──────────────────────────────────────────── */

code {
  font-family: var(--font-mono);
  background: var(--border-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--green-dark);
  font-weight: 500;
}

/* ── Toast notifications ───────────────────────────────── */
.ruty-toast-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  z-index: 9990;
  animation: rutyFadeIn 0.25s ease forwards;
}
.ruty-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  background: #fff;
  border-radius: 20px;
  padding: 40px 52px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 580px;
  max-width: 720px;
  animation: rutyToastIn 0.3s ease forwards;
}
.ruty-toast-icon {
  font-size: 56px !important;
  flex-shrink: 0;
}
.ruty-toast-text {
  flex: 1;
  font-size: 20px;
  font-weight: 500;
  color: #333;
  line-height: 1.4;
}
.ruty-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #bbb;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.ruty-toast-close:hover { color: #666; }

/* colores por tipo */
.ruty-toast-success { border-top: 4px solid #27ae60; }
.ruty-toast-success .ruty-toast-icon { color: #27ae60; }
.ruty-toast-error   { border-top: 4px solid #e74c3c; }
.ruty-toast-error   .ruty-toast-icon { color: #e74c3c; }

/* animaciones */
@keyframes rutyFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes rutyToastIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% - 18px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* salida (clase agregada por JS) */
.ruty-toast-hiding {
  animation: rutyToastOut 0.38s ease forwards !important;
}
.ruty-toast-overlay.ruty-toast-hiding {
  animation: rutyFadeOut 0.38s ease forwards !important;
}
@keyframes rutyToastOut {
  from { opacity: 1; transform: translate(-50%, -50%); }
  to   { opacity: 0; transform: translate(-50%, calc(-50% + 10px)); }
}
@keyframes rutyFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── Panel de Notificaciones ─────────────────────────────── */
.ruty-notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.ruty-notif-btn:hover { background: var(--border-2); }
.ruty-notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #DC2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}
.ruty-notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  overflow: hidden;
}
.ruty-notif-dropdown.open { display: block; }
.ruty-notif-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.ruty-notif-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  border-bottom: 1px solid var(--border-2);
  transition: background .15s;
}
.ruty-notif-item:hover { background: var(--green-xlight); color: var(--text); }
.ruty-notif-item:last-child { border-bottom: none; }
.ruty-notif-item-icon { color: var(--text-muted); flex-shrink: 0; }
.ruty-notif-item-label { flex: 1; }
.ruty-notif-item-count {
  background: #DC2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.ruty-notif-empty {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Fix: MD3 posiciona .input-group-text con position:absolute/right:0 —
   para input-groups estándar de Bootstrap (no-dynamic/static) lo revertimos */
.input-group:not(.input-group-dynamic):not(.input-group-static) .input-group-text {
  position: relative !important;
  right: auto !important;
  padding: 0.375rem 0.75rem !important;
}

/* Ambiente de desarrollo */
.ruty-dev-mode .sidenav { top: 31px !important; }
.ruty-dev-mode .main-content { padding-top: 31px; }
