/* ========================================
   HIG-Anpassungen (Apple Human Interface Guidelines)
   Kontrast, Fokus, Klickflächen, Farbbedeutung, Benachrichtigungen
   ======================================== */

/* ---------- Kontrast (Ziel ≥ 4,5:1, eigene Farben möglichst 7:1) ---------- */
:root {
  --text-secondary: rgba(255, 255, 255, 0.68);
  --text-muted: rgba(255, 255, 255, 0.52);
  --f-text-muted: rgba(255, 255, 255, 0.55);

  --link: #4da3ff;
  --focus-ring: #4da3ff;
  --hit-target: 44px;
}

:root[data-theme="light"],
body.light-mode {
  --text-secondary: #3d4349;
  --text-muted: #5c636a;
  --f-text-muted: #5c636a;

  --link: #0060c7;
  --focus-ring: #0060c7;
}

.section-title {
  color: var(--text-muted);
}

/* Badges: Textfarbe heller/dunkler, damit 12px-Text lesbar bleibt */
.badge-danger  { color: #ff6b78; }
.badge-success { color: #4cd07d; }
.badge-warning { color: #ffd35c; }
.badge-info    { color: #5ad8f5; }
[data-theme="light"] .badge-danger  { color: #b02a37; }
[data-theme="light"] .badge-success { color: #146c43; }
[data-theme="light"] .badge-warning { color: #7a5d00; }
[data-theme="light"] .badge-info    { color: #066577; }

/* ---------- Eine Farbe = eine Bedeutung ---------- */
/* Rot bleibt für Primäraktion und Status, Textlinks werden blau */
.main-content a:not([class]) {
  color: var(--link);
}

.main-content a:not([class]):hover {
  color: var(--link);
  text-decoration: underline;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ---------- Sichtbarer Fokus bei Tastaturbedienung ---------- */
:focus-visible {
  outline: 2px solid var(--focus-ring) !important;
  outline-offset: 2px !important;
}

input:focus-visible {
  outline-offset: 0 !important;
}

/* Textfelder: nur der dünne blaue Rand, kein zusätzlicher Outline-Ring */
.form-control:focus-visible,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none !important;
}

/* Kein roter Fokus-Rahmen/Glow an Eingabefeldern – nur der blaue Fokusring */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
textarea:focus,
select:focus,
.form-control:focus,
[data-theme="light"] .form-control:focus,
.light-mode .form-control:focus {
  border-color: var(--focus-ring) !important;
  box-shadow: none !important;
}

/* ---------- Klickflächen ---------- */
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--hit-target);
  min-height: var(--hit-target);
}

@media (pointer: coarse) {
  .btn,
  .btn-sm {
    min-height: var(--hit-target);
  }
}

/* ---------- Segmented Control (z. B. Farbschema im Profil) ---------- */
.segmented-control {
  display: flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.segmented-control button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented-control button:hover {
  color: var(--text-primary);
}

.segmented-control button[aria-checked="true"] {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@media (pointer: coarse) {
  .segmented-control button {
    min-height: var(--hit-target);
  }
}

/* Per hig.js bedienbar gemachte Klick-Elemente */
[data-hig-clickable] {
  cursor: pointer;
}

/* ---------- Toast (LST.toast / alert) ---------- */
.hig-toast-stack {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 1000000000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}

.hig-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-tertiary, #12141a);
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
  color: var(--text-primary, #fff);
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: var(--shadow-lg, 0 16px 40px rgba(0, 0, 0, 0.6));
  animation: higToastIn 0.2s ease-out;
}

.hig-toast i {
  margin-top: 2px;
}

.hig-toast-success i { color: #4cd07d; }
.hig-toast-error i   { color: #ff6b78; }
.hig-toast-warning i { color: #ffd35c; }
.hig-toast-info i    { color: var(--link, #4da3ff); }
[data-theme="light"] .hig-toast-success i { color: #146c43; }
[data-theme="light"] .hig-toast-error i   { color: #b02a37; }
[data-theme="light"] .hig-toast-warning i { color: #7a5d00; }

.hig-toast-body {
  flex: 1;
  min-width: 0;
}

.hig-toast-text {
  display: block;
  white-space: pre-line;
  word-break: break-word;
}

.hig-toast-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 6px 6px 6px 10px;
  border-radius: 8px;
  background: var(--bg-primary, #07080a);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  font-size: 0.85rem;
  color: var(--text-secondary, rgba(255, 255, 255, 0.68));
}

.hig-toast-code strong {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary, #fff);
  letter-spacing: 0.02em;
}

.hig-toast-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-light, rgba(255, 255, 255, 0.12));
  background: transparent;
  color: var(--text-primary, #fff);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.hig-toast-copy:hover {
  background: var(--bg-hover, #13161d);
}

.hig-toast-leaving {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hig-toast-close {
  background: none;
  border: none;
  color: var(--text-secondary, rgba(255, 255, 255, 0.68));
  cursor: pointer;
  min-width: 28px;
  min-height: 28px;
  margin: -6px -8px -6px 0;
  border-radius: 6px;
}

@keyframes higToastIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 600px) {
  .hig-toast-stack {
    left: 16px;
    right: 16px;
    max-width: none;
  }
}

/* ---------- Bestätigungs- und Eingabedialog (LST.confirm / LST.prompt) ---------- */
.hig-dialog {
  z-index: 100001;
}

.hig-dialog .modal {
  max-width: 440px;
}

.hig-dialog .modal-title {
  white-space: pre-line;
  line-height: 1.35;
}

.hig-dialog .modal-body p {
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-line;
}

.hig-dialog .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
