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;
  /* Guards against the .full-bleed trick (width:100vw) adding a stray
     horizontal scrollbar on the page itself when a vertical scrollbar is
     present, since vw includes its width in most browsers. */
  overflow-x: hidden;
}

/* ==========================================================================
   TimeSheetEasy theming
   Default theme is "red-black" (red / black / white). Additional themes are
   selected by the user and applied via a data-theme attribute on <html>.
   ========================================================================== */

:root,
[data-theme="red-black"] {
  --tse-primary: #c8102e;
  --tse-primary-dark: #8f0c20;
  --tse-primary-contrast: #ffffff;
  --tse-bg: #f7f7f8;
  --tse-surface: #ffffff;
  --tse-text: #161616;
  --tse-text-muted: #5a5a5a;
  --tse-border: #dcdcdc;
  --tse-border-strong: #adadad;
  --tse-header-bg: #161616;
  --tse-header-text: #ffffff;
}

[data-theme="midnight-blue"] {
  --tse-primary: #1d4ed8;
  --tse-primary-dark: #1e3a8a;
  --tse-primary-contrast: #ffffff;
  --tse-bg: #f5f7fb;
  --tse-surface: #ffffff;
  --tse-text: #111827;
  --tse-text-muted: #6b7280;
  --tse-border: #dbe2ea;
  --tse-border-strong: #94a3b8;
  --tse-header-bg: #111827;
  --tse-header-text: #ffffff;
}

[data-theme="forest-green"] {
  --tse-primary: #15803d;
  --tse-primary-dark: #14532d;
  --tse-primary-contrast: #ffffff;
  --tse-bg: #f5f8f6;
  --tse-surface: #ffffff;
  --tse-text: #14201a;
  --tse-text-muted: #5c6b63;
  --tse-border: #d7e3db;
  --tse-border-strong: #86a892;
  --tse-header-bg: #14201a;
  --tse-header-text: #ffffff;
}

[data-theme="royal-violet"] {
  --tse-primary: #7c3aed;
  --tse-primary-dark: #5b21b6;
  --tse-primary-contrast: #ffffff;
  --tse-bg: #f7f6fb;
  --tse-surface: #ffffff;
  --tse-text: #1e1b2e;
  --tse-text-muted: #635e77;
  --tse-border: #e1def0;
  --tse-border-strong: #a996d1;
  --tse-header-bg: #1e1b2e;
  --tse-header-text: #ffffff;
}

[data-theme="slate-dark"] {
  --tse-primary: #e11d48;
  --tse-primary-dark: #9f1239;
  --tse-primary-contrast: #ffffff;
  --tse-bg: #0f172a;
  --tse-surface: #1e293b;
  --tse-text: #e2e8f0;
  --tse-text-muted: #94a3b8;
  --tse-border: #334155;
  --tse-border-strong: #64748b;
  --tse-header-bg: #020617;
  --tse-header-text: #e2e8f0;
}

body {
  background-color: var(--tse-bg);
  color: var(--tse-text);
}

a {
  color: var(--tse-primary);
}

a:hover {
  color: var(--tse-primary-dark);
}

.tse-navbar {
  background-color: var(--tse-header-bg) !important;
  border-bottom: 3px solid var(--tse-primary);
}

.tse-navbar .navbar-brand,
.tse-navbar .nav-link {
  color: var(--tse-header-text) !important;
}

.tse-navbar .nav-link:hover {
  color: var(--tse-primary) !important;
}

.tse-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.tse-brand img {
  height: 32px;
  width: 32px;
}

.btn-primary {
  background-color: var(--tse-primary);
  border-color: var(--tse-primary);
  color: var(--tse-primary-contrast);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--tse-primary-dark);
  border-color: var(--tse-primary-dark);
  color: var(--tse-primary-contrast);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--tse-border);
  color: var(--tse-text);
}

.btn-secondary:hover {
  background-color: var(--tse-border);
  color: var(--tse-text);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.data-table {
  background-color: var(--tse-surface);
}

.data-table thead th {
  border-bottom: 3px solid var(--tse-primary);
  color: var(--tse-text);
}

.row-actions {
  white-space: nowrap;
}

.row-actions a,
.row-actions .row-action-btn {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.25rem 0.6rem;
  background: none;
  border: 1px solid var(--tse-border);
  border-radius: 0.25rem;
  color: var(--tse-text);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.4;
  cursor: pointer;
  font-family: inherit;
}

.row-actions a:last-child,
.row-actions .row-action-btn:last-child {
  margin-right: 0;
}

.row-actions a:hover,
.row-actions .row-action-btn:hover {
  background-color: var(--tse-border);
  color: var(--tse-text);
}

.row-actions a.month-view-btn {
  background-color: color-mix(in srgb, var(--tse-primary) 18%, white);
  border-color: color-mix(in srgb, var(--tse-primary) 35%, white);
  color: var(--tse-primary-dark);
}

.row-actions a.month-view-btn:hover {
  background-color: color-mix(in srgb, var(--tse-primary) 30%, white);
  border-color: var(--tse-primary);
  color: var(--tse-primary-dark);
}

.row-actions .row-action-btn:disabled {
  color: var(--tse-text-muted);
  cursor: default;
}

.row-actions .row-action-btn:disabled:hover {
  background: none;
}

/* Bootstrap's .table hardcodes a near-black text/border color that doesn't
   follow our theme variables, so row data is unreadable against the dark
   surface in this theme even though the header row (.data-table thead th)
   already uses --tse-text. */
[data-theme="slate-dark"] .table {
  --bs-table-color: var(--tse-text);
  --bs-table-bg: transparent;
  --bs-table-striped-color: var(--tse-text);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.05);
  --bs-table-active-color: var(--tse-text);
  --bs-table-active-bg: rgba(255, 255, 255, 0.1);
  --bs-table-hover-color: var(--tse-text);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.075);
  color: var(--tse-text);
  border-color: var(--tse-border-strong);
}

.detail-list {
  background-color: var(--tse-surface);
  border: 1px solid var(--tse-border);
  border-radius: 0.5rem;
  padding: 1rem 1.5rem;
}

.detail-list dt {
  color: var(--tse-text-muted);
  font-weight: 600;
}

.detail-list dd {
  margin-bottom: 0.75rem;
}

.auth-card {
  max-width: 420px;
  margin: 2rem auto;
  background-color: var(--tse-surface);
  border: 1px solid var(--tse-border);
  border-radius: 0.5rem;
  padding: 2rem;
}

/* Bootstrap's .modal-content defaults to a white background regardless of
   theme, while its text still inherits --tse-text from body. In dark
   themes that leaves light text on a white box, so it needs its own
   surface/text/border colors just like .auth-card and .detail-list. */
.modal-content {
  background-color: var(--tse-surface);
  color: var(--tse-text);
}

.modal-header,
.modal-footer {
  border-color: var(--tse-border);
}

[data-theme="slate-dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Bootstrap's .card defaults to a white background and its own header/border
   colors regardless of theme, while its text still inherits --tse-text from
   body - same problem already fixed for .modal-content. */
.card {
  background-color: var(--tse-surface);
  color: var(--tse-text);
  border-color: var(--tse-border);
}

.card-header {
  background-color: color-mix(in srgb, var(--tse-primary) 12%, var(--tse-surface));
  border-color: var(--tse-border);
}

.signup-tile {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.signup-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border-color: var(--tse-primary);
}

.form-hint {
  color: var(--tse-text-muted);
  font-size: 0.9rem;
}

.theme-swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.searchable-select {
  position: relative;
}

.searchable-select-menu {
  position: absolute;
  z-index: 1050;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  max-height: 220px;
  overflow-y: auto;
  background-color: var(--tse-surface);
  border: 1px solid var(--tse-border);
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.searchable-select-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.375rem 0.75rem;
  background: none;
  border: none;
  color: var(--tse-text);
  cursor: pointer;
}

.searchable-select-item:hover,
.searchable-select-item:focus {
  background-color: var(--tse-bg);
  color: var(--tse-primary);
  outline: none;
}

.searchable-select-empty {
  padding: 0.375rem 0.75rem;
  color: var(--tse-text-muted);
}

.month-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.month-nav-title {
  grid-column: 2;
  margin: 0;
  text-align: center;
}

.month-nav-prev {
  grid-column: 1;
  justify-self: start;
}

.month-nav-next {
  grid-column: 3;
  justify-self: end;
}

.month-view-table {
  background-color: var(--tse-surface);
  table-layout: fixed;
  border-color: var(--tse-border-strong);
}

.month-view-table th,
.month-view-table td {
  border-color: var(--tse-border-strong);
}

.month-view-table th {
  text-align: center;
  border-bottom: 3px solid var(--tse-primary);
}

.month-view-cell {
  height: 4.5rem;
  text-align: center;
  vertical-align: middle;
}

.month-view-table td.month-view-cell-today {
  background-color: color-mix(in srgb, var(--tse-surface) 90%, black);
}

.month-view-btn {
  background-color: color-mix(in srgb, var(--tse-primary) 18%, white);
  border-color: color-mix(in srgb, var(--tse-primary) 35%, white);
  color: var(--tse-primary-dark);
}

.month-view-btn:hover,
.month-view-btn:focus {
  background-color: color-mix(in srgb, var(--tse-primary) 30%, white);
  border-color: var(--tse-primary);
  color: var(--tse-primary-dark);
}

.month-view-day {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  padding: 0;
}

.month-view-day-has-data {
  font-size: 1.15em;
  font-weight: 700;
}

.leave-schedule-cell {
  height: auto;
  min-height: 4.5rem;
  text-align: left;
  vertical-align: top;
  padding: 0.4rem;
}

.leave-schedule-day-number {
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.25rem;
}

.leave-schedule-entry {
  font-size: 0.8rem;
  line-height: 1.3;
  word-break: break-word;
}

.month-view-table td.wfh-report-weekend {
  background-color: color-mix(in srgb, var(--tse-surface) 85%, #808080);
}

.month-view-table td.wfh-report-has-office {
  background-color: color-mix(in srgb, var(--tse-surface) 82%, #2e7d32);
}

.month-view-table td.leave-schedule-has-leave {
  background-color: color-mix(in srgb, var(--tse-surface) 82%, #2e7d32);
}

.wfh-report-name {
  text-align: center;
}

/* Bootstrap's .table forces width:100%, which - combined with a header row
   that has one column per user - squeezes every column (including the date
   column) down to fit the viewport instead of letting the table grow and
   scroll horizontally. Overriding to width:auto lets columns size to their
   content; the wrapping div's overflow-x:auto handles the scrolling. */
.time-grid-table {
  width: auto;
  min-width: 100%;
}

.time-grid-date-col {
  min-width: 160px;
  white-space: nowrap;
}

.time-grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--tse-surface);
}

.time-grid-table thead th.time-grid-self-col {
  background-color: color-mix(in srgb, var(--tse-primary) 12%, var(--tse-surface));
}

.time-grid-cell {
  vertical-align: top;
  min-width: 130px;
}

.time-grid-entry {
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: nowrap;
}

.time-grid-entry-total {
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: nowrap;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--tse-border);
}

.time-grid-self-col {
  /* Opaque (mixed with the surface color, not transparent) so it still
     looks right on the sticky header row, where a transparent tint would
     let scrolled-past content show through underneath. */
  background-color: color-mix(in srgb, var(--tse-primary) 12%, var(--tse-surface));
}

.time-grid-weekend-row {
  background-color: color-mix(in srgb, var(--tse-text) 6%, transparent);
}

/* Breaks a page's content out of the centered, max-width .container from
   MainLayout so it can use the full viewport width - needed for wide
   pivot-style tables like the Time Grid report. */
.full-bleed {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  padding-left: 1rem;
  padding-right: 1rem;
  box-sizing: border-box;
}

.month-view-hours {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--tse-text-muted);
}

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}

.toast-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  color: #ffffff;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.25);
  animation: tse-toast-in 0.2s ease-out;
}

.toast-success {
  background-color: #198754;
}

.toast-error {
  background-color: #dc3545;
}

.toast-message {
  flex: 1;
  word-break: break-word;
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

@keyframes tse-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#reportTabs {
  border-bottom-width: 2px;
  border-bottom-color: var(--tse-border-strong);
}

#reportTabs .nav-link {
  border-width: 2px;
  border-color: transparent transparent var(--tse-border-strong) transparent;
  color: var(--tse-text);
  font-weight: 600;
}

#reportTabs .nav-link:hover {
  border-color: var(--tse-border-strong) var(--tse-border-strong) var(--tse-border-strong) var(--tse-border-strong);
}

#reportTabs .nav-link.active {
  border-color: var(--tse-primary) var(--tse-primary) var(--tse-surface) var(--tse-primary);
  color: var(--tse-primary);
}
