/*
 * Kundenportal V1 - UI/UX-Hardening.
 *
 * Farben/Typografie exakt nach der BKDP-Markenrichtlinie (Notion MASTER
 * KNOWLEDGE §7, siehe auch static/css/base.css in der Faktura-Oberfläche
 * - dieselben sieben Token-Werte, damit Portal und Faktura-Owner-UI
 * dieselbe Palette teilen). Strong Blue ist der EINZIGE Akzent, nie
 * dekorativ verdoppelt. Inter wird selbst gehostet (fonts/inter/, aus
 * demselben Repository-Bestand wie static/fonts/inter/ - kein
 * Google-Fonts-Abruf).
 *
 * Bewusst weiterhin kein Framework, kein Build-Schritt (V3-D-Prinzip).
 */

@font-face {
  font-family: "Inter";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("../fonts/inter/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("../fonts/inter/Inter-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("../fonts/inter/Inter-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("../fonts/inter/Inter-Bold.woff2") format("woff2");
}

:root {
  /* Kanonische BKDP-Palette (bkdp-brand-guidelines) - keine weiteren Farben. */
  --bkdp-strong-blue: #1a4bbd;
  --bkdp-strong-blue-hover: #163f9f;
  --bkdp-deep-navy: #0a1628;
  --bkdp-section-navy: #0a1128;
  --bkdp-footer-navy: #060e1f;
  --bkdp-white: #ffffff;
  --bkdp-ink: #0d141a;
  --bkdp-form-grey: #b8c0cc;

  --font-sans: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --radius: 6px;
  --border: #dde1e7;
  --muted: #5b6472;
  --bg: #f5f6f8;

  --warning-bg: #fff4e5;
  --warning-border: #d99a2b;
  --warning-text: #7a4a00;
  --error-bg: #fdecea;
  --error-border: #c0392b;
  --error-text: #8e2318;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--bkdp-ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-weight: 700;
  line-height: 1.25;
}

/* ---------------------------------------------------------------------
 * Header (Dokumente/Rechnungen/Konto) - Deep Navy, Signet + Titel + Nav.
 * ------------------------------------------------------------------- */

header.portal-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: var(--bkdp-deep-navy);
  color: var(--bkdp-white);
  flex-wrap: wrap;
}

header.portal-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

header.portal-header .brand img {
  width: 28px;
  height: 28px;
  display: block;
}

header.portal-header .brand .org-label {
  color: var(--bkdp-form-grey);
  font-weight: 500;
}

nav#portal-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

nav#portal-nav a {
  color: var(--bkdp-white);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
}

nav#portal-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

nav#portal-nav a.active {
  background: var(--bkdp-strong-blue);
}

.header-logout {
  display: inline;
  width: auto;
  margin-top: 0;
  color: var(--bkdp-white);
  text-decoration: underline;
  white-space: nowrap;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

main h1 {
  font-size: 24px;
  margin: 0 0 6px;
}

/* ---------------------------------------------------------------------
 * Status-Banner (Warnung/Fehler) - Text bleibt die primäre Information,
 * Farbe nur unterstützend (Accessibility-Vorgabe der Markenrichtlinie).
 * ------------------------------------------------------------------- */

.status-banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.status-banner--warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}

.status-banner--error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
}

.status-banner--loading {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ---------------------------------------------------------------------
 * Tabellen - horizontal scrollbar auf schmalen Viewports statt Umbruch.
 * ------------------------------------------------------------------- */

.table-scroll {
  width: 100%;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.portal-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
}

table.portal-table th,
table.portal-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  white-space: nowrap;
}

table.portal-table td:nth-child(1),
table.portal-table th:nth-child(1) {
  white-space: normal;
}

table.portal-table tbody tr:last-child td {
  border-bottom: none;
}

table.portal-table tbody tr:hover {
  background: #fafbfc;
}

table.portal-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.empty-state {
  color: var(--muted);
  padding: 32px 16px;
  text-align: center;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.loading-state {
  color: var(--muted);
  padding: 24px 0;
}

/* ---------------------------------------------------------------------
 * Login-Shell V2: zweigeteiltes Layout (Markenpanel + Formularpanel).
 * Wird NUR auf index.html benutzt; documents/invoices/account haben
 * stattdessen den Header oben. Kein Foto-Hintergrund (bewusste
 * Design-Entscheidung, siehe portal-frontend/README.md) - stattdessen
 * eine sehr zurückhaltende geometrische Struktur rein aus CSS
 * (Radial-Glow + eine dünne diagonale Akzentlinie), keine externe
 * Bild-/CDN-Abhängigkeit.
 * ------------------------------------------------------------------- */

.login-shell {
  min-height: 100vh;
  display: flex;
}

.login-shell__brand {
  position: relative;
  overflow: hidden;
  flex: 1 1 42%;
  background:
    radial-gradient(ellipse 700px 500px at 15% 10%, rgba(26, 75, 189, 0.16), transparent 60%),
    radial-gradient(ellipse 900px 650px at 100% 100%, rgba(6, 14, 31, 0.65), transparent 60%),
    linear-gradient(165deg, var(--bkdp-deep-navy) 0%, var(--bkdp-section-navy) 55%, var(--bkdp-footer-navy) 100%);
  color: var(--bkdp-white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
}

.login-shell__brand-accent {
  position: absolute;
  right: -10%;
  bottom: -15%;
  width: 70%;
  height: 1px;
  background: var(--bkdp-strong-blue);
  opacity: 0.35;
  transform: rotate(-32deg);
  transform-origin: right bottom;
}

.login-shell__logo {
  width: 190px;
  height: auto;
  margin-bottom: 42px;
  position: relative;
}

.login-shell__claim {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 14px;
  max-width: 420px;
  position: relative;
}

.login-shell__claim span {
  color: #6f9bf0;
}

.login-shell__sub {
  color: var(--bkdp-form-grey);
  font-size: 15px;
  line-height: 1.6;
  max-width: 380px;
  margin: 0;
  position: relative;
}

.brand-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  width: 56px;
  margin: 28px 0 24px;
}

.brand-bullets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

.brand-bullet {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 400;
  color: var(--bkdp-form-grey);
}

.brand-bullet__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(111, 155, 240, 0.8);
}

.brand-bullet__icon svg {
  width: 14px;
  height: 14px;
}

.login-shell__form {
  flex: 1 1 58%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
  gap: 20px;
}

.auth-footer {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  text-align: center;
}

.auth-footer__link {
  color: var(--muted);
  text-decoration: underline;
}

.auth-footer__link:hover {
  color: var(--bkdp-ink);
}

.auth-footer__link:focus-visible {
  outline: 2px solid var(--bkdp-strong-blue);
  outline-offset: 2px;
  border-radius: 2px;
}

.auth-footer__sep {
  margin: 0 4px;
}

@media (max-width: 860px) {
  .login-shell {
    flex-direction: column;
  }
  .login-shell__brand {
    flex: 0 0 auto;
    padding: 32px 24px;
    align-items: center;
    text-align: center;
  }
  .login-shell__brand-accent {
    display: none;
  }
  .login-shell__logo {
    width: 160px;
    margin-bottom: 20px;
  }
  .login-shell__claim {
    font-size: 21px;
    max-width: none;
  }
  .login-shell__sub {
    max-width: none;
  }
  .brand-divider {
    margin: 20px auto;
  }
  .brand-bullets {
    display: none;
  }
  .login-shell__form {
    flex: 1 1 auto;
    padding: 28px 20px 40px;
  }
}

/* ---------------------------------------------------------------------
 * Formulare (Login, TOTP, Passwort, Konto-Bereiche).
 * ------------------------------------------------------------------- */

form.portal-form {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  padding: 32px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

form.portal-form h1 {
  font-size: 20px;
  margin: 0 0 4px;
}

form.portal-form > .form-hint:first-of-type {
  margin-top: 0;
}

form.portal-form label {
  display: block;
  margin: 16px 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

form.portal-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--bkdp-form-grey);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-sans);
}

form.portal-form input:focus {
  outline: 2px solid var(--bkdp-strong-blue);
  outline-offset: 1px;
  border-color: var(--bkdp-strong-blue);
}

form.portal-form input#totp-enroll-code,
form.portal-form input#totp-challenge-code {
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
  font-weight: 600;
}

form.portal-form button[type="submit"] {
  margin-top: 20px;
  width: 100%;
  padding: 12px;
  background: var(--bkdp-strong-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
}

form.portal-form button[type="submit"]:hover {
  background: var(--bkdp-strong-blue-hover);
}

form.portal-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: default;
}

form.portal-form .form-error {
  color: var(--error-text);
  font-size: 13px;
  margin-top: 10px;
  min-height: 16px;
}

form.portal-form .form-hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
  line-height: 1.5;
}

.form-hint--success {
  color: #1f7a4d;
}

/* ---------------------------------------------------------------------
 * Auth-Card V2 (nur index.html - Login/Magic-Link/Recovery/TOTP): eine
 * gezielt hochwertigere Ausprägung von form.portal-form, OHNE dessen
 * Basisregeln zu verändern (die gelten unveraendert weiter fuer
 * account.html - §28 "minimale gemeinsame CSS-Komponente"). Alles hier
 * ist additiv unter der zusätzlichen Klasse .auth-card.
 * ------------------------------------------------------------------- */

form.portal-form.auth-card {
  max-width: 512px;
  padding: 40px 44px;
  border-radius: 12px;
  border-color: #e6e8ec;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px -8px rgba(16, 24, 40, 0.10);
}

.auth-eyebrow {
  color: var(--bkdp-strong-blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 10px;
}

.auth-card h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

.auth-card > .form-hint:first-of-type {
  margin-top: 0;
  margin-bottom: 4px;
}

/* Formularfeld mit Label-Zeile (Label + optionaler Aktionslink) und
   Icon-Input. Additiv - form.portal-form input bleibt fuer Felder ohne
   diese Struktur (z. B. account.html) unveraendert. */
.field {
  margin-bottom: 4px;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field-label-row label {
  margin-bottom: 6px;
}

.field-label-row .btn-link {
  font-size: 13px;
  margin-bottom: 6px;
}

.field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.field__icon {
  position: absolute;
  left: 12px;
  display: flex;
  color: var(--muted);
  pointer-events: none;
}

.field__icon svg {
  width: 18px;
  height: 18px;
}

form.portal-form .field__control input {
  padding-left: 40px;
}

.field__toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  padding: 6px;
  display: flex;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
}

.field__toggle:hover {
  color: var(--bkdp-ink);
}

.field__toggle:focus-visible {
  outline: 2px solid var(--bkdp-strong-blue);
  outline-offset: 1px;
}

.field__toggle svg {
  width: 18px;
  height: 18px;
}

#login-password {
  padding-right: 40px;
}

.code-input {
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
  font-weight: 600;
}

/* Primärbutton mit Label + Icon, sichtbarer Ladezustand (§16). */
form.portal-form button[type="submit"] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

form.portal-form button[type="submit"] .btn-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.15s ease;
}

form.portal-form button[type="submit"]:hover .btn-icon {
  transform: translateX(2px);
}

form.portal-form button[type="submit"].is-loading {
  position: relative;
}

form.portal-form button[type="submit"]:focus-visible {
  outline: 2px solid var(--bkdp-strong-blue);
  outline-offset: 2px;
}

/* Sekundärer Ghost-/Outline-Button (Magic Link) - bewusst deutlich
   zurückhaltender als der Primärbutton (kein gefüllter Blauton). */
.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--bkdp-form-grey);
  color: var(--bkdp-ink);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
}

.btn-outline svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.btn-outline:hover {
  border-color: var(--bkdp-strong-blue);
  background: rgba(26, 75, 189, 0.04);
}

.btn-outline:focus-visible {
  outline: 2px solid var(--bkdp-strong-blue);
  outline-offset: 2px;
}

.btn-outline:disabled {
  opacity: 0.6;
  cursor: default;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.trust-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 24px 0 0;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.trust-box strong {
  display: block;
  color: var(--bkdp-ink);
  font-size: 13px;
  font-weight: 600;
}

.trust-box__icon {
  flex-shrink: 0;
  color: var(--bkdp-strong-blue);
  margin-top: 1px;
}

.trust-box__icon svg {
  width: 18px;
  height: 18px;
}

/* Sekundäre Aktionen (Magic Link, Passwort vergessen, zurück) - bewusst
   als schlichte Textlinks UNTER dem primären "Anmelden"-Button, nicht
   als gleichrangige Buttons (Anforderung: sekundäre Aktionen). */
.btn-link {
  display: inline;
  background: none;
  border: none;
  color: var(--bkdp-strong-blue);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  font-family: var(--font-sans);
  text-decoration: underline;
}

.btn-link:disabled {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}

/* Sekundäre Login-Aktionen (Magic Link, Passwort vergessen, zurück) -
   bewusst als schlichte, zentrierte Textlinks UNTER dem primären
   Button, nicht als gleichrangiger Button. Diese Block-/Zentrierlogik
   gilt NUR innerhalb dieses Wrappers, nicht fuer .btn-link allgemein
   (Tabellenaktionen etc. bleiben inline). */
.login-secondary-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.login-secondary-actions .btn-link {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 13px;
}

.form-back-link {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 13px;
  margin-top: 16px;
}

img.totp-qr {
  display: block;
  margin: 16px auto;
  max-width: 200px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  background: #fff;
}

form.portal-form code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  word-break: break-all;
}

/* ---------------------------------------------------------------------
 * Dokumente/Rechnungen-Seiten: Filter, Sektionshinweise.
 * ------------------------------------------------------------------- */

.filter-row {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-row label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.filter-row select {
  padding: 8px 10px;
  border: 1px solid var(--bkdp-form-grey);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 14px;
  background: #fff;
}

.section-hint {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ---------------------------------------------------------------------
 * Konto-Seite.
 * ------------------------------------------------------------------- */

.account-section {
  margin-bottom: 32px;
}

.account-section h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

.account-section form.portal-form {
  margin: 0;
  max-width: none;
  padding: 20px;
}

.account-section form.portal-form button[type="submit"] {
  width: auto;
  padding: 10px 20px;
}

.btn-link--spaced {
  margin-top: 12px;
}

.btn-secondary-inline {
  background: none;
  border: 1px solid var(--bkdp-strong-blue);
  color: var(--bkdp-strong-blue);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
}

.btn-secondary-inline:hover {
  background: rgba(26, 75, 189, 0.08);
}

.btn-secondary-inline:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 640px) {
  header.portal-header {
    padding: 12px 16px;
  }
  main {
    padding: 24px 14px 48px;
  }
  form.portal-form {
    padding: 24px 20px;
  }
}
