/* ============================================================
   TrustBite Cookie Banner & Settings Modal
   - Bottom-fixed Banner mit 3 gleich-prominenten Buttons
   - Settings-Modal (Overlay) mit Toggle-Switches
   - Dark-mode aware via prefers-color-scheme
   ============================================================ */

#tb-cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: #FFFFFF;
  border-top: 1px solid #E4E4E9;
  box-shadow: 0 -8px 32px rgba(0,0,0,.12);
  padding: 1.25rem 1.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #0D0D0F;
  font-size: .95rem;
  line-height: 1.5;
  animation: tbSlideUp .3s ease-out;
}
#tb-cookie-banner[hidden] { display: none !important; }

@keyframes tbSlideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.tb-cookie-inner {
  max-width: 1060px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tb-cookie-text { flex: 1; }
.tb-cookie-text h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 .35rem 0;
  color: #0D0D0F;
}
.tb-cookie-text p {
  margin: 0;
  color: #555;
  font-size: .9rem;
}
.tb-cookie-text a {
  color: #007AFF;
  text-decoration: underline;
}

.tb-cookie-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
}
@media (min-width: 640px) {
  .tb-cookie-buttons { grid-template-columns: 1fr 1fr 1fr; }
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .8rem 1.2rem;
  font-size: .9rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  font-family: inherit;
  min-height: 44px;
  text-align: center;
  white-space: nowrap;
}
.tb-btn-primary {
  background: #007AFF;
  color: #FFFFFF;
  border-color: #007AFF;
}
.tb-btn-primary:hover { background: #0055CC; border-color: #0055CC; }
.tb-btn-secondary {
  background: #FFFFFF;
  color: #0D0D0F;
  border-color: #D0D0D8;
}
.tb-btn-secondary:hover { background: #F5F7FA; border-color: #007AFF; }

/* ============== MODAL ============== */
#tb-cookie-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: tbFadeIn .2s ease-out;
}
#tb-cookie-modal[hidden] { display: none !important; }

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

.tb-modal-card {
  background: #FFFFFF;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: 0 32px 80px rgba(0,0,0,.22);
}
.tb-modal-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 .5rem 0;
}
.tb-modal-card p {
  color: #555;
  font-size: .9rem;
  margin: 0 0 1.25rem 0;
}

.tb-toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid #EEE;
}
.tb-toggle-row:last-of-type { border-bottom: none; }
.tb-toggle-info { flex: 1; }
.tb-toggle-info strong {
  display: block;
  font-size: .95rem;
  font-weight: 600;
  color: #0D0D0F;
  margin-bottom: .2rem;
}
.tb-toggle-info span {
  display: block;
  font-size: .85rem;
  color: #666;
  line-height: 1.4;
}

/* iOS-style toggle */
.tb-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.tb-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.tb-toggle-slider {
  position: absolute;
  inset: 0;
  background: #CCC;
  border-radius: 26px;
  transition: background .2s;
  cursor: pointer;
}
.tb-toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #FFF;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.tb-toggle input:checked + .tb-toggle-slider { background: #007AFF; }
.tb-toggle input:checked + .tb-toggle-slider::before { transform: translateX(18px); }
.tb-toggle input:disabled + .tb-toggle-slider {
  opacity: .55;
  cursor: not-allowed;
}

.tb-modal-actions {
  display: flex;
  gap: .6rem;
  margin-top: 1.5rem;
  flex-direction: column;
}
@media (min-width: 480px) {
  .tb-modal-actions { flex-direction: row; }
  .tb-modal-actions .tb-btn { flex: 1; }
}

/* ============== DARK MODE ============== */
@media (prefers-color-scheme: dark) {
  #tb-cookie-banner {
    background: #0D1220;
    border-top-color: #1E2536;
    color: #E4E4E9;
  }
  .tb-cookie-text h3 { color: #FFFFFF; }
  .tb-cookie-text p { color: #B5B5BC; }
  .tb-btn-secondary {
    background: #1E2536;
    color: #E4E4E9;
    border-color: #2A3247;
  }
  .tb-btn-secondary:hover { background: #2A3247; }
  .tb-modal-card { background: #0D1220; color: #E4E4E9; }
  .tb-modal-card h2 { color: #FFFFFF; }
  .tb-modal-card p { color: #B5B5BC; }
  .tb-toggle-row { border-bottom-color: #1E2536; }
  .tb-toggle-info strong { color: #FFFFFF; }
  .tb-toggle-info span { color: #9999A0; }
}
