/* ==========================================================================
   Portal-Features: Dark Mode, Benachrichtigungen, Vollbild-Unterschrift
   ========================================================================== */

/* --------------------------------------------------------------------------
   Dark Mode
   -------------------------------------------------------------------------- */

:root[data-theme="dark"] {
  --paper:          #0f1115;
  --white:          #1a1d24;
  --ink:            #e8e9ed;
  --ink-700:        #d0d2d8;
  --ink-500:        #b8bcc6;
  --line:           #2a2e38;
  --text:           #e8e9ed;
  --text-muted:     #9aa0ad;
  --accent:         #e05a3a;
  --accent-600:     #c8371e;
  --shadow-md:      0 0 0 1px var(--line);
}

:root[data-theme="dark"] body.portal {
  background: var(--paper);
  color: var(--text);
}

:root[data-theme="dark"] .seitenleiste {
  background: #0b0d12;
  color: #a9a9b3;
}

:root[data-theme="dark"] .portal-kopf {
  background: var(--white);
  border-bottom-color: var(--line);
}

:root[data-theme="dark"] .tafel,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .detail-kasten {
  background: var(--white);
  border-color: var(--line);
  color: var(--text);
}

:root[data-theme="dark"] .tafel__kopf {
  background: var(--ink-500);
  color: var(--text);
  border-bottom-color: var(--line);
}

:root[data-theme="dark"] .tafel__leib {
  color: var(--text);
}

:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #12151d;
  border-color: var(--line);
  color: var(--text);
}

:root[data-theme="dark"] .form-control:focus,
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,90,58,.25);
}

:root[data-theme="dark"] .btn--ghost {
  border-color: var(--line);
  color: var(--text);
}

:root[data-theme="dark"] .btn--ghost:hover {
  background: var(--ink-500);
  border-color: var(--text);
}

:root[data-theme="dark"] .marke--grau {
  background: #2a2e38;
  color: #b8bcc6;
}

:root[data-theme="dark"] .meldung--ok {
  background: #1a2e1a;
  color: #7dd87d;
  border-color: #2d5a2d;
}

:root[data-theme="dark"] .meldung--stop {
  background: #3a1a1a;
  color: #f08080;
  border-color: #5a2d2d;
}

:root[data-theme="dark"] .meldung--info {
  background: #1a2a3a;
  color: #80b8f0;
  border-color: #2d4a5a;
}

:root[data-theme="dark"] .vertrag {
  background: #12151d;
  color: var(--text);
  border-color: var(--line);
}

:root[data-theme="dark"] .zeichenfeld {
  background: #12151d;
  border-color: var(--accent);
}

:root[data-theme="dark"] .zeichenfeld__hinweis {
  color: var(--accent);
}

:root[data-theme="dark"] .zeichenfeld__hilfe {
  background: rgba(26,29,36,.95);
  color: var(--text);
}

:root[data-theme="dark"] .zeichenfeld__linie {
  border-bottom-color: rgba(232,233,237,.3);
}

:root[data-theme="dark"] .zeichenfeld__linie span {
  color: rgba(232,233,237,.5);
}

:root[data-theme="dark"] .unterschrift-tafel > .tafel__kopf {
  background: linear-gradient(135deg,#a52c17,#c8371e);
}

:root[data-theme="dark"] .kopf-verdienst {
  color: var(--text);
}

:root[data-theme="dark"] .kopf-verdienst__wert {
  color: var(--accent);
}

:root[data-theme="dark"] .pflichtleiste {
  background: var(--white);
  border-color: var(--line);
}

:root[data-theme="dark"] .hilfe__text {
  background: var(--white);
  border-color: var(--line);
  color: var(--text);
}

:root[data-theme="dark"] .logo__mark {
  filter: brightness(1.2);
}

/* Theme-Toggle */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}

.theme-toggle:hover {
  background: var(--paper);
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Benachrichtigungen
   -------------------------------------------------------------------------- */

.benachrichtigungen-wrapper {
  position: relative;
}

.benachrichtigungen-glocke {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}

.benachrichtigungen-glocke:hover {
  background: var(--paper);
  border-color: var(--accent);
}

.benachrichtigungen-icon {
  line-height: 1;
}

.benachrichtigungen-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 .25rem;
  border-radius: 1rem;
  background: #c8371e;
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1.25rem;
  text-align: center;
}

.benachrichtigungen-panel {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  z-index: 200;
  width: min(24rem, 90vw);
  max-height: 32rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
}

.benachrichtigungen-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: .875rem;
}

.benachrichtigungen-kopf .btn-text {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: .75rem;
  cursor: pointer;
  text-decoration: underline;
}

.benachrichtigungen-liste {
  list-style: none;
  margin: 0;
  padding: 0;
}

.benachrichtigung {
  border-bottom: 1px solid var(--line);
}

.benachrichtigung:last-child {
  border-bottom: 0;
}

.benachrichtigung--neu {
  background: rgba(200,55,30,.06);
}

:root[data-theme="dark"] .benachrichtigung--neu {
  background: rgba(224,90,58,.12);
}

.benachrichtigung__link {
  display: flex;
  gap: .75rem;
  padding: .85rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: background .15s;
}

.benachrichtigung__link:hover {
  background: var(--paper);
}

.benachrichtigung__icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1.4;
}

.benachrichtigung__text {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 0;
}

.benachrichtigung__text strong {
  font-size: .875rem;
  line-height: 1.3;
}

.benachrichtigung__text small {
  font-size: .8125rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.benachrichtigung__text time {
  font-size: .75rem;
  color: var(--text-muted);
}

.benachrichtigungen-leer {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .875rem;
}

/* --------------------------------------------------------------------------
   Vollbild-Unterschrift (nur auf Handys/Tablets)
   -------------------------------------------------------------------------- */

.btn-vollbild {
  display: none;
}

@media (max-width: 48rem), (pointer: coarse) {
  .btn-vollbild {
    display: inline-flex;
  }
}

.zeichenfeld-vollbild {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  padding: 1rem;
}

.zeichenfeld-vollbild .zeichenfeld {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-width: 3px;
}

.zeichenfeld-vollbild .zeichenfeld canvas {
  flex: 1;
  height: auto !important;
  min-height: 0;
}

.zeichenfeld-vollbild__kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.zeichenfeld-vollbild__kopf h3 {
  margin: 0;
  font-size: 1.125rem;
  color: var(--text);
}

.zeichenfeld-vollbild__aktionen {
  display: flex;
  gap: .75rem;
  margin-top: .75rem;
  flex-wrap: wrap;
}

.zeichenfeld-vollbild__aktionen .btn {
  flex: 1;
  min-width: 8rem;
}

.zeichenfeld-vollbild__schliessen {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
}

.zeichenfeld-vollbild__schliessen:hover {
  background: var(--paper);
  border-color: var(--accent);
}

body.zeichenfeld-vollbild-offen {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Fortschrittsanzeige
   -------------------------------------------------------------------------- */

.fortschritt {
  margin-bottom: 1.25rem;
}

.fortschritt__text {
  display: flex;
  justify-content: space-between;
  margin-bottom: .35rem;
  font-size: .8125rem;
  color: var(--text-muted);
}

.fortschritt__balken {
  height: .5rem;
  border-radius: 1rem;
  background: var(--line);
  overflow: hidden;
}

.fortschritt__fuellung {
  height: 100%;
  border-radius: 1rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-600));
  transition: width .3s ease;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 35rem) {
  .benachrichtigungen-panel {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    width: 100%;
    max-height: calc(100vh - 60px);
    border-radius: 0;
  }

  .zeichenfeld-vollbild {
    padding: .5rem;
  }

  .zeichenfeld-vollbild__aktionen .btn {
    min-width: 6rem;
    font-size: .875rem;
  }
}

@media print {
  .theme-toggle,
  .benachrichtigungen-wrapper,
  .zeichenfeld-vollbild {
    display: none !important;
  }
}
