/*
 * Fonts are self-hosted (M-22, GDPR): no external font/icon CDN requests.
 * @font-face rules live in wwwroot/fonts/fonts.css (loaded from index.html).
 * The --font-primary (Bellefair) / --font-secondary (Montserrat) stacks in
 * variables.css carry a full system-font fallback (Iowan Old Style, Palatino,
 * Georgia, serif / Avenir Next, Century Gothic, Segoe UI, system-ui) so text
 * still renders if a web font is missing.
 */
@import url('variables.css?v=f3e509b');

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Remove default focus outline from non-interactive elements */
h1:focus, h2:focus, h3:focus, h4:focus, h5:focus, h6:focus,
div:focus, section:focus, article:focus, main:focus, aside:focus,
p:focus, span:focus {
  outline: none;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-secondary);
  font-size: var(--body-size);
  line-height: var(--body-line-height);
  color: var(--text-dark);
  background-color: var(--neutral-cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
/* Bellefair has one weight: hierarchy comes from size and space, never a
 * synthesised bold (DESIGN.md, Single Weight Rule). */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-primary);
  font-weight: var(--font-regular);
  font-synthesis: none;
  line-height: var(--heading-line-height);
  color: var(--text-dark);
  margin-bottom: var(--space-sm);
  text-wrap: balance;
}

h1 { font-size: var(--h1-size); }
h2 { font-size: var(--h2-size); }
h3 { font-size: var(--h3-size); }
h4 { font-size: var(--h4-size); }

p {
  margin-bottom: var(--space-sm);
  color: var(--text-medium);
  text-wrap: pretty;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-primary-dark);
}

/* Browser surfaces themed from the palette */
::selection {
  background-color: rgba(var(--brand-primary-rgb), 0.2);
  color: var(--text-dark);
}

/* Keyboard focus ring (DESIGN.md). Components that style their own :focus
 * state keep it; dark bands override with --brand-focus-on-dark. */
:focus-visible {
  outline: 2px solid var(--brand-focus);
  outline-offset: 2px;
}

/* Buttons: every button is a pill (--radius-button), including component-scoped
 * ones; the base rule below covers unstyled <button> elements. */
button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"] {
  border-radius: var(--radius-button);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-secondary);
  font-size: var(--body-size);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  min-height: 48px;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: var(--neutral-white);
  border-color: var(--brand-primary);
}

.btn-primary:hover {
  background-color: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
}

.btn-outline {
  background-color: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-outline:hover {
  background-color: var(--brand-primary);
  color: var(--neutral-white);
}

.btn-text {
  background: none;
  border: none;
  color: var(--brand-primary);
  padding: var(--space-xs) var(--space-sm);
}

.btn-text:hover {
  color: var(--brand-primary-dark);
}

/*
 * Global .btn-secondary / .btn-danger / .btn-success and the .btn-sm / .btn-lg
 * size modifiers. Bootstrap previously supplied these; after its removal the
 * only definitions lived in a few components' scoped CSS, so pages without a
 * matching scoped rule rendered these buttons unstyled (e.g. Profile.razor's
 * marketing Grant/Withdraw .btn-secondary buttons, AdminEmployeeSchedule's
 * .btn-sm). Defined here with design-system tokens so they apply everywhere.
 * Components that already define their own scoped variant keep it (scoped
 * selectors have higher specificity than these global utilities).
 */
.btn-secondary {
  background-color: var(--neutral-white);
  color: var(--text-dark);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--neutral-gray);
}

.btn-danger {
  background-color: var(--error-red);
  color: var(--neutral-white);
  border-color: var(--error-red);
}

.btn-danger:hover {
  background-color: color-mix(in srgb, var(--error-red) 82%, var(--espresso));
  border-color: color-mix(in srgb, var(--error-red) 82%, var(--espresso));
}

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

.btn-success:hover {
  background-color: color-mix(in srgb, var(--success-green) 82%, var(--espresso));
  border-color: color-mix(in srgb, var(--success-green) 82%, var(--espresso));
}

/* Size modifiers -- apply on top of any .btn-* colour variant. */
.btn-sm {
  min-height: 36px;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--small-size);
}

.btn-lg {
  min-height: 56px;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--h4-size);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form Inputs */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: var(--font-medium);
  color: var(--text-dark);
}

.form-input {
  width: 100%;
  padding: var(--space-sm);
  font-size: var(--body-size);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background-color: var(--neutral-white);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.2);
}

.form-input.error {
  border-color: var(--error-red);
}

.form-error {
  color: var(--error-red);
  font-size: var(--small-size);
  margin-top: var(--space-xs);
}

.form-select {
  width: 100%;
  padding: var(--space-sm);
  font-size: var(--body-size);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background-color: var(--neutral-white);
  cursor: pointer;
}

/*
 * Global .form-control. Bootstrap supplied this before its removal; afterwards
 * only some admin pages' scoped CSS defined it, leaving pages without a scoped
 * rule (e.g. AdminEmployeeSchedule.razor, which has no .razor.css) with
 * unstyled inputs. Token-based, mirrors the look of the scoped admin
 * .form-control and the app.css .form-input. Components with their own scoped
 * .form-control keep it (higher specificity).
 */
.form-control {
  width: 100%;
  padding: var(--space-sm);
  font-size: var(--body-size);
  color: var(--text-dark);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background-color: var(--neutral-white);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.2);
}

.form-control:disabled {
  background-color: var(--neutral-cream);
  cursor: not-allowed;
}

/* Cards */
.card {
  background-color: var(--neutral-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-md);
  transition: box-shadow var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

/*
 * Alerts. Bootstrap supplied the .alert base plus colour variants before its
 * removal. Several components define a scoped .alert / .alert-success /
 * .alert-error, but some only define a variant without the base (e.g.
 * AdminLogin.razor.css defines .alert-danger but not the base .alert, so the
 * `<div class="alert alert-danger">` lost its layout). These global rules give
 * every page a token-based base + variants; scoped definitions still win where
 * present (higher specificity).
 */
.alert {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  font-size: var(--small-size);
}

.alert i {
  font-size: var(--h4-size);
}

.alert-success {
  background-color: color-mix(in srgb, var(--success-green) 10%, var(--surface-raised));
  color: var(--success-green);
}

.alert-error,
.alert-danger {
  background-color: color-mix(in srgb, var(--error-red) 10%, var(--surface-raised));
  color: var(--error-red);
}

.alert-warning {
  background-color: color-mix(in srgb, var(--warning-orange) 10%, var(--surface-raised));
  color: var(--warning-orange);
}

.alert-info {
  background-color: var(--surface-alt);
  color: var(--text-dark);
}

/* Modal */
.custom-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(var(--espresso-rgb), 0.5);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.custom-modal {
  background-color: var(--neutral-white);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: var(--z-modal);
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--neutral-gray-light);
}

.modal-body {
  padding: var(--space-md);
}

.modal-footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-md);
  border-top: 1px solid var(--neutral-gray-light);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-medium);
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-dark);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--neutral-white);
  min-width: 300px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

.toast.success {
  background-color: var(--success-green);
}

.toast.error {
  background-color: var(--error-red);
}

.toast.warning {
  background-color: var(--warning-orange);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--neutral-gray-light);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

/* Section Base */
.section {
  padding: var(--space-xxxl) var(--space-md);
}

.section-title {
  text-align: center;
  margin-bottom: var(--space-xl);
  letter-spacing: 2px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-brand { color: var(--brand-primary); }
.text-muted { color: var(--text-medium); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* --breakpoint-tablet (1023px) */
@media (max-width: 1023px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* --breakpoint-mobile (767px) */
@media (max-width: 767px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Blazor Error UI */
#blazor-error-ui {
  color-scheme: light only;
  background: var(--error-red);
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: var(--space-sm) var(--space-md);
  position: fixed;
  width: 100%;
  z-index: 1000;
  color: white;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: var(--space-md);
  top: var(--space-sm);
}

.blazor-error-boundary {
  background: var(--error-red);
  padding: var(--space-md);
  color: white;
  border-radius: var(--radius-md);
}

/* Loading Progress */
.loading-progress {
  position: relative;
  display: block;
  width: 8rem;
  height: 8rem;
  margin: 20vh auto 1rem auto;
}

.loading-progress circle {
  fill: none;
  stroke: var(--neutral-gray-light);
  stroke-width: 0.6rem;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
}

.loading-progress circle:last-child {
  stroke: var(--brand-primary);
  stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
  transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
  position: absolute;
  text-align: center;
  font-weight: var(--font-bold);
  inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
  color: var(--brand-primary);
}

.loading-progress-text:after {
  content: var(--blazor-load-percentage-text, "Loading");
}

/* Cookie Consent Banner */
.cookie-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--neutral-white);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: var(--z-modal);
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.cookie-consent-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
}

.cookie-consent-text h3 {
  font-family: var(--font-primary);
  font-size: var(--h4-size);
  color: var(--text-dark);
  margin-bottom: var(--space-xs);
}

.cookie-consent-text p {
  color: var(--text-medium);
  font-size: var(--body-size);
  line-height: 1.5;
  margin-bottom: var(--space-xs);
}

.cookie-learn-more {
  color: var(--brand-primary);
  font-size: var(--small-size);
  cursor: pointer;
  text-decoration: underline;
}

.cookie-learn-more:hover {
  color: var(--brand-primary-dark);
}

.cookie-details {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--neutral-gray-light);
}

.cookie-category {
  margin-bottom: var(--space-md);
}

.cookie-category:last-child {
  margin-bottom: 0;
}

.cookie-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}

.cookie-category-name {
  font-weight: var(--font-semibold);
  color: var(--text-dark);
}

.cookie-always-on {
  font-size: var(--small-size);
  color: var(--success-green);
  font-weight: var(--font-medium);
}

.cookie-category-description {
  font-size: var(--small-size);
  color: var(--text-medium);
  margin: 0;
}

/* Cookie Toggle Switch */
.cookie-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.cookie-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cookie-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--neutral-gray-light);
  border-radius: 26px;
  transition: background-color var(--transition-fast);
}

.cookie-toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--neutral-white);
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cookie-toggle input:checked + .cookie-toggle-slider {
  background-color: var(--brand-primary);
}

.cookie-toggle input:checked + .cookie-toggle-slider:before {
  transform: translateX(22px);
}

.cookie-consent-buttons {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-cookie-reject {
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-secondary);
  font-size: var(--body-size);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  border: 2px solid var(--neutral-gray);
  background-color: transparent;
  color: var(--text-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.btn-cookie-reject:hover {
  border-color: var(--text-dark);
  color: var(--text-dark);
}

.btn-cookie-accept {
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-secondary);
  font-size: var(--body-size);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  border: 2px solid var(--brand-primary);
  background-color: var(--brand-primary);
  color: var(--neutral-white);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.btn-cookie-accept:hover {
  background-color: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
}

/* --breakpoint-mobile (767px) */
@media (max-width: 767px) {
  .cookie-consent-content {
    padding: var(--space-md);
  }

  .cookie-consent-buttons {
    flex-direction: column;
  }

  .btn-cookie-reject,
  .btn-cookie-accept {
    width: 100%;
    text-align: center;
  }
}
