/**
 * ============================================================================
 * UTILITIES.CSS
 * ============================================================================
 * 
 * Utility classes, animations, and helper styles.
 * These are small, single-purpose classes that can be composed together.
 * 
 * NAMING CONVENTION:
 *   - Text: .text-{property}
 *   - Spacing: .m{side}-{size}, .p{side}-{size}
 *   - Display: .d-{value}
 *   - Flex: .flex-{property}
 * 
 * DEPENDENCIES:
 *   - definitions.css (CSS custom properties)
 * 
 * SECTIONS:
 *   1. Display Utilities
 *   2. Flexbox Utilities
 *   3. Spacing Utilities
 *   4. Text Utilities
 *   5. Color Utilities
 *   6. Sizing Utilities
 *   7. Border Utilities
 *   8. Shadow Utilities
 *   9. Animations
 *  10. Scrollbar Styles
 *  11. Print Styles
 * 
 * LAST UPDATED: 2026-01-14
 * ============================================================================
 */


/* =============================================================================
   1. DISPLAY UTILITIES
   =============================================================================
   Control element display behavior.
   ============================================================================= */

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }

/* Visibility */
.visible { visibility: visible !important; }
.invisible { visibility: hidden !important; }

/* Overflow */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }
.overflow-scroll { overflow: scroll !important; }
.overflow-visible { overflow: visible !important; }

/* Position */
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }
.position-sticky { position: sticky !important; }


/* =============================================================================
   2. FLEXBOX UTILITIES
   =============================================================================
   Quick flexbox alignment and layout.
   ============================================================================= */

/* Direction */
.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-row-reverse { flex-direction: row-reverse !important; }
.flex-column-reverse { flex-direction: column-reverse !important; }

/* Wrap */
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

/* Justify Content */
.justify-start { justify-content: flex-start !important; }
.justify-end { justify-content: flex-end !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-around { justify-content: space-around !important; }
.justify-evenly { justify-content: space-evenly !important; }

/* Align Items */
.align-start { align-items: flex-start !important; }
.align-end { align-items: flex-end !important; }
.align-center { align-items: center !important; }
.align-baseline { align-items: baseline !important; }
.align-stretch { align-items: stretch !important; }

/* Align Self */
.align-self-start { align-self: flex-start !important; }
.align-self-end { align-self: flex-end !important; }
.align-self-center { align-self: center !important; }
.align-self-stretch { align-self: stretch !important; }

/* Flex Grow/Shrink */
.flex-1 { flex: 1 1 0% !important; }
.flex-auto { flex: 1 1 auto !important; }
.flex-none { flex: none !important; }
.flex-grow-0 { flex-grow: 0 !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-shrink-1 { flex-shrink: 1 !important; }

/* Gap */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }
.gap-5 { gap: 24px !important; }
.gap-6 { gap: 32px !important; }


/* =============================================================================
   3. SPACING UTILITIES
   =============================================================================
   Margin and padding helpers.
   Scale: 0=0, 1=4px, 2=8px, 3=12px, 4=16px, 5=24px, 6=32px, 8=48px
   ============================================================================= */

/* Margin - All sides */
.m-0 { margin: 0 !important; }
.m-1 { margin: 4px !important; }
.m-2 { margin: 8px !important; }
.m-3 { margin: 12px !important; }
.m-4 { margin: 16px !important; }
.m-5 { margin: 24px !important; }
.m-6 { margin: 32px !important; }
.m-auto { margin: auto !important; }

/* Margin - Top */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-5 { margin-top: 24px !important; }
.mt-6 { margin-top: 32px !important; }
.mt-auto { margin-top: auto !important; }

/* Margin - Right */
.mr-0 { margin-right: 0 !important; }
.mr-1 { margin-right: 4px !important; }
.mr-2 { margin-right: 8px !important; }
.mr-3 { margin-right: 12px !important; }
.mr-4 { margin-right: 16px !important; }
.mr-5 { margin-right: 24px !important; }
.mr-auto { margin-right: auto !important; }

/* Margin - Bottom */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 24px !important; }
.mb-6 { margin-bottom: 32px !important; }

/* Margin - Left */
.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: 4px !important; }
.ml-2 { margin-left: 8px !important; }
.ml-3 { margin-left: 12px !important; }
.ml-4 { margin-left: 16px !important; }
.ml-5 { margin-left: 24px !important; }
.ml-auto { margin-left: auto !important; }

/* Margin - Horizontal (left + right) */
.mx-0 { margin-left: 0 !important; margin-right: 0 !important; }
.mx-1 { margin-left: 4px !important; margin-right: 4px !important; }
.mx-2 { margin-left: 8px !important; margin-right: 8px !important; }
.mx-3 { margin-left: 12px !important; margin-right: 12px !important; }
.mx-4 { margin-left: 16px !important; margin-right: 16px !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* Margin - Vertical (top + bottom) */
.my-0 { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-1 { margin-top: 4px !important; margin-bottom: 4px !important; }
.my-2 { margin-top: 8px !important; margin-bottom: 8px !important; }
.my-3 { margin-top: 12px !important; margin-bottom: 12px !important; }
.my-4 { margin-top: 16px !important; margin-bottom: 16px !important; }
.my-auto { margin-top: auto !important; margin-bottom: auto !important; }

/* Padding - All sides */
.p-0 { padding: 0 !important; }
.p-1 { padding: 4px !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 12px !important; }
.p-4 { padding: 16px !important; }
.p-5 { padding: 24px !important; }
.p-6 { padding: 32px !important; }

/* Padding - Top */
.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 4px !important; }
.pt-2 { padding-top: 8px !important; }
.pt-3 { padding-top: 12px !important; }
.pt-4 { padding-top: 16px !important; }
.pt-5 { padding-top: 24px !important; }

/* Padding - Right */
.pr-0 { padding-right: 0 !important; }
.pr-1 { padding-right: 4px !important; }
.pr-2 { padding-right: 8px !important; }
.pr-3 { padding-right: 12px !important; }
.pr-4 { padding-right: 16px !important; }
.pr-5 { padding-right: 24px !important; }

/* Padding - Bottom */
.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 4px !important; }
.pb-2 { padding-bottom: 8px !important; }
.pb-3 { padding-bottom: 12px !important; }
.pb-4 { padding-bottom: 16px !important; }
.pb-5 { padding-bottom: 24px !important; }

/* Padding - Left */
.pl-0 { padding-left: 0 !important; }
.pl-1 { padding-left: 4px !important; }
.pl-2 { padding-left: 8px !important; }
.pl-3 { padding-left: 12px !important; }
.pl-4 { padding-left: 16px !important; }
.pl-5 { padding-left: 24px !important; }

/* Padding - Horizontal */
.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: 4px !important; padding-right: 4px !important; }
.px-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-3 { padding-left: 12px !important; padding-right: 12px !important; }
.px-4 { padding-left: 16px !important; padding-right: 16px !important; }
.px-5 { padding-left: 24px !important; padding-right: 24px !important; }

/* Padding - Vertical */
.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: 4px !important; padding-bottom: 4px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 12px !important; padding-bottom: 12px !important; }
.py-4 { padding-top: 16px !important; padding-bottom: 16px !important; }
.py-5 { padding-top: 24px !important; padding-bottom: 24px !important; }


/* =============================================================================
   4. TEXT UTILITIES
   =============================================================================
   Typography helpers.
   ============================================================================= */

/* Font Size */
.text-xs { font-size: 11px !important; }
.text-sm { font-size: 12px !important; }
.text-base { font-size: 14px !important; }
.text-lg { font-size: 16px !important; }
.text-xl { font-size: 18px !important; }
.text-2xl { font-size: 24px !important; }
.text-3xl { font-size: 30px !important; }

/* Font Weight */
.font-normal { font-weight: 400 !important; }
.font-medium { font-weight: 500 !important; }
.font-semibold { font-weight: 600 !important; }
.font-bold { font-weight: 700 !important; }

/* Text Alignment */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-justify { text-align: justify !important; }

/* Text Transform */
.uppercase { text-transform: uppercase !important; }
.lowercase { text-transform: lowercase !important; }
.capitalize { text-transform: capitalize !important; }
.normal-case { text-transform: none !important; }

/* Text Decoration */
.underline { text-decoration: underline !important; }
.line-through { text-decoration: line-through !important; }
.no-underline { text-decoration: none !important; }

/* White Space */
.whitespace-nowrap { white-space: nowrap !important; }
.whitespace-normal { white-space: normal !important; }
.whitespace-pre { white-space: pre !important; }
.whitespace-pre-wrap { white-space: pre-wrap !important; }

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

.break-words { word-wrap: break-word !important; }
.break-all { word-break: break-all !important; }

/* Line Height */
.leading-none { line-height: 1 !important; }
.leading-tight { line-height: 1.25 !important; }
.leading-normal { line-height: 1.5 !important; }
.leading-relaxed { line-height: 1.75 !important; }
.leading-loose { line-height: 2 !important; }


/* =============================================================================
   5. COLOR UTILITIES
   =============================================================================
   Text and background colors using theme tokens.
   ============================================================================= */

/* Text Colors */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-muted { color: var(--text-tertiary) !important; }

.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-info { color: var(--primary-color) !important; }

.text-white { color: white !important; }
.text-inherit { color: inherit !important; }

/* Background Colors */
.bg-primary { background-color: var(--bg-primary) !important; }
.bg-surface { background-color: var(--bg-surface) !important; }
.bg-surface-hover { background-color: var(--bg-surface-hover) !important; }

.bg-success { background-color: var(--color-success-bg) !important; }
.bg-warning { background-color: var(--color-warning-bg) !important; }
.bg-danger { background-color: var(--color-danger-bg) !important; }

.bg-transparent { background-color: transparent !important; }
.bg-white { background-color: white !important; }


/* =============================================================================
   6. SIZING UTILITIES
   =============================================================================
   Width and height helpers.
   ============================================================================= */

/* Width */
.w-auto { width: auto !important; }
.w-full { width: 100% !important; }
.w-screen { width: 100vw !important; }
.w-fit { width: fit-content !important; }
.w-min { width: min-content !important; }
.w-max { width: max-content !important; }

/* Height */
.h-auto { height: auto !important; }
.h-full { height: 100% !important; }
.h-screen { height: 100vh !important; }
.h-fit { height: fit-content !important; }

/* Min/Max Width */
.min-w-0 { min-width: 0 !important; }
.min-w-full { min-width: 100% !important; }
.max-w-full { max-width: 100% !important; }
.max-w-screen { max-width: 100vw !important; }

/* Min/Max Height */
.min-h-0 { min-height: 0 !important; }
.min-h-full { min-height: 100% !important; }
.min-h-screen { min-height: 100vh !important; }
.max-h-full { max-height: 100% !important; }
.max-h-screen { max-height: 100vh !important; }


/* =============================================================================
   7. BORDER UTILITIES
   =============================================================================
   Border styles and radius.
   ============================================================================= */

/* Border */
.border { border: 1px solid var(--border-color) !important; }
.border-0 { border: 0 !important; }
.border-t { border-top: 1px solid var(--border-color) !important; }
.border-r { border-right: 1px solid var(--border-color) !important; }
.border-b { border-bottom: 1px solid var(--border-color) !important; }
.border-l { border-left: 1px solid var(--border-color) !important; }

/* Border Radius */
.rounded-none { border-radius: 0 !important; }
.rounded-sm { border-radius: 4px !important; }
.rounded { border-radius: 6px !important; }
.rounded-md { border-radius: 8px !important; }
.rounded-lg { border-radius: 12px !important; }
.rounded-xl { border-radius: 16px !important; }
.rounded-full { border-radius: 9999px !important; }


/* =============================================================================
   8. SHADOW UTILITIES
   =============================================================================
   Box shadow helpers.
   ============================================================================= */

.shadow-none { box-shadow: none !important; }
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow-md) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
.shadow-xl { box-shadow: var(--shadow-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25)) !important; }


/* =============================================================================
   9. ANIMATIONS
   =============================================================================
   Reusable animation keyframes and classes.
   ============================================================================= */

/* Fade In */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fadeInUp {
    animation: fadeInUp 0.3s ease-out;
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fadeInDown {
    animation: fadeInDown 0.3s ease-out;
}

/* Slide In Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slideInRight {
    animation: slideInRight 0.3s ease-out;
}

/* Slide In Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slideInLeft {
    animation: slideInLeft 0.3s ease-out;
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scaleIn {
    animation: scaleIn 0.2s ease-out;
}

/* Pulse */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Spin */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
    50% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
}

.animate-bounce {
    animation: bounce 1s infinite;
}

/* Staggered Children Animation */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 0.3s ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }
.stagger-children > *:nth-child(9) { animation-delay: 400ms; }
.stagger-children > *:nth-child(10) { animation-delay: 450ms; }


/* =============================================================================
   10. SCROLLBAR STYLES
   =============================================================================
   Custom scrollbar styling for webkit browsers.
   ============================================================================= */

/* Thin scrollbar for containers */
.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

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

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

.scrollbar-thin::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Hide scrollbar but keep functionality */
.scrollbar-hidden {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.scrollbar-hidden::-webkit-scrollbar {
    display: none;
}


/* =============================================================================
   11. PRINT STYLES
   =============================================================================
   Styles applied when printing.
   ============================================================================= */

@media print {
    /* Hide non-essential elements */
    .no-print,
    .sidebar,
    .nav,
    .tk-toast-container {
        display: none !important;
    }
    
    /* Reset backgrounds for printing */
    body {
        background: white !important;
        color: black !important;
    }
    
    /* Ensure links show their URLs */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    /* Avoid page breaks inside elements */
    .tk-card,
    .tk-table tr,
    img {
        page-break-inside: avoid;
    }
}


/* =============================================================================
   12. ACCESSIBILITY HELPERS
   =============================================================================
   Classes for screen readers and accessibility.
   ============================================================================= */

/* Visually hidden but accessible to screen readers */
.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;
}

/* Show on focus (for skip links) */
.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Focus visible helper */
.focus-ring:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
