/* Shared interaction layer: short motion, no delays on application actions. */
:root {
  --motion-ease: cubic-bezier(.2, .75, .25, 1);
}

#site-root, .react-page { width: 100%; min-width: 0; }
body:not([data-page]) #site-root { max-width: 1080px; }
body:not([data-page]) .auth-layout { margin-inline: auto; }
.react-messages { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.react-messages:has(.empty-state) { flex: 1; justify-content: center; }
.react-messages .bubble.bot { align-self: flex-start; }
.message-bubble { animation: none; }
.whatsapp-avatar { display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 50%; flex-shrink: 0; }
.whatsapp-avatar:not(.convo-avatar):not(.contact-avatar) { width: 100%; height: 100%; }
.whatsapp-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.bubble.has-audio { width: min(360px, 90%); max-width: 90%; min-width: 0; }
.react-audio-player { width: 100%; min-width: 0; padding: 0 !important; }
.react-audio-player audio { display: none; }
.react-audio-player .audio-controls, .react-audio-player .audio-row { min-width: 0; width: 100%; }
.react-audio-player .audio-progress-wrap { flex: 1; min-width: 40px; }
.react-audio-player .audio-time { min-width: 35px; }
.audio-options { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 11px; }
.audio-options label { display: flex; align-items: center; gap: 5px; }
.audio-options select { padding: 3px 5px; min-height: 0; width: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.audio-error { font-size: 11px; margin-top: 8px; color: var(--danger); white-space: normal; }
.motion-value { display: inline-block; }
.react-emoji-panel { position: absolute; bottom: calc(100% + 8px); left: 0; display: grid; grid-template-columns: repeat(4, 36px); gap: 4px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); z-index: 30; }
.react-emoji-panel button { font-size: 22px; border: 0; background: transparent; border-radius: 6px; padding: 5px; cursor: pointer; }
.react-emoji-wrap { position: relative; }
.page-workspace:empty { display: none; }
.page-workspace > div:empty { display: none; }

@keyframes motion-status { from { opacity: .35; } to { opacity: 1; } }
@keyframes motion-loading { to { rotate: 360deg; } }
@keyframes motion-chart { from { scale: 1 0; } to { scale: 1 1; } }


#interaction-effects {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  overflow: hidden;
}
.motion-clip { position: absolute; overflow: hidden; pointer-events: none; }
.motion-ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  animation: motion-ripple 440ms var(--motion-ease) both;
}
@keyframes motion-ripple {
  from { transform: translate(-50%, -50%) scale(0); opacity: .19; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
@keyframes motion-enter {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes motion-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: no-preference) {
  :is(button, a[href], [role="button"]) {
    transition: background-color 160ms ease, border-color 160ms ease,
      color 160ms ease, box-shadow 180ms ease, opacity 160ms ease,
      transform 180ms var(--motion-ease), scale 140ms var(--motion-ease);
  }
  :where(button, [role="button"]):not(:disabled):not([aria-disabled="true"]):active {
    scale: .97;
  }
  .nav-icon { transition: transform 200ms var(--motion-ease); }
  .inline-editor:not([hidden]) > .editor-panel,
  .login-card {
    animation: motion-enter 280ms var(--motion-ease);
  }
  .login-intro { animation: motion-enter 360ms var(--motion-ease); }
  .metric-card, .chip-card, .campaign-card, .flow-card, .webhook-card, .contact-card {
    transition: translate 200ms var(--motion-ease), border-color 180ms ease, box-shadow 200ms ease;
  }
  .page-notice:not([hidden]), .error-msg:not([hidden]), .profile-error:not([hidden]) {
    animation: motion-enter 200ms var(--motion-ease);
  }
  .convo-item, .contact-item {
    transition: background-color 160ms ease, border-color 160ms ease;
  }
  .app { transition: grid-template-columns 260ms var(--motion-ease); }
  input, textarea, select, .profile-field, .table-search, .table-select {
    transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
  }
  .conn-value, .chip-status-pill, .campaign-status, .funnel-outcome { animation: motion-status 260ms ease; }
  .row-actions[open] .row-action-buttons, .react-emoji-panel, .tags-picker-full, .import-result:not([hidden]), .file-preview:not([hidden]), .bulk-bar:not([hidden]), .register-fields { animation: motion-enter 200ms var(--motion-ease); }
  .motion-value { animation: motion-enter 220ms var(--motion-ease); }
  .chart-bar { transform-origin: bottom; animation: motion-chart 480ms var(--motion-ease); transition: height 350ms var(--motion-ease); }
  .data-table tbody tr { transition: background-color 180ms ease; }
  .tag-toggle-btn, .color-option, .kanban-card { transition: background-color 160ms ease, border-color 160ms ease, translate 180ms var(--motion-ease), box-shadow 180ms ease; }
  button[aria-busy="true"]::after { content: ''; display: inline-block; width: 11px; height: 11px; margin-left: 7px; vertical-align: middle; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: motion-loading 650ms linear infinite; }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .nav-item:hover .nav-icon { transform: translateX(2px); }
  #dashCardOpen:hover, #dashCardFinalized:hover,
  .metric-card[role="button"]:hover, .chip-card:hover, .campaign-card:hover,
  .flow-card:hover, .webhook-card:hover, .contact-card:hover { translate: 0 -3px; }
  .login-btn:not(:disabled):hover, .profile-save:not(:disabled):hover,
  .send-btn:not(:disabled):hover { translate: 0 -1px; }
  .data-table tbody tr:hover { background: var(--surface-2); }
  .kanban-card:hover { translate: 0 -2px; }
}

@media (prefers-reduced-motion: reduce) {
  #interaction-effects { display: none; }
  #site-root *, #site-root *::before, #site-root *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
