/**
 * Global Text Overflow Utilities
 * Mobile-first approach for handling text overflow across the application
 * Focused on TEXT readability and overflow prevention
 */

/* ============================================
   BASE TYPOGRAPHY - MOBILE FIRST
   ============================================ */

/* Mobile base font size */
.text-mobile-base {
  font-size: 14px;
  line-height: 1.5;
}

/* Larger screens */
@media (min-width: 768px) {
  .text-mobile-base {
    font-size: 16px;
  }
}

/* ============================================
   TEXT OVERFLOW UTILITIES
   ============================================ */

/* Break words at any character to prevent overflow */
.break-word {
  word-break: break-word;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Break words only at normal break points */
.break-normal {
  word-break: normal;
  overflow-wrap: normal;
}

/* Break long words at arbitrary points */
.break-all {
  word-break: break-all;
}

/* Break long words on hyphens */
.break-hyphens {
  word-break: break-keep;
  overflow-wrap: break-word;
}

/* Keep words on same line (no breaking) */
.keep-all {
  word-break: keep-all;
}

/* ============================================
   TEXT TRUNCATION
   ============================================ */

/* Single line truncation with ellipsis */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Multi-line truncation with ellipsis (2 lines) */
.truncate-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* Multi-line truncation with ellipsis (3 lines) */
.truncate-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

/* ============================================
   UUID TRUNCATION STYLES
   ============================================ */

/* Truncate UUID in middle: abc...xyz */
.uuid-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

@media (min-width: 768px) {
  .uuid-truncate {
    max-width: 200px;
  }
}

/* Truncate with monospace font for better readability */
.uuid-monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.875em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Short UUID display (first 8 chars only) */
.uuid-short {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.875em;
}

/* ============================================
   OVERFLOW WRAP UTILITIES
   ============================================ */

/* Allow long words to wrap and overflow */
.overflow-wrap {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Allow long words to break anywhere */
.overflow-wrap-anywhere {
  overflow-wrap: anywhere;
}

/* Prevent text overflow with scroll */
.overflow-x-auto {
  overflow-x: auto;
}

.overflow-y-auto {
  overflow-y: auto;
}

.overflow-auto {
  overflow: auto;
}

/* Hide overflowing content */
.overflow-hidden {
  overflow: hidden;
}

/* ============================================
   TABLE CELL OVERFLOW HANDLING
   ============================================ */

/* Prevent table cells from expanding beyond container */
table {
  table-layout: fixed;
  width: 100%;
  overflow-wrap: break-word;
}

/* Table cell with text truncation */
.table-cell-truncate {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Table cell with word break */
.table-cell-break {
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Responsive table wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Small table cells for UUID/ID columns */
.table-cell-small {
  width: 80px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .table-cell-small {
    width: 120px;
    max-width: 120px;
  }
}

/* ============================================
   FLEXBOX OVERFLOW PREVENTION
   ============================================ */

/* Prevent flex items from overflowing */
.flex-overflow-protected {
  display: flex;
  flex-wrap: wrap;
  overflow: hidden;
}

/* Flex item with min-width: 0 to allow shrinking */
.flex-shrink-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Flex container that prevents text overflow */
.flex-text-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
}

/* ============================================
   GRID OVERFLOW PREVENTION
   ============================================ */

/* Grid with automatic column sizing */
.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 1rem;
}

/* Grid with fixed columns */
.grid-fixed-overflow {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

@media (min-width: 768px) {
  .grid-fixed-overflow {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Grid cell with overflow protection */
.grid-cell-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* ============================================
   MOBILE-SPECIFIC TEXT UTILITIES
   ============================================ */

/* Prevent horizontal scroll on mobile */
.mobile-no-overflow {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* Small text for mobile */
.text-sm-mobile {
  font-size: 12px;
}

@media (min-width: 768px) {
  .text-sm-mobile {
    font-size: 14px;
  }
}

/* Extra small text for mobile */
.text-xs-mobile {
  font-size: 11px;
}

@media (min-width: 768px) {
  .text-xs-mobile {
    font-size: 12px;
  }
}

/* Compact text for tight mobile spaces */
.text-compact {
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* ============================================
   INLINE TEXT UTILITIES
   ============================================ */

/* Inline element with text truncation */
.inline-truncate {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* Inline-flex with overflow protection */
.inline-flex-text {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

/* ============================================
   SPECIAL CASES
   ============================================ */

/* Long URLs */
.url-break {
  word-break: break-all;
  overflow-wrap: break-word;
  color: inherit;
}

/* Email addresses */
.email-break {
  word-break: break-all;
}

/* Phone numbers */
.phone-break {
  word-break: break-all;
  white-space: nowrap;
}

/* Code blocks with overflow */
.code-overflow {
  overflow-x: auto;
  white-space: pre;
  font-size: 0.875em;
}

/* Long sequences without spaces (like long tokens) */
.token-break {
  word-break: break-all;
  overflow-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}
