/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Authentication Layout Utilities */
.auth-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 1.5rem 1rem;
}

@media (min-width: 640px) {
  .auth-container {
    min-height: calc(100vh - 4rem);
    justify-content: center;
    padding: 3rem 1.5rem;
  }
}

@media (min-width: 1024px) {
  .auth-container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.loader {
  border-top-color: #3498db;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Text Overflow Utilities for Hardening */
.text-overflow-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.word-break {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.break-all {
  word-break: break-all;
}

/* Flex/Grid overflow prevention */
.flex-overflow-safe {
  min-width: 0;
  overflow: hidden;
}

.grid-overflow-safe {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Animation Delay Utilities for Staggered Animations */
.animate-delay-100 {
  animation-delay: 100ms;
}

.animate-delay-150 {
  animation-delay: 150ms;
}

.animate-delay-200 {
  animation-delay: 200ms;
}

.animate-delay-300 {
  animation-delay: 300ms;
}

/* Progress Bar Width Utilities */
/* These work with CSS custom properties set via JavaScript */
.progress-bar-fill {
  width: var(--progress-width, 0%);
  transition: width 0.3s ease-out, opacity 0.3s ease-out;
}

/* Progress bar visibility states */
.progress-bar-hidden {
  opacity: 0;
}

.progress-bar-visible {
  opacity: 1;
}

/* Focus Indicator Utilities */
/* Standardized focus ring styles consistent with design system */

/* Base focus ring - always visible, high contrast */
.focus-ring {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Focus ring with primary brand color (default) */
.focus-ring-primary {
  @apply focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 focus:outline-none;
}

/* Focus ring for error states */
.focus-ring-error {
  @apply focus:ring-2 focus:ring-error-500 focus:ring-offset-2 focus:outline-none;
}

/* Focus ring for success states */
.focus-ring-success {
  @apply focus:ring-2 focus:ring-success-500 focus:ring-offset-2 focus:outline-none;
}

/* Focus ring for warning states */
.focus-ring-warning {
  @apply focus:ring-2 focus:ring-warning-500 focus:ring-offset-2 focus:outline-none;
}

/* Focus ring for neutral/secondary actions */
.focus-ring-neutral {
  @apply focus:ring-2 focus:ring-neutral-500 focus:ring-offset-2 focus:outline-none;
}

/* Focus ring inset (for filled elements like inputs) */
.focus-ring-inset-primary {
  @apply focus:ring-2 focus:ring-inset focus:ring-primary-500 focus:outline-none;
}

.focus-ring-inset-error {
  @apply focus:ring-2 focus:ring-inset focus:ring-error-500 focus:outline-none;
}

/* Focus visible only - respects user's prefers-reduced-motion setting */
.focus-visible-only {
  @apply focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:outline-none;
}

/* High contrast focus indicators for better accessibility */
@media (prefers-contrast: high) {
  .focus-ring-primary,
  .focus-ring-error,
  .focus-ring-success,
  .focus-ring-warning,
  .focus-ring-neutral {
    outline-width: 3px;
    outline-offset: 2px;
  }
}

/* Visible focus indicator - never removes focus ring */
.focus-always-visible:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Skip link focus styles */
.skip-link {
  @apply sr-only focus:not-sr-only focus:absolute focus:top-4 focus:left-4 focus:z-50 focus:px-4 focus:py-2 focus:bg-primary-600 focus:text-white focus:rounded-lg;
}

/* ============================================
   MARKDOWN CONTENT STYLES FOR CHAT MESSAGES
   These styles apply to rendered markdown within
   [data-message-content] elements in chat bubbles
   ============================================ */

[data-message-content] {
  /* Base typography */
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================
   PARAGRAPHS
   ============================================ */
[data-message-content] p {
  margin: 0.5em 0;
}

[data-message-content] p:first-child {
  margin-top: 0;
}

[data-message-content] p:last-child {
  margin-bottom: 0;
}

/* Remove margin after headings if followed by paragraph */
[data-message-content] h1 + p,
[data-message-content] h2 + p,
[data-message-content] h3 + p {
  margin-top: 0.25em;
}

/* ============================================
   HEADINGS
   ============================================ */
[data-message-content] h1,
[data-message-content] h2,
[data-message-content] h3,
[data-message-content] h4,
[data-message-content] h5,
[data-message-content] h6 {
  font-weight: 600;
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  line-height: 1.3;
  color: rgb(17 24 39); /* text-neutral-900 */
}

[data-message-content] h1 {
  font-size: 1.4em;
  border-bottom: 1px solid rgb(229 231 235);
  padding-bottom: 0.3em;
}

[data-message-content] h2 {
  font-size: 1.25em;
  border-bottom: 1px solid rgb(243 244 246);
  padding-bottom: 0.25em;
}

[data-message-content] h3 {
  font-size: 1.1em;
}

[data-message-content] h4 {
  font-size: 1em;
}

[data-message-content] h5,
[data-message-content] h6 {
  font-size: 0.95em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   LISTS
   ============================================ */
[data-message-content] ul,
[data-message-content] ol {
  margin: 0.75em 0;
  padding-left: 1.5em;
}

[data-message-content] ul {
  list-style-type: disc;
}

[data-message-content] ol {
  list-style-type: decimal;
}

[data-message-content] li {
  margin: 0.35em 0;
  line-height: 1.5;
}

[data-message-content] li > p {
  margin: 0.25em 0;
}

/* Nested lists */
[data-message-content] ul ul,
[data-message-content] ol ol,
[data-message-content] ul ol,
[data-message-content] ol ul {
  margin: 0.25em 0;
}

[data-message-content] ul ul {
  list-style-type: circle;
}

[data-message-content] ul ul ul {
  list-style-type: square;
}

/* ============================================
   CODE & INLINE CODE
   ============================================ */

/* Inline code */
[data-message-content] code {
  background-color: rgb(243 244 246); /* bg-neutral-100 */
  color: rgb(239 68 68); /* text-error-600 for contrast */
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875em;
  font-weight: 500;
  border: 1px solid rgb(229 231 235); /* border-neutral-200 */
}

/* Code blocks */
[data-message-content] pre {
  background-color: rgb(17 24 39); /* bg-neutral-900 - dark for contrast */
  color: rgb(243 244 246); /* text-neutral-100 */
  border: 1px solid rgb(75 85 99); /* border-neutral-600 */
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1em 0;
  font-size: 0.875em;
  line-height: 1.5;
}

[data-message-content] pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  border: none;
  font-weight: 400;
}

/* ============================================
   BLOCKQUOTES
   ============================================ */
[data-message-content] blockquote {
  border-left: 4px solid rgb(99 102 241); /* border-indigo-500 */
  padding: 0.75em 1rem;
  margin: 1em 0;
  background-color: rgb(238 242 255); /* bg-indigo-50 */
  border-radius: 0 0.375rem 0.375rem 0;
  color: rgb(55 65 81); /* text-neutral-700 */
}

[data-message-content] blockquote p {
  margin: 0;
}

[data-message-content] blockquote p:first-child {
  margin-top: 0;
}

[data-message-content] blockquote p:last-child {
  margin-bottom: 0;
}

/* ============================================
   TABLES
   ============================================ */

/* Table wrapper for horizontal scroll */
[data-message-content] > table {
  display: block;
  overflow-x: auto;
  margin: 1em 0;
  max-width: 100%;
  border-radius: 0.5rem;
  border: 1px solid rgb(229 231 235); /* border-neutral-200 */
  font-size: 0.8125em;
}

[data-message-content] table {
  border-collapse: collapse;
  width: 100%;
  min-width: 500px; /* Ensure minimum width for scrolling */
}

/* Table header */
[data-message-content] thead {
  background-color: rgb(243 244 246); /* bg-neutral-100 */
  border-bottom: 2px solid rgb(209 213 219); /* border-neutral-300 */
}

[data-message-content] thead th {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75em;
  color: rgb(55 65 81); /* text-neutral-700 */
  text-align: left;
}

/* Table cells */
[data-message-content] th,
[data-message-content] td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid rgb(229 231 235); /* border-neutral-200 */
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

[data-message-content] td {
  color: rgb(55 65 81); /* text-neutral-700 */
}

/* Zebra striping for table rows */
[data-message-content] tbody tr:nth-child(even) {
  background-color: rgb(249 250 251); /* bg-neutral-50 */
}

[data-message-content] tbody tr:hover {
  background-color: rgb(243 244 246); /* bg-neutral-100 */
}

/* Last row border */
[data-message-content] tbody tr:last-child td {
  border-bottom: none;
}

/* Alignments */
[data-message-content] th[align="center"],
[data-message-content] td[align="center"] {
  text-align: center;
}

[data-message-content] th[align="right"],
[data-message-content] td[align="right"] {
  text-align: right;
}

/* ============================================
   HORIZONTAL RULES
   ============================================ */
[data-message-content] hr {
  border: none;
  border-top: 2px solid rgb(229 231 235); /* border-neutral-200 */
  margin: 1.5em 0;
}

[data-message-content] hr + * {
  margin-top: 0;
}

/* ============================================
   LINKS
   ============================================ */
[data-message-content] a {
  color: rgb(37 99 235); /* text-primary-600 */
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color 0.15s ease;
}

[data-message-content] a:hover {
  color: rgb(29 78 216); /* text-primary-700 */
  text-decoration-thickness: 2px;
}

[data-message-content] a:visited {
  color: rgb(109 40 217); /* text-purple-600 */
}

/* ============================================
   TEXT FORMATTING
   ============================================ */
[data-message-content] strong {
  font-weight: 600;
  color: rgb(17 24 39); /* text-neutral-900 */
}

[data-message-content] em {
  font-style: italic;
  color: rgb(55 65 81); /* text-neutral-700 */
}

[data-message-content] del,
[data-message-content] s {
  text-decoration: line-through;
  color: rgb(156 163 175); /* text-neutral-400 */
}

[data-message-content] sub,
[data-message-content] sup {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

[data-message-content] sup {
  top: -0.5em;
}

[data-message-content] sub {
  bottom: -0.25em;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

/* Smaller screens - reduce table padding */
@media (max-width: 640px) {
  [data-message-content] th,
  [data-message-content] td {
    padding: 0.5rem 0.625rem;
    font-size: 0.75em;
    max-width: 120px;
  }

  [data-message-content] table {
    min-width: 400px;
  }

  [data-message-content] h1 {
    font-size: 1.25em;
  }

  [data-message-content] h2 {
    font-size: 1.15em;
  }
}

/* ============================================
   UTILITY: Message bubble scroll
   ============================================ */
[data-message-bubble] {
  overflow-x: auto;
  max-width: 100%;
}

