/* ═══════════════════════════════════════════════════
   PlanAuto Global Styles
   DaisyUI v4 + TailwindCSS Companion Stylesheet
   ═══════════════════════════════════════════════════ */

/* ── Reduced Motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── HTMX Transitions ───────────────────────────── */
.htmx-swapping {
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

.htmx-added {
  animation: fadeSlideIn 300ms ease-out;
}

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

/* ── Scrollbar ──────────────────────────────────── */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: oklch(var(--bc) / 0.1) transparent;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

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

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: oklch(var(--bc) / 0.1);
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: oklch(var(--bc) / 0.2);
}

/* ── Toggle Smooth Animation ───────────────────── */
.toggle {
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle::before {
  transition: translate 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ── Card Hover Effect ──────────────────────────── */
.card-hover {
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px oklch(var(--bc) / 0.1), 0 4px 10px -6px oklch(var(--bc) / 0.05);
}

/* ── Button Active Feedback ─────────────────────── */
.btn:active:not(:disabled):not(.btn-disabled) {
  transform: scale(0.97);
}

/* ── HTMX Request Loading State for Buttons ─────── */
.htmx-request .btn-loading-indicator {
  display: inline-flex;
}

.btn-loading-indicator {
  display: none;
}

button.htmx-request,
a.htmx-request {
  pointer-events: none;
  opacity: 0.7;
}

button.htmx-request::after {
  content: '';
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 0.5em;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ── Skeleton Loader ────────────────────────────── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.skeleton-animate {
  animation: skeleton-pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ── Page Enter Animation ───────────────────────── */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-page-enter {
  animation: pageEnter 400ms ease-out;
}

/* ── Chat Message Slide-in ──────────────────────── */
@keyframes chatSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-chat-slide {
  animation: chatSlideIn 200ms ease-out;
}

/* ── Badge Pop-in ───────────────────────────────── */
@keyframes badgePopIn {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-badge-pop {
  animation: badgePopIn 300ms ease-out;
}


/* ═══════════════════════════════════════════════════
   Modern Chat UI (ChatGPT/Claude-inspired)
   ═══════════════════════════════════════════════════ */

/* ── Remove DaisyUI Chat Bubble Arrows ────────── */
.chat-bubble::before {
  display: none !important;
}

/* ── Modern Bubble Shape ──────────────────────── */
.chat-start .chat-bubble {
  border-radius: 1.25rem 1.25rem 1.25rem 0.375rem;
}

.chat-end .chat-bubble {
  border-radius: 1.25rem 1.25rem 0.375rem 1.25rem;
}

/* ── AI Avatar ────────────────────────────────── */
.ai-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.5rem;
  background: oklch(var(--p) / 0.12);
  color: oklch(var(--p));
  flex-shrink: 0;
}

[data-theme="dark"] .ai-avatar {
  background: oklch(var(--p) / 0.15);
}

/* ── AI Chat Bubble ───────────────────────────── */
.chat-bubble-ai {
  background: oklch(var(--bc) / 0.03);
  color: oklch(var(--bc));
  border: 1px solid oklch(var(--bc) / 0.06);
  max-width: 92%;
}

[data-theme="dark"] .chat-bubble-ai {
  background: oklch(var(--bc) / 0.055);
  color: oklch(var(--bc));
  border: 1px solid oklch(var(--bc) / 0.08);
}

/* ── User Chat Bubble (Primary) Refinement ──── */
.chat-bubble-primary {
  max-width: 80%;
}

/* ── Landing Mockup Browser Polish ────────────── */
[data-theme="dark"] .mockup-browser .chat-bubble-ai {
  background-color: oklch(var(--bc) / 0.06);
  border: 1px solid oklch(var(--bc) / 0.06);
}

[data-theme="dark"] .mockup-browser .chat-bubble-primary {
  border: 1px solid oklch(var(--p) / 0.3);
}

/* ── Prompt Input Container ───────────────────── */
.prompt-input-container {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  border-radius: 1.25rem;
  border: 1px solid oklch(var(--bc) / 0.1);
  background: oklch(var(--b1));
  box-shadow: 0 1px 6px oklch(var(--bc) / 0.04), 0 0 0 1px oklch(var(--bc) / 0.02);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.prompt-input-container:focus-within {
  border-color: oklch(var(--p) / 0.3);
  box-shadow: 0 1px 8px oklch(var(--p) / 0.06), 0 0 0 1px oklch(var(--p) / 0.08);
}

[data-theme="dark"] .prompt-input-container {
  background: oklch(var(--bc) / 0.04);
  border-color: oklch(var(--bc) / 0.08);
  box-shadow: 0 1px 8px oklch(var(--bc) / 0.08);
}

[data-theme="dark"] .prompt-input-container:focus-within {
  border-color: oklch(var(--p) / 0.25);
  box-shadow: 0 1px 12px oklch(var(--p) / 0.08);
}

/* ── Suggestion Chips ─────────────────────────── */
.chip-suggestion {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  border-radius: 9999px;
  border: 1px solid oklch(var(--bc) / 0.12);
  color: oklch(var(--bc) / 0.7);
  background: transparent;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}

.chip-suggestion:hover {
  background: oklch(var(--p) / 0.08);
  border-color: oklch(var(--p) / 0.3);
  color: oklch(var(--p));
}

.chip-suggestion:active {
  transform: scale(0.96);
}


/* ═══════════════════════════════════════════════════
   Prose (Markdown Rendering in Chat)
   ═══════════════════════════════════════════════════ */

.prose-chat {
  font-size: 0.9375rem;
  line-height: 1.65;
}

.prose-chat h1, .prose-chat h2, .prose-chat h3 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 600;
}

.prose-chat p {
  margin-bottom: 0.5em;
}

.prose-chat ul, .prose-chat ol {
  margin-left: 1.25em;
  margin-bottom: 0.5em;
}

.prose-chat code {
  padding: 0.15em 0.35em;
  border-radius: 0.25em;
  font-size: 0.875em;
  background: oklch(var(--bc) / 0.06);
}

.prose-chat pre {
  padding: 0.75em 1em;
  border-radius: 0.75em;
  overflow-x: auto;
  background: oklch(var(--bc) / 0.04);
  border: 1px solid oklch(var(--bc) / 0.06);
  margin-bottom: 0.75em;
}

.prose-chat pre code {
  padding: 0;
  background: none;
}

.prose-chat blockquote {
  border-left: 3px solid oklch(var(--p) / 0.4);
  padding-left: 1em;
  margin: 0.75em 0;
  color: oklch(var(--bc) / 0.7);
}

.prose-chat table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75em 0;
  font-size: 0.875em;
}

.prose-chat th, .prose-chat td {
  padding: 0.5em 0.75em;
  border: 1px solid oklch(var(--bc) / 0.1);
  text-align: left;
}

.prose-chat th {
  background: oklch(var(--bc) / 0.04);
  font-weight: 600;
}

/* ── Dark Mode: Prose ─────────────────────────── */
[data-theme="dark"] .prose-chat code {
  background: oklch(var(--bc) / 0.1);
}

[data-theme="dark"] .prose-chat pre {
  background: oklch(var(--bc) / 0.06);
  border-color: oklch(var(--bc) / 0.08);
}

[data-theme="dark"] .prose-chat pre code {
  border: none;
}

[data-theme="dark"] .prose-chat blockquote {
  color: oklch(var(--bc) / 0.85);
  border-left-color: oklch(var(--p) / 0.5);
}

[data-theme="dark"] .prose-chat th {
  background: oklch(var(--bc) / 0.08);
}

[data-theme="dark"] .prose-chat th,
[data-theme="dark"] .prose-chat td {
  border-color: oklch(var(--bc) / 0.1);
}


/* ═══════════════════════════════════════════════════
   Streaming & Animations
   ═══════════════════════════════════════════════════ */

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

.streaming-cursor::after {
  content: '\25AE';
  animation: blink 0.8s step-end infinite;
  margin-left: 2px;
  color: oklch(var(--p));
}

@keyframes ping-slow {
  0% { transform: scale(1); opacity: 0.4; }
  75%, 100% { transform: scale(1.8); opacity: 0; }
}

.animate-ping-slow {
  animation: ping-slow 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}


/* ═══════════════════════════════════════════════════
   Global UI Polish
   ═══════════════════════════════════════════════════ */

/* ── Focus Ring ───────────────────────────────── */
:focus-visible {
  outline: 2px solid oklch(var(--p));
  outline-offset: 2px;
}

/* ── Content Scroll ───────────────────────────── */
.content-scroll {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: oklch(var(--bc) / 0.1) transparent;
}

/* ── Theme Transition ─────────────────────────── */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition: background-color 300ms ease,
              color 200ms ease,
              border-color 200ms ease,
              box-shadow 200ms ease,
              fill 200ms ease !important;
}

/* ── Gradient Text ────────────────────────────── */
.text-gradient-primary {
  background: linear-gradient(135deg, oklch(var(--p)), oklch(var(--s)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Toast ────────────────────────────────────── */
.toast .alert {
  transition: all 300ms ease;
}


/* ═══════════════════════════════════════════════════
   Landing Page
   ═══════════════════════════════════════════════════ */

.hero-gradient {
  background: linear-gradient(
    180deg,
    oklch(var(--b1)) 0%,
    oklch(var(--p) / 0.08) 50%,
    oklch(var(--b2)) 100%
  );
}

.dot-pattern {
  background-image: radial-gradient(
    circle,
    oklch(var(--bc) / 0.12) 1px,
    transparent 1px
  );
  background-size: 24px 24px;
}

.scroll-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.stagger-children .scroll-reveal:nth-child(1) { transition-delay: 0ms; }
.stagger-children .scroll-reveal:nth-child(2) { transition-delay: 100ms; }
.stagger-children .scroll-reveal:nth-child(3) { transition-delay: 200ms; }
.stagger-children .scroll-reveal:nth-child(4) { transition-delay: 300ms; }

.glow-primary {
  box-shadow: 0 0 20px oklch(var(--p) / 0.3);
  transition: box-shadow 300ms ease;
}

.glow-primary:hover {
  box-shadow: 0 0 30px oklch(var(--p) / 0.45);
}


/* ═══════════════════════════════════════════════════
   Document Preview (PDF-like Markdown Rendering)
   ═══════════════════════════════════════════════════ */

.prose-document {
  font-family: 'Pretendard Variable', 'Pretendard', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.8;
  color: oklch(var(--bc));
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ── Document Page Container ─────────────────────── */
.document-page {
  background: white;
  border-radius: 0.5rem;
  box-shadow:
    0 1px 3px oklch(var(--bc) / 0.08),
    0 4px 12px oklch(var(--bc) / 0.04);
  padding: 3rem 3.5rem;
  min-height: 400px;
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid oklch(var(--bc) / 0.06);
  color: #1a1a2e;
}

[data-theme="dark"] .document-page {
  background: oklch(var(--b1));
  border-color: oklch(var(--bc) / 0.08);
  box-shadow:
    0 1px 3px oklch(var(--bc) / 0.12),
    0 4px 16px oklch(var(--bc) / 0.06);
  color: oklch(var(--bc));
}

@media (max-width: 768px) {
  .document-page {
    padding: 1.5rem 1.25rem;
  }
}

/* ── Headings ────────────────────────────────────── */
.prose-document h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid oklch(var(--p) / 0.2);
  line-height: 1.3;
}

.prose-document h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid oklch(var(--bc) / 0.08);
  line-height: 1.35;
}

.prose-document h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.prose-document h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

/* ── Paragraphs ──────────────────────────────────── */
.prose-document p {
  margin-bottom: 0.75rem;
  text-align: justify;
}

/* ── Lists ───────────────────────────────────────── */
.prose-document ul {
  list-style-type: disc;
  margin-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.prose-document ol {
  list-style-type: decimal;
  margin-left: 1.5rem;
  margin-bottom: 0.75rem;
}

.prose-document li {
  margin-bottom: 0.25rem;
  line-height: 1.7;
}

.prose-document li > ul,
.prose-document li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

/* ── Table ───────────────────────────────────────── */
.prose-document table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.prose-document th {
  background: oklch(var(--bc) / 0.04);
  font-weight: 600;
  padding: 0.625rem 0.75rem;
  border: 1px solid oklch(var(--bc) / 0.12);
  text-align: left;
}

.prose-document td {
  padding: 0.5rem 0.75rem;
  border: 1px solid oklch(var(--bc) / 0.1);
}

.prose-document tbody tr:nth-child(even) {
  background: oklch(var(--bc) / 0.02);
}

[data-theme="dark"] .prose-document th {
  background: oklch(var(--bc) / 0.08);
}

[data-theme="dark"] .prose-document tbody tr:nth-child(even) {
  background: oklch(var(--bc) / 0.04);
}

/* ── Blockquote ──────────────────────────────────── */
.prose-document blockquote {
  border-left: 3px solid oklch(var(--p) / 0.3);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: oklch(var(--p) / 0.03);
  border-radius: 0 0.375rem 0.375rem 0;
  color: oklch(var(--bc) / 0.8);
}

[data-theme="dark"] .prose-document blockquote {
  background: oklch(var(--p) / 0.06);
  border-left-color: oklch(var(--p) / 0.4);
  color: oklch(var(--bc) / 0.9);
}

/* ── Code ────────────────────────────────────────── */
.prose-document code {
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.85em;
  background: oklch(var(--bc) / 0.06);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.prose-document pre {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  background: oklch(var(--bc) / 0.04);
  border: 1px solid oklch(var(--bc) / 0.08);
  margin: 1rem 0;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.prose-document pre code {
  padding: 0;
  background: none;
  border-radius: 0;
}

[data-theme="dark"] .prose-document code {
  background: oklch(var(--bc) / 0.1);
}

[data-theme="dark"] .prose-document pre {
  background: oklch(var(--bc) / 0.06);
  border-color: oklch(var(--bc) / 0.1);
}

/* ── Horizontal Rule ─────────────────────────────── */
.prose-document hr {
  border: none;
  border-top: 1px solid oklch(var(--bc) / 0.1);
  margin: 1.5rem 0;
}

/* ── Strong / Emphasis ───────────────────────────── */
.prose-document strong {
  font-weight: 600;
}

.prose-document em {
  font-style: italic;
}

/* ── Links ───────────────────────────────────────── */
.prose-document a {
  color: oklch(var(--p));
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose-document a:hover {
  color: oklch(var(--p) / 0.8);
}

/* ── Dashboard Stats (mobile) ─────────────────────── */
@media (max-width: 640px) {
  .stats-horizontal .stat {
    min-width: 5rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

/* ── Document Empty State ────────────────────────── */
.document-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: oklch(var(--bc) / 0.4);
  font-size: 0.9375rem;
}
