/* ==========================================================================
   Utilities
   Reusable utility classes for visibility, text, layout, and decoration.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Visibility
   --------------------------------------------------------------------------- */
.is-hidden {
  display: none !important;
}

.is-visible {
  display: block !important;
}

.is-visible-flex {
  display: flex !important;
}

.is-visible-grid {
  display: grid !important;
}

.is-invisible {
  visibility: hidden !important;
}

/* Screen-reader only — visible to assistive technology, hidden visually */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

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

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

.mono {
  font-family: var(--font-mono);
}

.text-accent {
  color: var(--accent);
}

.text-success {
  color: var(--color-success);
}

.text-error {
  color: var(--color-error);
}

.text-warning {
  color: var(--color-warning);
}

.text-info {
  color: var(--color-info);
}

.text-sell {
  color: var(--color-sell);
}

.text-primary {
  color: var(--text-primary);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-muted {
  color: var(--text-muted);
}

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md   { font-size: var(--text-md); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }

.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

.uppercase   { text-transform: uppercase; }
.capitalize  { text-transform: capitalize; }

/* ---------------------------------------------------------------------------
   Layout Helpers
   --------------------------------------------------------------------------- */
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.flex-row       { flex-direction: row; }
.flex-wrap      { flex-wrap: wrap; }
.flex-1         { flex: 1; }
.flex-shrink-0  { flex-shrink: 0; }

.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.items-end      { align-items: flex-end; }
.items-stretch  { align-items: stretch; }

.justify-center  { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.justify-start   { justify-content: flex-start; }

.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-5  { gap: var(--space-5); }
.gap-6  { gap: var(--space-6); }

.grid          { display: grid; }
.grid-cols-2   { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3   { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4   { grid-template-columns: repeat(4, 1fr); }

/* ---------------------------------------------------------------------------
   Spacing Helpers
   --------------------------------------------------------------------------- */
.p-0  { padding: var(--space-0); }
.p-1  { padding: var(--space-1); }
.p-2  { padding: var(--space-2); }
.p-3  { padding: var(--space-3); }
.p-4  { padding: var(--space-4); }

.px-2 { padding-inline: var(--space-2); }
.px-3 { padding-inline: var(--space-3); }
.px-4 { padding-inline: var(--space-4); }

.py-1 { padding-block: var(--space-1); }
.py-2 { padding-block: var(--space-2); }
.py-3 { padding-block: var(--space-3); }
.py-4 { padding-block: var(--space-4); }

.m-0  { margin: var(--space-0); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.ml-auto { margin-left: auto; }

/* ---------------------------------------------------------------------------
   Border / Decoration
   --------------------------------------------------------------------------- */
.rounded-sm   { border-radius: var(--radius-sm); }
.rounded-md   { border-radius: var(--radius-md); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.border        { border: 1px solid var(--border-default); }
.border-muted  { border: 1px solid var(--border-muted); }
.border-accent { border: 1px solid var(--accent); }
.border-bottom { border-bottom: 1px solid var(--border-muted); }

.bg-base     { background-color: var(--bg-base); }
.bg-surface  { background-color: var(--bg-surface); }
.bg-elevated { background-color: var(--bg-elevated); }
.bg-overlay  { background-color: var(--bg-overlay); }

/* ---------------------------------------------------------------------------
   Cursor / Interaction
   --------------------------------------------------------------------------- */
.cursor-pointer  { cursor: pointer; }
.cursor-default  { cursor: default; }
.pointer-events-none { pointer-events: none; }

.select-none { user-select: none; }
.select-all  { user-select: all; }

/* ---------------------------------------------------------------------------
   Overflow
   --------------------------------------------------------------------------- */
.overflow-hidden  { overflow: hidden; }
.overflow-auto    { overflow: auto; }
.overflow-y-auto  { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }

/* ---------------------------------------------------------------------------
   Width / Height
   --------------------------------------------------------------------------- */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-0 { min-height: 0; }
.min-w-0 { min-width: 0; }

/* ---------------------------------------------------------------------------
   Position
   --------------------------------------------------------------------------- */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }
.inset-0  { inset: 0; }

/* ---------------------------------------------------------------------------
   Opacity / Transitions
   --------------------------------------------------------------------------- */
.opacity-0   { opacity: 0; }
.opacity-50  { opacity: 0.5; }
.opacity-100 { opacity: 1; }

.transition {
  transition-property: color, background-color, border-color, opacity, transform, box-shadow;
  transition-duration: var(--duration-normal);
  transition-timing-function: var(--ease-default);
}

/* ---------------------------------------------------------------------------
   Animation Utilities
   --------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

.animate-fadeIn {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.animate-fadeInUp {
  animation: fadeInUp var(--duration-normal) var(--ease-out);
}

.animate-fadeInDown {
  animation: fadeInDown var(--duration-normal) var(--ease-out);
}

/* ---------------------------------------------------------------------------
   Status Dot — connection indicator (used by main.js)
   --------------------------------------------------------------------------- */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--color-error);
  flex-shrink: 0;
  transition: background-color var(--transition-base);
}

.status-dot.connected {
  background-color: var(--color-success);
  animation: status-dot-pulse 2s ease-in-out infinite;
}

.status-dot.connecting {
  background-color: var(--color-warning);
  animation: status-dot-pulse 1s ease-in-out infinite;
}

.status-dot.disconnected {
  background-color: var(--color-error);
  animation: none;
}

@keyframes status-dot-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ---------------------------------------------------------------------------
   Paused Indicator
   --------------------------------------------------------------------------- */
.paused-indicator {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-warning);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.paused-indicator.show {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
   Reduced motion for status dot
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .status-dot.connected,
  .status-dot.connecting {
    animation: none;
  }
}
