/* Webmail (Bulwark) no estilo do O Teu Ginásio (shadcn/ui "luma", fundo preto).
   Injetado pelo nginx em todas as páginas de mail.oteuginasio.com.
   1) paleta, letra e raios   2) componentes   3) ecrã de entrada */

/* ------------------------------------------------ 1) paleta, letra, raios */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/_oteuginasio/onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/_oteuginasio/onest-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* As mesmas cores do painel (globals.css .dark), seja qual for o tema escolhido
   no webmail. !important para ganhar também às cores que o Bulwark põe inline. */
html:root,
html.dark,
html body {
  color-scheme: dark;
  --color-background: oklch(0 0 0) !important;
  --color-foreground: oklch(0.985 0 0) !important;
  --color-card: oklch(0.205 0 0) !important;
  --color-card-foreground: oklch(0.985 0 0) !important;
  --color-popover: oklch(0.205 0 0) !important;
  --color-popover-foreground: oklch(0.985 0 0) !important;
  --color-primary: oklch(0.922 0 0) !important;
  --color-primary-foreground: oklch(0.205 0 0) !important;
  --color-secondary: oklch(0.269 0 0) !important;
  --color-secondary-foreground: oklch(0.985 0 0) !important;
  --color-muted: oklch(0.269 0 0) !important;
  --color-muted-foreground: oklch(0.708 0 0) !important;
  --color-accent: oklch(0.269 0 0) !important;
  --color-accent-foreground: oklch(0.985 0 0) !important;
  --color-destructive: oklch(0.704 0.191 22.216) !important;
  --color-destructive-foreground: oklch(0.985 0 0) !important;
  --color-border: oklch(1 0 0 / 10%) !important;
  --color-input: oklch(1 0 0 / 15%) !important;
  --color-ring: oklch(0.556 0 0) !important;
  --color-sidebar: oklch(0 0 0) !important;
  --color-sidebar-foreground: oklch(0.985 0 0) !important;
  --color-sidebar-border: oklch(1 0 0 / 10%) !important;
  --color-sidebar-accent: oklch(0.269 0 0) !important;
  --color-sidebar-accent-foreground: oklch(0.985 0 0) !important;
  --color-selection: oklch(1 0 0 / 9%) !important;
  --color-selection-foreground: oklch(0.985 0 0) !important;
  --color-unread: oklch(0.922 0 0) !important;
  --color-info: oklch(0.87 0 0) !important;
  --color-chart-1: oklch(0.87 0 0) !important;

  /* Raios do painel (--radius 0.625rem, escala do luma). */
  --radius-sm: 0.375rem !important;
  --radius-md: 0.5rem !important;
  --radius-lg: 0.625rem !important;
  --radius-xl: 0.875rem !important;
  --radius-2xl: 1.625rem !important;

  --font-sans: "Onest", "Onest Fallback", ui-sans-serif, system-ui, sans-serif !important;
  --font-geist-sans: "Onest", ui-sans-serif, system-ui, sans-serif !important;
}
html body {
  background: var(--color-background);
  font-family: var(--font-sans);
}
::selection {
  background: oklch(1 0 0 / 20%);
}
* {
  scrollbar-width: thin;
  scrollbar-color: oklch(1 0 0 / 15%) transparent;
}

/* ---------------------------------------------------------- 2) componentes */

/* Campos de texto: pílula, sem contorno, fundo input/50 (como o <Input> do painel). */
input:is([type="text"], [type="email"], [type="password"], [type="search"], [type="url"],
    [type="number"], [type="tel"], [type="date"], [type="time"], [type="datetime-local"],
    :not([type]))[class~="border"]:not(.sr-only),
select[class~="border"] {
  border-radius: 9999px !important;
  border-color: transparent !important;
  background-color: color-mix(in oklch, var(--color-input) 50%, transparent) !important;
  box-shadow: none !important;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea[class~="border"] {
  border-radius: 1.25rem !important;
  border-color: transparent !important;
  background-color: color-mix(in oklch, var(--color-input) 50%, transparent) !important;
  box-shadow: none !important;
}
input[class~="border"]:not(.sr-only):focus,
select[class~="border"]:focus,
textarea[class~="border"]:focus {
  border-color: var(--color-ring) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-ring) 30%, transparent) !important;
}
input::placeholder,
textarea::placeholder {
  color: var(--color-muted-foreground);
}

/* Botões (o <Button> do Bulwark é inline-flex + justify-center): pílula, sem sombra. */
:is(button, a)[class*="inline-flex"][class*="justify-center"]:not([role="switch"]):not([role="checkbox"]),
button[type="submit"] {
  border-radius: 9999px !important;
  box-shadow: none !important;
}

/* Caixas de seleção: 16px, cantos de 5px, fundo input/90; marcada = primária. */
input[type="checkbox"]:not(.sr-only) {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  display: inline-grid;
  place-content: center;
  border: 1px solid transparent !important;
  border-radius: 5px !important;
  background: color-mix(in oklch, var(--color-input) 90%, transparent) no-repeat center / 0.75rem !important;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="checkbox"]:not(.sr-only):checked {
  background-color: var(--color-primary) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23262626' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") !important;
}
input[type="checkbox"]:not(.sr-only):focus-visible,
input[type="radio"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-ring) 30%, transparent);
}
/* As caixas desenhadas pelo próprio Bulwark (input escondido + span). */
input.sr-only[type="checkbox"] + span {
  border-color: transparent !important;
  border-radius: 5px !important;
  background-color: color-mix(in oklch, var(--color-input) 90%, transparent) !important;
}
input.sr-only[type="checkbox"]:checked + span {
  background-color: var(--color-primary) !important;
  color: var(--color-primary-foreground) !important;
}
input[type="radio"] {
  accent-color: var(--color-primary);
}

/* Interruptores: desligado = input/90 com bolinha clara; ligado = primária. */
button[role="switch"] {
  background-color: color-mix(in oklch, var(--color-input) 90%, transparent) !important;
}
button[role="switch"][aria-checked="true"] {
  background-color: var(--color-primary) !important;
}
button[role="switch"] > span {
  background-color: var(--color-foreground) !important;
  box-shadow: 0 1px 2px oklch(0 0 0 / 30%);
}
button[role="switch"][aria-checked="true"] > span {
  background-color: var(--color-primary-foreground) !important;
}
button[role="switch"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-ring) 30%, transparent) !important;
}

/* Sliders: calha fina e botão redondo, como o <Slider> do painel. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 1rem;
  background: transparent;
  accent-color: var(--color-primary);
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 0.375rem;
  border-radius: 9999px;
  background: var(--color-muted);
}
input[type="range"]::-moz-range-track {
  height: 0.375rem;
  border-radius: 9999px;
  background: var(--color-muted);
}
input[type="range"]::-moz-range-progress {
  height: 0.375rem;
  border-radius: 9999px;
  background: var(--color-primary);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1rem;
  height: 1rem;
  margin-top: -0.3125rem;
  border-radius: 9999px;
  border: 2px solid var(--color-primary);
  background: var(--color-background);
}
input[type="range"]::-moz-range-thumb {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 9999px;
  border: 2px solid var(--color-primary);
  background: var(--color-background);
}

/* Contentores: cartões e diálogos com anel subtil em vez de borda carregada. */
.bg-card[class*="border"],
[role="dialog"][class*="border"] {
  border-color: oklch(1 0 0 / 10%) !important;
}
[role="menu"],
[role="listbox"] {
  border-radius: var(--radius-xl) !important;
}
[role="menuitem"],
[role="option"] {
  border-radius: var(--radius-md);
}

/* ------------------------------------------------------ 3) ecrã de entrada */
.min-h-screen:has(#username):has(#password) {
  background: #000 !important;
}
/* Fora: botão de tema, aviso de versão, título "O Teu Ginásio — Correio",
   "Webmail" e o código 2FA. */
.min-h-screen:has(#username):has(#password) > .absolute,
.min-h-screen:has(#username):has(#password) .rounded-2xl ~ .mt-6,
.min-h-screen:has(#username):has(#password) .mt-6:has(a),
.min-h-screen:has(#username):has(#password) h1,
.min-h-screen:has(#username):has(#password) h1 + p,
.min-h-screen:has(#username):has(#password) form fieldset > button[type="button"],
.min-h-screen:has(#username):has(#password) form fieldset > div:has(input[autocomplete="one-time-code"]),
.min-h-screen:has(#username):has(#password) form fieldset > div:has(input[inputmode="numeric"]) {
  display: none !important;
}

/* Textos em português de Portugal. */
.min-h-screen:has(#username):has(#password) div:has(> div > #password) > label,
.min-h-screen:has(#username):has(#password) label:has(input[type="checkbox"]) > span:last-child {
  font-size: 0 !important;
}
.min-h-screen:has(#username):has(#password) div:has(> div > #password) > label::after {
  content: "Palavra-passe";
  font-size: 0.875rem;
}
.min-h-screen:has(#username):has(#password) label:has(input[type="checkbox"]) > span:last-child::after {
  content: "Manter sessão iniciada";
  font-size: 0.875rem;
}
/* Os exemplos nos campos vêm em português do Brasil: escondidos. */
.min-h-screen:has(#username):has(#password) #username::placeholder,
.min-h-screen:has(#username):has(#password) #password::placeholder {
  color: transparent;
}

/* Sem cartão: tudo direto no fundo, como no nosso login. */
.min-h-screen:has(#username):has(#password) .rounded-2xl {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  overflow: visible !important;
}
.min-h-screen:has(#username):has(#password) .rounded-2xl > div {
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.min-h-screen:has(#username):has(#password) .rounded-2xl > div:first-child {
  padding-bottom: 0.5rem !important;
}

/* O nosso logótipo em vez do escudo. */
.min-h-screen:has(#username):has(#password) .rounded-2xl .inline-flex:has(> img) {
  width: 190px !important;
  height: 36px !important;
  margin-bottom: 1.5rem !important;
  background: url("/_oteuginasio/logo.png") center / contain no-repeat;
}
.min-h-screen:has(#username):has(#password) .rounded-2xl .inline-flex > img {
  display: none !important;
}

/* Rótulos discretos por cima, campos em pílula. */
.min-h-screen:has(#username):has(#password) form label.block {
  padding-left: 0.25rem;
  font-weight: 400 !important;
  color: var(--color-muted-foreground) !important;
}
.min-h-screen:has(#username):has(#password) #username,
.min-h-screen:has(#username):has(#password) #password {
  height: 44px !important;
  padding-left: 1.25rem !important;
  padding-right: 3rem !important;
}
.min-h-screen:has(#username):has(#password) #password + button {
  right: 0.9rem !important;
  border-radius: 9999px !important;
}

/* Botão "Entrar": pílula clara, sem ícone, como no painel. */
.min-h-screen:has(#username):has(#password) form button[type="submit"] {
  width: 100% !important;
  height: 44px !important;
  background: var(--color-primary) !important;
  color: var(--color-primary-foreground) !important;
  font-weight: 500 !important;
  border: 0 !important;
  transition: background-color 0.15s ease;
}
.min-h-screen:has(#username):has(#password) form button[type="submit"]:hover {
  background: color-mix(in oklch, var(--color-primary) 80%, transparent) !important;
}
.min-h-screen:has(#username):has(#password) form button[type="submit"] svg:not(.animate-spin) {
  display: none !important;
}
