/* ================================================================
   Chat fiscal — Professional Theme
   ================================================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --taxgpt-emerald: #10b981;
  --taxgpt-teal: #0d9488;
  --taxgpt-gradient: linear-gradient(135deg, #10b981 0%, #0d9488 100%);
}

body {
  font-family: var(--font-sans) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ================================================================
   Animations
   ================================================================ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes subtlePulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes progressSlide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}


/* ================================================================
   Hide Chainlit Branding
   ================================================================ */

a[href*="chainlit"],
a[href*="github.com/Chainlit"] {
  display: none !important;
}
.watermark,
[class*="watermark"] {
  display: none !important;
}


/* ================================================================
   User Messages — gradient bubble
   ================================================================ */

/* User message bubble — .bg-accent.rounded-3xl container */
.step .bg-accent.rounded-3xl {
  background: linear-gradient(135deg,
    hsl(160 84% 39% / 0.85) 0%,
    hsl(170 70% 32% / 0.85) 100%) !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: 0 2px 12px hsl(160 84% 39% / 0.15);
  animation: fadeInUp 0.3s ease-out both;
}

/* User message text — keep white for contrast on green */
.step .bg-accent.rounded-3xl .message-content {
  color: #fff !important;
}


/* ================================================================
   Assistant Messages — clean card feel
   ================================================================ */

/* Each step animates in */
.step {
  animation: fadeInUp 0.35s ease-out both;
}


/* ================================================================
   Chat Input Area
   ================================================================ */

/* Input container — the rounded composer box */
main .dark\:bg-card.rounded-3xl {
  border: 1px solid hsla(220, 12%, 20%, 1) !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

main .dark\:bg-card.rounded-3xl:focus-within {
  border-color: hsla(160, 84%, 39%, 0.5) !important;
  box-shadow: 0 0 0 3px hsla(160, 84%, 39%, 0.1),
              0 1px 3px hsla(0, 0%, 0%, 0.2) !important;
}


/* ================================================================
   Send Button — gradient accent
   ================================================================ */

/* The primary-colored circular send button */
button[class*="bg-primary"]:not([class*="sidebar"]) {
  background: var(--taxgpt-gradient) !important;
  border: none !important;
  box-shadow: 0 2px 8px hsl(160 84% 39% / 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button[class*="bg-primary"]:not([class*="sidebar"]):hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px hsl(160 84% 39% / 0.4);
}


/* ================================================================
   Sidebar (ElementSidebar) — glassmorphism
   ================================================================ */

/* The sidebar aside panel */
aside.relative {
  animation: slideInRight 0.3s ease-out both;
}

/* The card container inside the sidebar */
aside.relative > div.bg-card {
  background-color: hsla(220, 16%, 10%, 0.7) !important;
  background-image: none !important;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-color: hsla(160, 84%, 39%, 0.12) !important;
  border-radius: 0.75rem !important;
}

/* Sidebar title */
aside.relative > div.bg-card > div:first-child {
  font-weight: 600 !important;
  letter-spacing: -0.01em;
  border-bottom: 1px solid hsla(160, 84%, 39%, 0.15);
  color: hsl(160, 60%, 70%) !important;
}

/* Citation card separators inside sidebar */
aside.relative hr {
  border-color: hsl(220 12% 18%) !important;
  margin: 0.5rem 0 !important;
}

/* Blockquotes in sidebar (law excerpts) */
aside.relative blockquote {
  border-left: 3px solid hsl(160 84% 39% / 0.4) !important;
  background: hsl(220 16% 8% / 0.5) !important;
  border-radius: 0 0.5rem 0.5rem 0 !important;
  padding: 0.75rem 1rem !important;
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
  color: hsl(210 15% 72%) !important;
}


/* ================================================================
   Thread Sidebar (left panel — chat history)
   ================================================================ */

/* Active thread highlight */
nav a[aria-current="page"],
nav li:has(a[aria-current]) {
  background: hsl(160 84% 39% / 0.1) !important;
  border-left: 2px solid var(--taxgpt-emerald) !important;
}


/* ================================================================
   Action Buttons (copy, feedback, follow-ups, summary)
   ================================================================ */

/* Action button row — add breathing room */
.step div.-ml-1\.5.flex.items-center.flex-wrap {
  gap: 4px;
  margin-left: 0 !important;
  margin-top: 2px;
}

/* Icon buttons (copy, thumbs) — transparent, ghost style */
.step div.-ml-1\.5 button[class*="h-9"][class*="w-9"] {
  color: hsl(var(--muted-foreground));
  background: transparent !important;
  border-color: transparent !important;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.step div.-ml-1\.5 button[class*="h-9"][class*="w-9"]:hover {
  background-color: hsl(160 84% 39% / 0.08);
  color: hsl(160 60% 65%);
}

/* Text action buttons (Busca mas, Generar resumen, Ver fundamentos) */
.step div.-ml-1\.5 button[class*="h-9"][class*="px-3"] {
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: 9999px;
  padding: 0 12px;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.step div.-ml-1\.5 button[class*="h-9"][class*="px-3"]:hover {
  background-color: hsl(160 84% 39% / 0.08);
  border-color: hsl(160 84% 39% / 0.25);
  color: hsl(160 60% 65%);
}


/* ================================================================
   Login Page — Light theme to match landing & registration pages
   JS intercepts window.theme BEFORE React for flash-free light mode.
   JS also adds body.taxgpt-login-page for CSS scoping.
   ================================================================ */

/* CSS-variable fallback (reinforces the JS theme intercept) */
.taxgpt-login-page {
  --background: 40 20% 98%;
  --foreground: 230 20% 26%;
  --card: 0 0% 100%;
  --card-foreground: 230 20% 26%;
  --primary: 160 84% 39%;
  --primary-foreground: 0 0% 100%;
  --secondary: 40 10% 94%;
  --secondary-foreground: 230 20% 26%;
  --muted: 40 10% 94%;
  --muted-foreground: 220 5% 46%;
  --accent: 40 10% 94%;
  --accent-foreground: 230 20% 26%;
  --border: 40 8% 90%;
  --input: 40 8% 90%;
  --ring: 160 84% 39%;
}

/* Page background */
.taxgpt-login-page,
.taxgpt-login-page #root {
  background-color: #faf9f7 !important;
}

/* Full-height centred layout */
.taxgpt-login-page .min-h-svh {
  background: #faf9f7 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Card container — transparent (the form itself is the card) */
.taxgpt-login-page [class*="bg-card"] {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Form card — white, rounded, soft shadow */
.taxgpt-login-page form {
  background: #ffffff !important;
  border: 1px solid #e8e7e3 !important;
  border-radius: 16px !important;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.06) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 2rem !important;
  width: 100%;
  max-width: 380px;
  animation: fadeInUp 0.4s ease-out both;
}

/* Input fields — clean light style */
.taxgpt-login-page input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]) {
  background: #ffffff !important;
  border: 1px solid #e0dfd9 !important;
  color: #1a1a2e !important;
  border-radius: 10px !important;
  height: 44px !important;
  font-size: 0.95rem !important;
  padding: 0 14px !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.taxgpt-login-page input:focus {
  border-color: #10b981 !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
  outline: none !important;
}

.taxgpt-login-page input::placeholder {
  color: #a0a4b8 !important;
}

/* Labels */
.taxgpt-login-page label {
  color: #1a1a2e !important;
  font-size: 0.88rem !important;
  font-weight: 500 !important;
}

/* Submit button — emerald gradient (scoped to login) */
.taxgpt-login-page button[type="submit"] {
  background: var(--taxgpt-gradient) !important;
  border: none !important;
  font-weight: 600 !important;
  font-size: 0.95rem !important;
  letter-spacing: 0.01em;
  color: #fff !important;
  border-radius: 10px !important;
  height: 44px !important;
  box-shadow: 0 2px 12px hsl(160 84% 39% / 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.taxgpt-login-page button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px hsl(160 84% 39% / 0.35);
}

/* All text — dark colors on light bg */
.taxgpt-login-page h1,
.taxgpt-login-page h2,
.taxgpt-login-page h3 {
  color: #1a1a2e !important;
}

.taxgpt-login-page p,
.taxgpt-login-page span {
  color: #4a4f6a !important;
}

/* Links — emerald */
.taxgpt-login-page a:not(.taxgpt-login-logo a) {
  color: #10b981 !important;
}

/* JS-injected register link */
.taxgpt-register-link {
  color: #4a4f6a !important;
}

.taxgpt-register-link a {
  color: #10b981 !important;
  font-weight: 600;
  transition: color 0.15s ease;
}

.taxgpt-register-link a:hover {
  color: #059669 !important;
}

/* JS-injected logo above form */
.taxgpt-login-logo {
  text-align: center;
  margin-bottom: 12px;
}

.taxgpt-login-logo svg {
  width: 170px;
  height: auto;
}


/* ================================================================
   Scrollbar Styling (Webkit)
   ================================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: hsl(220 12% 22%);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: hsl(220 12% 30%);
}


/* ================================================================
   Typography Refinements
   ================================================================ */

/* Message text readability */
main p, main li, main td {
  line-height: 1.7;
}

/* Bold headings in messages */
main h1, main h2, main h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
}

/* Inline code */
main code:not(pre code) {
  background: hsl(220 16% 14%) !important;
  padding: 0.15em 0.4em;
  border-radius: 0.3rem;
  font-size: 0.9em;
}

/* Citation footer separator */
main hr {
  border-color: hsl(160 84% 39% / 0.2) !important;
  margin: 1.5rem 0 !important;
}

/* "Fundamento legal" bold label in footer */
main strong {
  color: hsl(160 60% 70%);
}


/* ================================================================
   Collapsible Citation Block (class-based toggle)
   ================================================================ */

/* The "Fundamento legal" heading becomes a clickable toggle */
.citation-toggle {
  cursor: pointer;
  user-select: none;
  margin-top: 0.75rem !important;
  padding: 0.5rem 0 0.25rem !important;
}

/* Replace the bold text with a flex row + chevron */
.citation-toggle .font-bold,
.citation-toggle strong {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: hsl(160 60% 70%);
}

/* Chevron indicator */
.citation-toggle::before {
  content: "\25B6";
  font-size: 0.6rem;
  color: hsl(160 84% 39% / 0.6);
  display: inline-block;
  transition: transform 0.2s ease;
  margin-right: 0.35rem;
}

.citation-toggle[data-collapsed="false"]::before {
  transform: rotate(90deg);
}

/* Hide/show the citation list */
.citation-list.citation-hidden {
  display: none !important;
}

/* Style the visible citation list */
.citation-list {
  animation: fadeInUp 0.25s ease-out both;
  margin-top: 0.25rem !important;
}

.citation-list li {
  font-size: 0.85rem;
  color: hsl(210 15% 68%);
  padding: 0.15rem 0;
  line-height: 1.5;
}

.citation-list li .font-bold,
.citation-list li strong {
  color: hsl(160 50% 65%);
  font-weight: 500;
}

/* Hide the --- separator above citations */
.citation-sep {
  display: none !important;
}


/* ================================================================
   Thinking Indicator
   ================================================================ */

/* Chainlit renders *text* as <span class="italic"> inside
   <div role="article"> inside .prose.  Target thinking messages. */
.prose span.italic:only-child {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  animation: subtlePulse 1.5s ease-in-out infinite;
  color: hsl(160 50% 55%) !important;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

/* Spinning circle before the status text */
.prose span.italic:only-child::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid hsl(160 84% 39% / 0.25);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Indeterminate progress bar below — on the parent article div */
.prose div[role="article"]:has(> span.italic:only-child) {
  position: relative;
  padding-bottom: 12px;
}

.prose div[role="article"]:has(> span.italic:only-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #10b981, transparent);
  border-radius: 1px;
  animation: progressSlide 1.5s ease-in-out infinite;
}
