html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* ===== TIMESHEET CUSTOM STYLES ===== */

/* Tab buttons — MVP-style pill container */
.ts-tab-container {
  display: inline-flex;
  gap: 2px;
  background: #f0f4f8;
  border-radius: 8px;
  padding: 3px;
}

.ts-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  background: transparent;
  color: #627d98;
}

.ts-tab-btn:hover {
  color: #334e68;
}

.ts-tab-btn.active {
  background: #fff;
  color: #243b53;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  font-weight: 600;
}

.ts-tab-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Icon buttons — MVP-style borderless with colored hover */
.ts-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 8px;
  color: #829ab1;
  text-decoration: none;
  transition: all 150ms ease;
  line-height: 1;
}

.ts-icon-notes:hover {
  color: #d97706;
  background: #fffbeb;
}

.ts-icon-gear:hover {
  color: #0891b2;
  background: #ecfeff;
}

.ts-icon-absence:hover {
  color: #dc2626;
  background: #fef2f2;
}

.ts-icon-override:hover {
  color: #7c3aed;
  background: #f5f3ff;
}

.ts-exception-pill {
  display: inline-block;
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
  line-height: 1.4;
}
.ts-exception-pill:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

.ts-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f59e0b;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Scrollable grid container with sticky header */
.ts-grid-scroll {
  max-height: calc(100vh - 280px);
  overflow: auto;
}

/* Sticky header for timesheet grids — month row */
.ts-grid-horas thead tr:first-child th,
.ts-grid-entrada thead tr:first-child th,
.ts-grid-export thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #e0f2fe;
}

/* Sticky header — day row (below month row) */
.ts-grid-horas thead tr:nth-child(2) th,
.ts-grid-entrada thead tr:nth-child(2) th,
.ts-grid-export thead tr:nth-child(2) th {
  position: sticky;
  top: 28px;
  z-index: 3;
  background: #f8f9fa;
}

/* Employee column header needs higher z-index (sticky left + top) */
.ts-grid-horas thead th:first-child,
.ts-grid-entrada thead th:first-child,
.ts-grid-export thead th:first-child {
  z-index: 5;
}

/* Export total column header needs high z-index too */
.ts-grid-export thead th:last-child {
  z-index: 5;
}

/* Vertical centering for grid cells */
.ts-grid-horas td,
.ts-grid-entrada td {
  vertical-align: middle;
}

/* Notes modal */
.ts-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(0,0,0,.4);
  align-items: center;
  justify-content: center;
}
.ts-modal-overlay.show { display: flex; }

.ts-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0,0,0,.2);
  border: 1px solid #d9e2ec;
  width: 100%;
  max-width: 520px;
  margin: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.ts-notes-list {
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
  margin-bottom: 16px;
}

.ts-note-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.ts-note-item:first-child {
  background: rgba(245,158,11,.08);
}

/* Tooltip — MVP-style white popup with arrow */
.ts-tip-wrap {
  position: relative;
  cursor: help;
}

.ts-tip-wrap .ts-tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  color: #102a43;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1.7;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  border: 1px solid #d9e2ec;
}

.ts-tip-wrap .ts-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #ffffff;
}

.ts-tip-wrap:hover .ts-tip {
  display: block;
}

/* Tooltip flipped below for first row */
.ts-tip-wrap .ts-tip-below {
  bottom: auto;
  top: calc(100% + 8px);
}

.ts-tip-wrap .ts-tip-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #ffffff;
}

/* Grid cell borders — black instead of Bootstrap default gray */
.ts-grid-horas.table-bordered > :not(caption) > * > *,
.ts-grid-entrada.table-bordered > :not(caption) > * > *,
.ts-grid-export.table-bordered > :not(caption) > * > * {
  border-color: #000 !important;
}

/* Ensure all grid cells have explicit top+bottom black borders */
.ts-grid-horas td,
.ts-grid-horas th,
.ts-grid-entrada td,
.ts-grid-entrada th,
.ts-grid-export td,
.ts-grid-export th {
  border-top: 1px solid #000 !important;
  border-bottom: 1px solid #000 !important;
}

/* Cell colors: .ts-cell-* rules are injected dynamically by _Layout.cshtml */
/* from AbsenceColorService (configured via Settings > Colores). */
/* A static fallback for legacy class name: */
.ts-cell-other-absence { background-color: #fef3c7 !important; color: #92400e; }

/* ================================================================ */
/* Calendar view (Calendario de Ausencias) — layout classes only.   */
/* Cell colors reuse existing .ts-cell-* classes above.             */
/* ================================================================ */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-header > div {
  font-weight: 600;
  text-align: center;
  padding: 8px 6px;
  background: #102a43;
  color: #fff;
  border-radius: 4px;
  font-family: 'Lexend', sans-serif;
  letter-spacing: 0.05em;
}
.cal-day {
  min-height: 130px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  padding: 5px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 4px;
}
.cal-day-out {
  background: #f8f9fa;
  color: #adb5bd;
  border-color: #f1f3f5;
}
.cal-day-out .cal-day-num { color: #adb5bd; }
.cal-day-weekend {
  background: #fafbfc;
}
.cal-day-today {
  outline: 2px solid #0891B2;
  outline-offset: -2px;
}
.cal-day-num {
  font-weight: 700;
  font-size: 0.95rem;
  color: #102a43;
  margin-bottom: 2px;
  font-family: 'Lexend', sans-serif;
}
.cal-holiday-banner {
  font-size: 0.72rem;
  padding: 3px 5px;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-absence {
  font-size: 0.75rem;
  padding: 2px 5px;
  border-radius: 3px;
  display: flex;
  gap: 5px;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
}
.cal-badge {
  font-weight: 700;
  font-size: 0.68rem;
  padding: 0 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.cal-name {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ================================================================ */
/* Sidebar navigation (rail, collapsible)                           */
/* ================================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #102a43;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
html.sidebar-collapsed .sidebar {
  width: 64px;
}
.sidebar-brand {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.sidebar-brand-full {
  display: block;
  min-width: 0;
}
.sidebar-brand-compact {
  display: none;
  background: #fff;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  padding: 4px;
  align-items: center;
  justify-content: center;
}
.sidebar-brand-compact img {
  width: 100%;
  height: 100%;
  display: block;
}
html.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
html.sidebar-collapsed .sidebar-brand-full { display: none; }
html.sidebar-collapsed .sidebar-brand-compact { display: flex; }
.sidebar-title {
  font-family: 'Lexend', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}
.sidebar-subtitle {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-toggle {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.85);
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  width: 100%;
}
.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.sidebar-toggle svg {
  flex-shrink: 0;
}
html.sidebar-collapsed .sidebar-toggle {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.sidebar-nav {
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.sidebar-item.active {
  background: rgba(8, 145, 178, 0.18);
  border-left-color: #0891B2;
  color: #fff;
}
.sidebar-item svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}
.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
html.sidebar-collapsed .sidebar-item {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  border-left: 0;
}
html.sidebar-collapsed .sidebar-item.active {
  border-left: 0;
  background: rgba(8, 145, 178, 0.22);
  box-shadow: inset 3px 0 0 #0891B2;
}
html.sidebar-collapsed .sidebar-label {
  display: none;
}
.sidebar-user {
  margin-top: auto;
  padding: 12px 0 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-user-info {
  padding: 4px 16px 10px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.8rem;
  line-height: 1.3;
}
.sidebar-user-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-role {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sidebar-logout-form {
  margin: 0;
  padding: 0;
}
.sidebar-logout {
  width: 100%;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
html.sidebar-collapsed .sidebar-user-info {
  display: none;
}
.app-content {
  flex: 1 1 auto;
  min-width: 0; /* allow flex child to shrink so inner grids can scroll */
}
