/* SITA — base styles. Tailwind CDN handles utilities; this is small overrides. */
@media (prefers-color-scheme: light) {
  body {
    background-color: #0a0a0a;
    color: #f4f4f4;
  }
}

/* Smooth scroll for chat history */
main {
  scroll-behavior: smooth;
}

/* iOS / Android safe area — applies to the chat composer + voice page footer */
@supports (padding: env(safe-area-inset-bottom)) {
  footer,
  .sita-safe-bottom {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
  }
  header,
  .sita-safe-top {
    padding-top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
  }
}

/* Pulse for streaming indicator */
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.streaming {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Fade-in for new chat bubbles + cards */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fadeIn {
  animation: fadeIn 0.3s ease-out;
}

/* Subtle breathing for idle UI elements */
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50%      { transform: scale(1.03); opacity: 1; }
}

/* Better touch targets on mobile — make all clickable controls
   at least 44×44 px (Apple HIG, WCAG 2.5.5 AA) without bloating desktop */
@media (max-width: 767px) {
  button, [role="button"], a {
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.08);
    touch-action: manipulation;
  }
  /* Inputs: stop iOS from auto-zooming in by ensuring 16px font */
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* Prevent overscroll bounce trapping focus in iOS */
html, body {
  overscroll-behavior-y: contain;
}

/* PWA standalone mode: full-height app feel */
@media all and (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; }
  /* But allow selection inside the transcript / message bubbles */
  .selectable, input, textarea { user-select: text; -webkit-user-select: text; }
}

/* =========================================================================
   2026-05-18 — UI refinement pass for the main chat (index.html). The goal:
   bring the same polish that landed in voice.html — gradient orb empty
   state, subtle shimmer hovers, glass-morphism header, refined message
   cards, animated focus ring on the composer.
   These are layered ON TOP of Tailwind utilities; nothing here overrides
   tailwind-generated classes, so the markup stays the source of truth.
   ========================================================================= */

/* Multi-layered breathing for the empty-state orb (matches voice.html
   wake animation but at a calmer 4s cycle for the chat page since
   there's no live audio level to react to). */
@keyframes orbBreathe {
  0%, 100% { transform: scale(1);   opacity: 0.95; }
  50%      { transform: scale(1.06); opacity: 1; }
}
@keyframes orbGlow {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}
@keyframes orbHaloDrift {
  0%   { transform: scale(1)    rotate(0deg);   opacity: 0.30; }
  50%  { transform: scale(1.08) rotate(180deg); opacity: 0.45; }
  100% { transform: scale(1)    rotate(360deg); opacity: 0.30; }
}
.sita-orb-core   { animation: orbBreathe 4s ease-in-out infinite; }
.sita-orb-glow   { animation: orbGlow 3.5s ease-in-out infinite; }
.sita-orb-halo   { animation: orbHaloDrift 12s linear infinite; }

/* Soft shimmer for suggestion cards on hover — light sweeps across the
   border subtly so the card feels alive without being noisy. */
@keyframes cardShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.sita-suggestion {
  position: relative;
  background-clip: padding-box;
  isolation: isolate;
}
.sita-suggestion::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    110deg,
    transparent 35%,
    rgba(52, 211, 153, 0.0) 45%,
    rgba(52, 211, 153, 0.45) 50%,
    rgba(52, 211, 153, 0.0) 55%,
    transparent 65%
  );
  background-size: 200% 100%;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: -1;
}
.sita-suggestion:hover::before {
  opacity: 1;
  animation: cardShimmer 1.6s linear infinite;
}

/* Composer focus glow — when the textarea is focused, the surrounding
   wrapper emits a soft emerald inner ring. Selector targets a wrapper
   with .sita-composer that contains the focused textarea.
   IDLE state: subtle inner highlight so the composer reads as a "card",
   not as a flat hole in the page. */
.sita-composer {
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
  box-shadow:
    0 8px 24px -12px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.sita-composer:focus-within {
  border-color: rgba(52, 211, 153, 0.40);
  box-shadow:
    0 0 0 1px rgba(52, 211, 153, 0.22),
    0 10px 36px -10px rgba(52, 211, 153, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Keyboard focus-visible rings on ALL interactive elements — replaces
   the browser default chunky outline with a subtle emerald ring that
   matches the brand. Only fires on keyboard nav, not on mouse click. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(52, 211, 153, 0.65);
  outline-offset: 2px;
  border-radius: 4px;
}
.sita-composer:focus-within textarea:focus-visible {
  outline: none;
}

/* Thinking dots — used both in the header pill and in the in-message
   placeholder. Three dots that bounce in sequence. */
@keyframes thinkBounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
  40%           { transform: translateY(-3px); opacity: 1;   }
}
.sita-think-dot       { animation: thinkBounce 1.2s ease-in-out infinite; }
.sita-think-dot:nth-child(2) { animation-delay: 0.15s; }
.sita-think-dot:nth-child(3) { animation-delay: 0.30s; }

/* Inline streaming caret — emerald instead of gray-300 so it ties to the
   SITA brand color. Slightly thinner + with a subtle glow. */
.sita-stream-caret {
  display: inline-block;
  width: 6px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: linear-gradient(180deg, rgba(110, 231, 183, 0.95), rgba(52, 211, 153, 0.7));
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.45);
  animation: caretBlink 1.05s steps(1) infinite;
}
@keyframes caretBlink {
  0%, 49%   { opacity: 0.9; }
  50%, 100% { opacity: 0.15; }
}

/* Assistant message hover affordance — desktop only. Slight lighten of
   the background so the action row visibly belongs to that message. */
@media (hover: hover) and (pointer: fine) {
  .sita-asst-bubble {
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    border-radius: 0.75rem;
    margin: 0 -0.5rem;
    padding: 0.25rem 0.5rem;
  }
  .sita-asst-bubble:hover {
    background-color: rgba(20, 20, 20, 0.55);
  }
}

/* Custom scrollbar — dark + thin, replaces the chunky native one on
   webkit. Only on the main scroll container, not all elements. */
.sita-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.sita-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.sita-scroll::-webkit-scrollbar-thumb {
  background: rgba(115, 115, 115, 0.25);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.sita-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(115, 115, 115, 0.45);
  background-clip: padding-box;
}
/* Firefox */
.sita-scroll { scrollbar-width: thin; scrollbar-color: rgba(115,115,115,0.30) transparent; }

/* Sidebar conversation item — selected variant gets a left accent stripe
   in emerald. Subtler than a full bg highlight. */
.sita-conv-active {
  position: relative;
}
.sita-conv-active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, rgba(110, 231, 183, 0.95), rgba(52, 211, 153, 0.4));
  border-radius: 999px;
}

/* Send button — gradient + glow when enabled. Stays flat when disabled
   so the contrast carries info ("can I send right now?"). */
.sita-send-btn {
  background: linear-gradient(135deg, #d4d4d4, #fafafa);
  color: #0a0a0a;
  transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.sita-send-btn:not(:disabled):hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #fafafa, #ffffff);
  box-shadow: 0 6px 20px -6px rgba(255, 255, 255, 0.35);
}
.sita-send-btn:not(:disabled):active {
  transform: translateY(0);
}
.sita-send-btn:disabled {
  background: #262626;
  color: #525252;
  box-shadow: none;
}

/* =========================================================================
   ROUND 2 of UI refinement — modals, toasts, mic button, sidebar buttons,
   attachment chips, search input, tool rail. Same emerald-on-ink palette,
   same restrained motion. Goal: nothing in the chat should still feel
   "flat tailwind defaults" — everything has subtle depth and intention.
   ========================================================================= */

/* Modal panel — glass-morphism with an emerald accent strip at the top
   (a thin gradient line) and an inner ring for depth. Replaces the
   plain `bg-ink-900 border border-ink-700`. */
.sita-modal {
  position: relative;
  background: linear-gradient(180deg, rgba(20, 20, 20, 0.92), rgba(15, 15, 15, 0.95));
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(38, 38, 38, 0.8);
  box-shadow:
    0 24px 64px -16px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.sita-modal::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(52, 211, 153, 0.0) 25%,
    rgba(52, 211, 153, 0.55) 50%,
    rgba(52, 211, 153, 0.0) 75%,
    transparent 100%
  );
  pointer-events: none;
}

/* Modal enter / exit transitions — alpine x-transition handles opacity
   + scale already, but we tweak the timing to feel snappier on enter
   and smooth on exit. */
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.sita-modal-enter {
  animation: modalIn 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Toast — slide in from the right with a tiny bounce, fade out. */
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  60%  { opacity: 1; transform: translateX(-2px); }
  to   { opacity: 1; transform: translateX(0); }
}
.sita-toast { animation: toastIn 320ms cubic-bezier(0.16, 1, 0.3, 1); }

/* Mic recording — animated ring that grows + fades, like a sonar ping.
   Layered behind the mic button so the red circle still shows + the
   ping radiates from it. */
@keyframes micPing {
  0%   { transform: scale(0.95); opacity: 0.65; }
  100% { transform: scale(1.9);  opacity: 0;    }
}
.sita-mic-ping {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: rgba(239, 68, 68, 0.45);
  animation: micPing 1.4s cubic-bezier(0.16, 1, 0.3, 1) infinite;
  pointer-events: none;
}
.sita-mic-ping.delay {
  animation-delay: 0.7s;
}

/* "New conversation" button in sidebar — gradient + lift on hover.
   Replaces the flat `hover:bg-ink-800`. */
.sita-newconv-btn {
  background: linear-gradient(180deg, rgba(38,38,38,0.55), rgba(26,26,26,0.55));
  border: 1px solid rgba(58, 58, 58, 0.5);
  transition: all 0.2s ease;
}
.sita-newconv-btn:hover {
  background: linear-gradient(180deg, rgba(58,58,58,0.65), rgba(38,38,38,0.65));
  border-color: rgba(52, 211, 153, 0.25);
  box-shadow: 0 6px 18px -8px rgba(52, 211, 153, 0.15);
}

/* Tool rail buttons — gradient bg on hover + slight indent (translateX). */
.sita-toolrail-btn {
  transition: background-color 0.18s ease, transform 0.18s ease, color 0.18s ease;
}
.sita-toolrail-btn:not(:disabled):hover {
  background-color: rgba(38, 38, 38, 0.7);
  transform: translateX(2px);
}
.sita-toolrail-btn:not(:disabled):hover .sita-toolrail-icon {
  transform: scale(1.08);
}
.sita-toolrail-icon {
  transition: transform 0.18s ease;
}

/* Attachment chip — refined: round 12px, subtle gradient, remove
   button visible at the corner with a smooth scale on hover. */
.sita-attach-chip {
  position: relative;
  border-radius: 0.625rem;
  overflow: hidden;
  border: 1px solid rgba(58, 58, 58, 0.6);
  background: linear-gradient(135deg, rgba(38,38,38,0.7), rgba(26,26,26,0.9));
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.sita-attach-chip:hover {
  border-color: rgba(52, 211, 153, 0.4);
  transform: translateY(-1px);
}
.sita-attach-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 18px; height: 18px;
  border-radius: 9999px;
  background: rgba(239, 68, 68, 0.95);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.sita-attach-chip:hover .sita-attach-remove,
.sita-attach-chip:focus-within .sita-attach-remove {
  opacity: 1;
  transform: scale(1);
}

/* Search input with icon prefix — used in the sidebar conversation search. */
.sita-search-wrap {
  position: relative;
}
.sita-search-wrap > svg {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  color: rgba(115, 115, 115, 0.7);
  pointer-events: none;
}
.sita-search-wrap > input {
  padding-left: 24px !important;
}

/* Drag overlay — replace dashed border with a glass card + dimensions */
.sita-drop-card {
  background: linear-gradient(135deg, rgba(20,20,20,0.85), rgba(15,15,15,0.92));
  border: 1.5px dashed rgba(52, 211, 153, 0.45);
  box-shadow:
    0 24px 64px -16px rgba(52, 211, 153, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Message-action button row — small icon buttons with consistent
   hover state. Was already mostly OK; this adds a unified focus ring. */
.sita-action-btn {
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.sita-action-btn:active {
  transform: scale(0.92);
}

/* Status pill in the header — wraps both "pensando" and "hablando".
   Subtle inner glow that picks up the same emerald/violet of the bg. */
.sita-status-pill {
  position: relative;
  isolation: isolate;
}
.sita-status-pill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

/* Avatar in user message — gradient + small glow on the avatar that
   appears when the user has just sent. NOT used yet but defined here
   so we have a hook if we add a user-avatar later. */

/* Sidebar section divider — replaces hard `border-t border-ink-800` with
   a horizontal gradient that fades to transparent at the edges. Reads as
   a soft separator instead of a hard line. */
.sita-divider {
  border-top: none;
  position: relative;
  margin-top: 0.25rem;
  padding-top: 0.5rem;
}
.sita-divider::before {
  content: "";
  position: absolute;
  left: 12%; right: 12%; top: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(115, 115, 115, 0.25) 30%,
    rgba(115, 115, 115, 0.35) 50%,
    rgba(115, 115, 115, 0.25) 70%,
    transparent
  );
  pointer-events: none;
}

/* Keep reduced-motion section consolidated. */
@media (prefers-reduced-motion: reduce) {
  .sita-orb-core,
  .sita-orb-glow,
  .sita-orb-halo,
  .sita-think-dot,
  .sita-stream-caret,
  .animate-fadeIn,
  .sita-suggestion:hover::before,
  .sita-modal-enter,
  .sita-toast,
  .sita-mic-ping {
    animation: none !important;
    transition: none !important;
  }
}
