/* ── Cube Assistant ── */

#cube-assistant {
  position: fixed;
  left: calc(100vw - 84px);
  top: calc(100vh - 84px);
  z-index: 9000;
  pointer-events: none;
}

/* ── FAB ── */
#cube-fab {
  width: 56px;
  height: 56px;
  background: #D4AF37;
  border-radius: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 8px 24px rgba(212,175,55,0.35);
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0;
}
#cube-fab:hover {
  box-shadow: 0 12px 32px rgba(212,175,55,0.5);
  animation: none;
}
#cube-fab::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 14px;
  border: 2px solid rgba(212,175,55,0.35);
  animation: cube-pulse 3s ease-in-out infinite;
  pointer-events: none;
}

.cube-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.cube-eyes { display: flex; gap: 10px; }
.cube-eye {
  width: 10px;
  height: 10px;
  background: #1a1a2e;
  border-radius: 50%;
  position: relative;
  transition: height .15s;
}
.cube-eye::after {
  content: '';
  width: 3px; height: 3px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transform: translate(var(--pupil-x, 0px), var(--pupil-y, 0px));
  transition: transform .08s;
}
.cube-mouth {
  width: 10px; height: 4px;
  border-bottom: 2px solid #1a1a2e;
  border-radius: 0 0 50% 50%;
  transition: all .15s;
}

/* Zustände */
#cube-fab.state-alert  { background: #e05050; box-shadow: 0 8px 24px rgba(224,80,80,0.4); }
#cube-fab.state-alert .cube-eye { width: 12px; height: 12px; }
#cube-fab.state-alert .cube-mouth { border-bottom: 2px solid #1a1a2e; border-radius: 0; width: 12px; height: 2px; }

#cube-fab.state-happy  { background: #2ECC71; box-shadow: 0 8px 24px rgba(46,204,113,0.4); }
#cube-fab.state-happy .cube-eye { height: 5px; border-radius: 50% 50% 0 0; background: #1a1a2e; }
#cube-fab.state-happy .cube-mouth { width: 14px; height: 7px; border-bottom: 2px solid #1a1a2e; border-radius: 0 0 50% 50%; }

#cube-fab.state-blink .cube-eye { height: 2px; border-radius: 2px; }

#cube-fab.state-thinking .cube-eye:first-child { height: 2px; border-radius: 2px; }
#cube-fab.state-thinking .cube-eye:last-child { height: 8px; }
#cube-fab.state-thinking .cube-mouth { width: 8px; height: 2px; border-bottom: 2px solid #1a1a2e; border-radius: 0; transform: rotate(8deg); }

/* ── Speech Bubble ── */
#cube-bubble {
  background: #ffffff;
  border: 1px solid #e0e6e3;
  border-radius: 12px;
  padding: 11px 15px;
  font-size: 13px;
  line-height: 1.5;
  color: #1a2a24;
  width: 240px;
  position: absolute;
  bottom: 68px;
  right: 0;
  pointer-events: all;
  cursor: default;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  animation: bubble-in .2s ease;
}
#cube-bubble::after {
  content: '';
  position: absolute;
  right: 20px; bottom: -7px;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid #ffffff;
}
#cube-bubble .bubble-close {
  position: absolute;
  top: 6px; right: 8px;
  font-size: 14px;
  color: #a0b0a8;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
#cube-bubble .bubble-close:hover { color: #4a5a54; }
#cube-bubble .bubble-action {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: #B8960C;
  cursor: pointer;
  font-weight: 600;
  border-bottom: 1px solid rgba(184,150,12,0.3);
}
#cube-bubble .bubble-action:hover { color: #D4AF37; }
#cube-bubble.hidden { display: none; }

/* ── Panel ── */
#cube-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  background: #ffffff;
  border: 1px solid #e0e6e3;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  z-index: 9001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panel-in .2s ease;
}
#cube-panel.hidden { display: none; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #f0f4f2;
  background: #fafcfb;
}
.panel-header-cube {
  width: 32px; height: 32px;
  background: #D4AF37;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.panel-header-cube .cube-eyes { gap: 6px; }
.panel-header-cube .cube-eye  { width: 6px; height: 6px; }
.panel-header-cube .cube-eye::after { width: 2px; height: 2px; }
.panel-header-title { font-size: 13px; font-weight: 600; color: #1a2a24; flex: 1; }
.panel-header-close {
  color: #a0b0a8; cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px;
  transition: color .15s;
}
.panel-header-close:hover { color: #4a5a54; }

/* ── Onboarding Score ── */
.panel-score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 8px;
  border-bottom: 1px solid #f0f4f2;
  background: #fafcfb;
}
.panel-score.hidden { display: none; }
.score-label {
  font-size: 11px;
  color: #7a8a84;
  text-transform: uppercase;
  letter-spacing: .5px;
  flex: 1;
}
.score-value {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.score-bar {
  width: 100%;
  flex-basis: 100%;
  height: 4px;
  background: #f0f4f2;
  border-radius: 2px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .4s ease, background .4s ease;
}


.panel-tip {
  margin: 10px 12px;
  background: #fdf6e3;
  border: 1px solid #e8d78a;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: #5a4510;
}
.panel-tip.alert {
  background: #fdf0f0;
  border-color: #dba8a8;
  color: #6a2020;
}
.panel-tip-action {
  display: inline-block;
  margin-top: 5px;
  font-size: 11px;
  color: #B8960C;
  cursor: pointer;
  font-weight: 600;
  border-bottom: 1px solid rgba(184,150,12,0.3);
}
.panel-tip.alert .panel-tip-action { color: #a84a4a; border-color: rgba(168,74,74,0.3); }
.panel-tip.hidden { display: none; }

.panel-search {
  margin: 10px 12px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f5f7f6;
  border: 1px solid #e0e6e3;
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color .15s;
}
.panel-search:focus-within { border-color: #D4AF37; }
.panel-search input {
  background: none; border: none; outline: none;
  color: #1a2a24; font-size: 13px; flex: 1;
}
.panel-search input::placeholder { color: #a0b0a8; }
.panel-search svg { color: #a0b0a8; flex-shrink: 0; }

.panel-links {
  padding: 4px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 260px;
  overflow-y: auto;
}
.panel-links::-webkit-scrollbar { width: 4px; }
.panel-links::-webkit-scrollbar-track { background: transparent; }
.panel-links::-webkit-scrollbar-thumb { background: #e0e6e3; border-radius: 4px; }

.panel-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s;
}
.panel-link:hover, .panel-link.focused { background: #f0f4f2; }
.panel-link-icon { font-size: 14px; width: 22px; text-align: center; flex-shrink: 0; }
.panel-link-label { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.panel-link-title { font-size: 13px; color: #1a2a24; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-link-sub   { font-size: 11px; color: #7a8a84; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-link.faq { align-items: flex-start; padding: 10px 8px; }
.panel-link.faq .panel-link-sub { white-space: normal; overflow: visible; line-height: 1.45; }
.panel-link-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: #fdf0f0; color: #a84a4a; flex-shrink: 0; font-weight: 600; }
.panel-loading, .panel-empty { padding: 12px 16px; font-size: 12px; color: #a0b0a8; }

.panel-footer {
  padding: 8px 16px;
  border-top: 1px solid #f0f4f2;
  text-align: center;
}
.panel-footer-link {
  font-size: 11px;
  color: #a0b0a8;
  cursor: pointer;
  transition: color .15s;
}
.panel-footer-link:hover { color: #e05050; }

/* ── Pet-Zustände ── */
#cube-fab.state-sleep {
  animation: cube-sleep-bob 2s ease-in-out infinite;
}
#cube-fab.state-sleep .cube-eye {
  height: 2px;
  border-radius: 2px;
  width: 10px;
}
#cube-fab.state-sleep .cube-mouth {
  width: 6px;
  height: 2px;
  border-bottom: 2px solid #1a1a2e;
  border-radius: 0;
}

#cube-fab.state-run .cube-eye { width: 12px; height: 12px; }
#cube-fab.state-run .cube-mouth { width: 12px; height: 2px; border-radius: 0; }

#cube-fab.state-jump {
  animation: cube-jump .4s ease;
}

.cube-zzz {
  position: absolute;
  top: -14px; right: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #a0b0a8;
  opacity: 0;
  pointer-events: none;
  animation: zzz-float 2s ease-in-out infinite;
}

/* ── Animationen ── */
@keyframes cube-pulse {
  0%, 100% { opacity: .3; transform: scale(1); }
  50%       { opacity: .8; transform: scale(1.05); }
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cube-sleep-bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-2px); }
}
@keyframes cube-jump {
  0%   { transform: translateY(0) scale(1); }
  40%  { transform: translateY(-24px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes zzz-float {
  0%   { opacity: 0; transform: translateY(0) translateX(0) scale(.8); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px) translateX(6px) scale(1.1); }
}

/* ── Bubble Footer (Aktion + Snooze) ── */
.bubble-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}
.bubble-footer.hidden { display: none; }
.bubble-action.hidden { display: none; }

#cube-bubble .bubble-footer .bubble-action { margin-top: 0; flex: 1; }

.bubble-snooze {
  font-size: 11px;
  color: #a0b0a8;
  cursor: pointer;
  transition: color .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.bubble-snooze:hover { color: #4a5a54; }

/* ── Panel Summary (Tagesübersicht) ── */
.panel-summary {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.summary-date {
  font-size: 10px;
  font-weight: 600;
  color: #a0b0a8;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding-bottom: 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid #f0f4f2;
}
.summary-line {
  font-size: 13px;
  color: #1a2a24;
  line-height: 1.5;
  padding: 5px 0;
  border-bottom: 1px solid #f8faf9;
}
.summary-line:last-child { border-bottom: none; }
.summary-line.urgent  { color: #a84a4a; font-weight: 600; }
.summary-line.due     { color: #b87820; }
.summary-line.entry   { color: #2d7a4d; }
.summary-line.exit    { color: #7a4a90; }
.summary-line.pending { color: #a84a4a; }
.summary-line.ok      { color: #2d7a4d; }
.summary-line.soon, .summary-line.draft, .summary-line.probezeit { color: #5a6a64; }
.summary-line.score-line { font-size: 14px; padding: 8px 0 4px; border-bottom: 1px solid #f0f4f2; }

/* ── Person-Kontext (Seiten-bezogen) ── */
.person-context { border: 1px solid #e0e6e3; border-radius: 8px; margin: 0; }
.person-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0 4px;
  border-bottom: 1px solid #f0f4f2;
  margin-bottom: 2px;
}
.person-icon { font-size: 16px; }
.person-name { font-size: 14px; font-weight: 600; color: #1a2a24; flex: 1; }
.person-type { font-size: 10px; color: #a0b0a8; text-transform: uppercase; letter-spacing: .5px; }
.ctx-label { display: inline-block; width: 80px; color: #7a8a84; font-size: 11px; flex-shrink: 0; }

/* ── Mobile ── */
@media (max-width: 480px) {
  #cube-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 72px;
    width: auto;
    max-height: calc(100vh - 80px);
  }
  #cube-bubble {
    position: fixed;
    left: 8px;
    right: 8px;
    width: auto;
    bottom: 72px;
    font-size: 14px;
    padding: 14px 18px;
  }
  #cube-bubble::after { right: 28px; left: auto; }
}
