/*
  RIVAID Portal - UI Material compatibility layer

  Zweck:
  - alte Utility- und Komponentenklassen stabil halten
  - keine zweite Designquelle mehr aufbauen
  - Tokens immer aus /assets/manifest.css beziehen

  Canonical ownership:
  - Shell, Topbar, Header und Content-Frame: portal-layout-system.css
  - Legacy-Kompatibilität für Utility- und Formular-Klassen: manifest.css
*/

:root {
  --rivaid-ink: var(--ink, #0c1116);
  --rivaid-muted: var(--muted, rgba(12, 17, 22, .62));
  --rivaid-stroke: var(--border, rgba(12, 17, 22, .10));
  --rivaid-panel: var(--surface, rgba(255, 255, 255, .82));
  --rivaid-panel-strong: var(--surface2, rgba(255, 255, 255, .94));
  --rivaid-glass: var(--surface3, rgba(255, 255, 255, .72));
  --rivaid-shadow: var(--shadow-lg, 0 18px 60px rgba(12, 17, 22, .10));
  --rivaid-shadow2: var(--shadow-md, 0 10px 30px rgba(12, 17, 22, .08));
  --rivaid-teal: var(--teal, #0ea5a0);
  --rivaid-teal-deep: var(--teal-deep, #0b8b87);
  --rivaid-teal-soft: var(--teal-glow, rgba(14, 165, 160, .14));
  --rivaid-red-soft: var(--red-soft, rgba(239, 68, 68, .10));
  --rivaid-red-stroke: rgba(239, 68, 68, .22);

  --btn-h: 44px;
  --btn-px: 18px;
  --btn-radius: var(--public-btn-radius, 999px);
  --btn-fs: 14px;
  --btn-fw: 700;
  --btn-lh: 1;
  --btn-border-w: 1px;
  --btn-border-style: solid;

  --btn-text: #ffffff;
  --btn-bg: var(--accent-grad, linear-gradient(145deg, #10a7a0 0%, #0b8b87 100%));
  --btn-bg-size: 100% 100%;
  --btn-bg-pos: 0% 0;
  --btn-border: transparent;
  --btn-shadow: 0 4px 18px rgba(14, 165, 160, .28);

  --btn-hover-border: transparent;
  --btn-hover-shadow: 0 8px 28px rgba(14, 165, 160, .34);
  --btn-focus-shadow: 0 0 0 4px rgba(14, 165, 160, .18), 0 8px 28px rgba(14, 165, 160, .20);

  --btn-primary-shadow: 0 4px 18px rgba(14, 165, 160, .28);
  --btn-primary-hover-shadow: 0 8px 28px rgba(14, 165, 160, .34);
  --btn-primary-active-bg: linear-gradient(145deg, #0b8b87 0%, #087a76 100%);
  --btn-primary-active-shadow: 0 6px 16px rgba(14, 165, 160, .24);

  --btn-secondary-text: var(--ink, #0c1116);
  --btn-secondary-bg: var(--surface2, rgba(255, 255, 255, .94));
  --btn-secondary-border: var(--border, rgba(12, 17, 22, .12));
  --btn-secondary-hover-bg: rgba(255, 255, 255, .98);
  --btn-secondary-hover-text: var(--ink, #0c1116);
  --btn-secondary-hover-border: var(--border-strong, rgba(12, 17, 22, .18));
  --btn-secondary-hover-shadow: var(--shadow-md, 0 8px 32px rgba(12, 17, 22, .10));
  --btn-secondary-active-shadow: var(--shadow-sm, 0 2px 10px rgba(12, 17, 22, .07));

  --btn-ghost-text: var(--teal, #0ea5a0);
  --btn-danger-text: #b42323;
  --btn-danger-bg: rgba(255, 255, 255, .95);
  --btn-danger-border: rgba(220, 38, 38, .28);
  --btn-danger-hover-bg: rgba(255, 248, 248, .98);
  --btn-danger-hover-border: rgba(220, 38, 38, .38);
  --btn-danger-hover-text: #a61f1f;
  --btn-link-text: color-mix(in srgb, var(--ink, #0c1116) 78%, transparent);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --btn-secondary-bg: rgba(28, 50, 58, .95);
  --btn-secondary-border: rgba(14, 165, 160, .22);
  --btn-secondary-hover-bg: rgba(34, 58, 66, .98);
  --btn-secondary-hover-text: var(--ink, #e8f4f4);
  --btn-secondary-hover-border: rgba(14, 165, 160, .32);
  --btn-danger-bg: rgba(72, 24, 28, .72);
  --btn-danger-border: rgba(255, 146, 146, .24);
  --btn-danger-hover-bg: rgba(92, 28, 34, .82);
  --btn-danger-hover-border: rgba(255, 146, 146, .34);
  --btn-danger-hover-text: #ffd1d1;
}

/* ===== Legacy rbar shell ===== */
.rbar {
  margin: 0 0 18px;
  position: sticky;
  top: 12px;
  z-index: 40;
}

.rbar-pill {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--pill-bg, rgba(255, 255, 255, .76));
  border: 1px solid var(--border2, rgba(255, 255, 255, .58));
  box-shadow: var(--rivaid-shadow2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.rbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--rivaid-ink);
  background: transparent;
  border: 0;
  box-shadow: none;
  white-space: nowrap;
}

.rbar-logo {
  height: 28px;
  width: auto;
  display: block;
}

.rbar-brandText {
  font-weight: 900;
  letter-spacing: .2px;
}

.rbar-nav {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rbar-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink2, rgba(12, 17, 22, .82));
  font-weight: 700;
  font-size: 13px;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  position: relative;
  transition: transform .12s ease, color .12s ease, opacity .12s ease;
}

.rbar-nav a:hover,
.rbar-nav a:focus-visible {
  color: var(--ink, #0c1116);
  transform: translateY(-1px);
  outline: none;
}

.rbar-nav a::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
  transform: scaleX(.45);
  transform-origin: center;
  transition: opacity .15s ease, transform .15s ease;
}

.rbar-nav a:hover::after,
.rbar-nav a:focus-visible::after,
.rbar-nav a.active::after,
.rbar-nav a[aria-current="page"]::after {
  opacity: 1;
  transform: scaleX(1);
}

.rbar-nav a.admin {
  color: #9f2222;
}

.rbar-cta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.rbar-ctaLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--border, rgba(12, 17, 22, .10));
  background: var(--surface2, rgba(255, 255, 255, .92));
  color: var(--ink, #0c1116);
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(12, 17, 22, .07));
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}

.rbar-ctaLink:hover,
.rbar-ctaLink:focus-visible {
  transform: translateY(-1px);
  background: var(--teal-glow, rgba(14, 165, 160, .10));
  outline: none;
}

.rbar-ctaLink.primary {
  border-style: dashed;
  border-color: rgba(14, 165, 160, .40);
  color: var(--teal-deep, #0b8b87);
}

@media (max-width: 980px) {
  .rbar-pill {
    flex-wrap: wrap;
    border-radius: 26px;
    padding: 10px;
  }

  .rbar-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow: auto;
    white-space: nowrap;
    padding-bottom: 2px;
  }

  .rbar-cta {
    order: 2;
    margin-left: auto;
  }
}

/* ===== Legacy dropdown aliases ===== */
.dropdown,
.userMenu {
  position: relative;
}

.userBtn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(12, 17, 22, .10));
  background: var(--surface2, rgba(255, 255, 255, .92));
  color: var(--ink, #0c1116);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(12, 17, 22, .07));
}

.userBtn:hover,
.userBtn:focus-visible {
  background: var(--teal-glow, rgba(14, 165, 160, .10));
  transform: translateY(-1px);
  outline: none;
}

.userBtn .avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(14, 165, 160, .18);
  border: 1px solid rgba(14, 165, 160, .28);
  font-weight: 900;
}

.userName {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu,
.userDropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  border-radius: var(--r-sm, 14px);
  border: 1px solid var(--border, rgba(12, 17, 22, .10));
  background: var(--surface2, rgba(255, 255, 255, .94));
  box-shadow: var(--shadow-md, 0 8px 32px rgba(12, 17, 22, .10));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  z-index: 200;
}

.menu.open,
.dropdown details[open] .menu,
.userMenu[open] .userDropdown {
  display: block;
}

.menuHead {
  padding: 10px 10px 8px;
}

.menuTitle {
  font-weight: 900;
  margin: 0;
}

.menuSub {
  font-size: 12px;
  color: var(--muted, rgba(12, 17, 22, .62));
  margin: 2px 0 0;
}

.divider {
  height: 1px;
  background: rgba(12, 17, 22, .06);
  margin: 6px 4px;
}

.menuItem,
.userDropdown a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink2, #2b3c47);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
}

.menuItem:hover,
.userDropdown a:hover {
  background: var(--teal-glow, rgba(14, 165, 160, .10));
  color: var(--ink, #0c1116);
}

.menuItem.danger:hover,
.userDropdown a.danger:hover {
  background: rgba(239, 68, 68, .10);
  border-color: rgba(239, 68, 68, .18);
  color: #a61f1f;
}

/* ===== Lightweight message compatibility ===== */
.msg {
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 12px;
  border: 1px solid rgba(12, 17, 22, .10);
  background: var(--surface2, rgba(255, 255, 255, .94));
}

.msg.ok {
  border-color: rgba(14, 165, 160, .28);
  background: rgba(14, 165, 160, .08);
}

.msg.err {
  border-color: rgba(220, 38, 38, .28);
  background: rgba(220, 38, 38, .06);
}

/* ===== Legacy button aliases not covered everywhere ===== */
body .btn.btnGhost:not(.userBtn),
body .btnGhost:not(.userBtn) {
  background: var(--btn-secondary-bg) !important;
  color: var(--btn-secondary-text) !important;
  border: 1px solid var(--btn-secondary-border) !important;
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(12, 17, 22, .07)) !important;
}

body .btn.btnGhost:not(.userBtn):hover,
body .btnGhost:not(.userBtn):hover {
  background: var(--btn-secondary-hover-bg) !important;
  color: var(--btn-secondary-hover-text) !important;
  border-color: var(--btn-secondary-hover-border) !important;
}

body .btn.link:not(.userBtn) {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: var(--btn-link-text) !important;
}

body .btn.link:not(.userBtn)::before {
  display: none !important;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
  font-family: inherit;
}

summary::-webkit-details-marker {
  display: none;
}

summary {
  list-style: none;
}
