/**
 * Spedition Mayr — Authelia portal theme
 * Matches design/ (Mayr Sped). Overrides MUI defaults with !important.
 */

@import url("https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,700&display=swap");

:root {
  --mayr-green: #008b3b;
  --mayr-green-hover: #007a33;
  --mayr-green-tint: #e6f4ec;
  --mayr-green-tint-soft: rgba(0, 139, 59, 0.05);
  --mayr-bg-page: #f9fafb;
  --mayr-bg-card: #ffffff;
  --mayr-border: #e5e7eb;
  --mayr-border-strong: #d1d5db;
  --mayr-ink: #111827;
  --mayr-ink-muted: #4b5563;
  --mayr-ink-label: #374151;
  --mayr-radius-sm: 0.375rem;
  --mayr-radius-xl: 0.75rem;
  --mayr-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --mayr-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --mayr-font: "Lato", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html,
body,
#root {
  font-family: var(--mayr-font) !important;
  background: linear-gradient(to bottom right, #f9fafb, #f3f4f6) !important;
  background-color: var(--mayr-bg-page) !important;
  color: var(--mayr-ink) !important;
}

body {
  min-height: 100vh !important;
}

.MuiTypography-root,
.MuiInputBase-input,
.MuiFormLabel-root,
.MuiFormHelperText-root,
.MuiButton-root,
.MuiCheckbox-root,
label,
p,
span,
div,
button,
input {
  font-family: var(--mayr-font) !important;
}

.MuiTypography-root,
.MuiTypography-body1,
.MuiTypography-body2 {
  color: var(--mayr-ink) !important;
}

.MuiTypography-colorTextSecondary,
.MuiFormHelperText-root {
  color: var(--mayr-ink-muted) !important;
}

.MuiCard-root,
.MuiPaper-root {
  background: var(--mayr-bg-card) !important;
  border-radius: var(--mayr-radius-xl) !important;
  box-shadow: var(--mayr-shadow-lg) !important;
  border: 1px solid var(--mayr-border) !important;
}

img[alt="Logo"],
img[alt="Authelia"],
img[src*="logo.png"],
img[src*="logo"] {
  /* Authelia hard-codes width: 64px via MUI sx — override for Mayr wordmark */
  width: auto !important;
  max-width: min(320px, 85vw) !important;
  height: 96px !important; /* matches portal login h-24 */
  max-height: none !important;
  object-fit: contain !important;
  margin: 0.5rem auto 1rem !important;
  display: block !important;
}

/* Parent flex/grid cells that shrink the logo */
#root img[alt="Logo"],
.MuiGrid-root > img,
.MuiBox-root > img[alt="Logo"] {
  width: auto !important;
  height: 96px !important;
}

/* Primary actions — fight MUI emotion specificity */
button.MuiButton-containedPrimary,
.MuiButton-contained.MuiButton-colorPrimary,
.MuiButton-root.MuiButton-containedPrimary {
  background-color: #008b3b !important;
  background: #008b3b !important;
  color: #fff !important;
}

button.MuiButton-containedPrimary:hover,
.MuiButton-contained.MuiButton-colorPrimary:hover {
  background-color: #007a33 !important;
  background: #007a33 !important;
}

.MuiOutlinedInput-root {
  border-radius: var(--mayr-radius-sm) !important;
  background: var(--mayr-bg-card) !important;
}

.MuiOutlinedInput-notchedOutline {
  border-color: var(--mayr-border-strong) !important;
}

.MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline {
  border-color: var(--mayr-green) !important;
}

.MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline {
  border-color: var(--mayr-green) !important;
  border-width: 1px !important;
  box-shadow: 0 0 0 1px var(--mayr-green) !important;
}

.MuiInputLabel-root.Mui-focused {
  color: var(--mayr-green) !important;
}

.MuiInputBase-input {
  color: var(--mayr-ink) !important;
  caret-color: var(--mayr-green) !important;
}

.MuiButton-containedPrimary {
  background-color: var(--mayr-green) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  text-transform: none !important;
  border-radius: var(--mayr-radius-sm) !important;
  box-shadow: var(--mayr-shadow-sm) !important;
  padding: 0.5rem 1rem !important;
}

.MuiButton-containedPrimary:hover {
  background-color: var(--mayr-green-hover) !important;
}

.MuiButton-containedPrimary:focus-visible {
  outline: 2px solid var(--mayr-green) !important;
  outline-offset: 2px !important;
}

.MuiButton-textPrimary,
.MuiButton-text,
a.MuiTypography-root,
.MuiLink-root {
  color: var(--mayr-green) !important;
  text-transform: none !important;
  font-weight: 600 !important;
}

.MuiButton-textPrimary:hover,
.MuiButton-text:hover,
.MuiLink-root:hover {
  background-color: var(--mayr-green-tint) !important;
  color: var(--mayr-green-hover) !important;
}

.MuiCheckbox-root {
  color: var(--mayr-border-strong) !important;
}

.MuiCheckbox-root.Mui-checked,
.MuiCheckbox-colorPrimary.Mui-checked {
  color: var(--mayr-green) !important;
}

.MuiCircularProgress-colorPrimary,
.MuiLinearProgress-barColorPrimary {
  color: var(--mayr-green) !important;
  background-color: var(--mayr-green) !important;
}

.MuiAlert-standardError {
  background-color: #fee2e2 !important;
  color: #b91c1c !important;
}

.MuiAlert-standardInfo {
  background-color: #dbeafe !important;
  color: #1d4ed8 !important;
}

.MuiSwitch-switchBase.Mui-checked {
  color: var(--mayr-green) !important;
}

.MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track {
  background-color: var(--mayr-green) !important;
}

.MuiTab-root.Mui-selected {
  color: var(--mayr-green) !important;
}

.MuiTabs-indicator {
  background-color: var(--mayr-green) !important;
}

/* Soften Authelia footer branding */
body a[href*="authelia.com"],
body a[href*="github.com/authelia"] {
  color: var(--mayr-ink-muted) !important;
  font-weight: 400 !important;
  font-size: 0.75rem !important;
}

/* Dark mode (theme: auto) */
@media (prefers-color-scheme: dark) {
  :root {
    --mayr-bg-page: #111827;
    --mayr-bg-card: #1f2937;
    --mayr-border: #374151;
    --mayr-border-strong: #4b5563;
    --mayr-ink: #ffffff;
    --mayr-ink-muted: #9ca3af;
    --mayr-ink-label: #d1d5db;
  }

  html,
  body,
  #root {
    background: linear-gradient(to bottom right, #111827, #1f2937) !important;
  }

  .MuiOutlinedInput-root {
    background: #374151 !important;
  }

  .MuiButton-textPrimary:hover,
  .MuiButton-text:hover,
  .MuiLink-root:hover {
    background-color: rgba(0, 139, 59, 0.15) !important;
  }
}
