/* static/css/utilities.css */
/* --- REORGANIZED FOR CLARITY AND MAINTAINABILITY --- */

/* 1. LAYOUT & DISPLAY
----------------------------------------------------------------*/
/* Display */
.block { display: block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
/* MODIFIED: Added !important to ensure this utility always wins */
.hidden { display: none !important; }

/* Flexbox & Grid */
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.align-middle { vertical-align: middle; }

/* Positioning */
.relative { position: relative; }
.absolute { position: absolute; }
.right-3 { right: 0.75rem; }
.top-1\/2 { top: 50%; }

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


/* 2. SIZING
----------------------------------------------------------------*/
.w-full { width: 100%; }
.w-auto { width: auto; }
.w-1\/3 { width: 33.333333%; }
.w-2\/3 { width: 66.666667%; }
.w-20 { width: 5rem; }
.max-w-md { max-width: 28rem; }
.max-w-7xl { max-width: 80rem; }
.max-w-screen-2xl { max-width: 1536px; }

.h-full { height: 100%; }
.h-10 { height: 2.5rem; }
.h-16 { height: 4rem; }
.h-20 { height: 5rem; }
.h-48 { height: 12rem; }
.min-h-screen { min-height: 100vh; }


/* 3. SPACING
----------------------------------------------------------------*/

/* --- MARGINS --- */
.mx-auto { margin-left: auto; margin-right: auto; }
.my-auto { margin-top: auto; margin-bottom: auto; }

/* Left / Right */
.ml-0\.5 { margin-left: 0.125rem; }
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 0.75rem; }
.ml-4 { margin-left: 1rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 0.75rem; }
.mr-4 { margin-right: 1rem; }

/* Top */
.mt-0 { margin-top: 0; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mt-10 { margin-top: 2.5rem; }

/* Bottom */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-10 { margin-bottom: 2.5rem; }


/* --- PADDING --- */
/* All Sides */
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; } /* Adjusted to standard Tailwind (was 2rem) */
.p-8 { padding: 2rem; }
.p-10 { padding: 2.5rem; }
.p-12 { padding: 3rem; }

/* Horizontal (X-Axis) */
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }

/* Vertical (Y-Axis) */
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }

/* Individual Sides */
.pt-0\.5 { padding-top: 0.125rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pt-5 { padding-top: 1.25rem; }
.pt-6 { padding-top: 1.5rem; }

.pb-2 { padding-bottom: 0.5rem; }
.pb-3 { padding-bottom: 0.75rem; }
.pb-4 { padding-bottom: 1rem; }
.pb-6 { padding-bottom: 1.5rem; }

.pl-4 { padding-left: 1rem; }
.pr-10 { padding-right: 2.5rem; }


/* --- GAP (Flexbox & Grid) --- */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-5 { gap: 1.25rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }
.gap-10 { gap: 2.5rem; }

.gap-x-4 { column-gap: 1rem; }
.gap-x-6 { column-gap: 1.5rem; }
.gap-y-5 { row-gap: 1.25rem; }
.gap-y-6 { row-gap: 1.5rem; }


/* --- SPACE BETWEEN --- */
/* Adds margin to all children except the first one */
.space-x-2 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.5rem; }
.space-x-3 > :not([hidden]) ~ :not([hidden]) { margin-left: 0.75rem; }
.space-x-4 > :not([hidden]) ~ :not([hidden]) { margin-left: 1rem; }

.space-y-1 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.25rem; }
.space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.5rem; }
.space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.75rem; }
.space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1rem; }
.space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }
.space-y-8 > :not([hidden]) ~ :not([hidden]) { margin-top: 2rem; }


/* 4. TYPOGRAPHY
----------------------------------------------------------------*/
/* Font Family */
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

/* Font Size */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }

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

/* Text Color (Themed) */
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-heading-light { color: var(--color-accent); }
.text-text-light { color: var(--color-text); }
.text-text-primary { color: var(--color-text-primary); }
.text-text-secondary { color: var(--color-text-secondary); }

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

/* Text Styling */
.uppercase { text-transform: uppercase; }
.whitespace-nowrap { white-space: nowrap; }
.tracking-tight { letter-spacing: -0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.leading-relaxed { line-height: 1.625; }


/* 5. BACKGROUNDS & COLORS
----------------------------------------------------------------*/
/* Themed Backgrounds */
.bg-primary { background-color: var(--color-primary); }
.bg-primary-10 { background-color: rgba(242, 153, 74, 0.1); }
.bg-background-light { background-color: var(--color-background); }
.bg-surface-light { background-color: var(--color-surface); }

/* Static Colors (Non-themed) */
.text-white { color: #ffffff; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-200 { background-color: #e5e7eb; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-800 { color: #1f2937; }


/* 6. BORDERS & DIVIDERS
----------------------------------------------------------------*/
/* Borders */
.border { border-width: 1px; }
.border-2 { border-width: 2px; }
.border-b { border-bottom-width: 1px; }
.border-dashed { border-style: dashed; }
.border-border-light { border-color: var(--color-border); }

/* Border Radius */
.rounded { border-radius: var(--border-radius-default); }
.rounded-md { border-radius: var(--border-radius-md); }
.rounded-lg { border-radius: var(--border-radius-lg); }

/* Dividers */
.divide-y > :not([hidden]) ~ :not([hidden]) { border-top-width: 1px; }
.divide-border-light > :not([hidden]) ~ :not([hidden]) { border-color: var(--color-border); }


/* 7. EFFECTS & TRANSITIONS
----------------------------------------------------------------*/
/* Box Shadow */
.shadow-sm { box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); }

/* Transform */
.-translate-y-1\/2 { transform: translateY(-50%); }

/* Transitions */
.transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-colors { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-opacity { transition-property: opacity; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }
.duration-200 { transition-duration: 200ms; }


/* 8. INTERACTIVITY & STATES
----------------------------------------------------------------*/
.cursor-pointer { cursor: pointer; }
.pointer-events-none { pointer-events: none; }

/* Hover */
.hover\:opacity-90:hover { opacity: 0.9; }
.hover\:bg-gray-100:hover { background-color: #f3f4f6; }
.hover\:bg-gray-300:hover { background-color: #d1d5db; }

/* Focus */
.focus\:outline-none:focus { outline: 2px solid transparent; outline-offset: 2px; }
.focus\:border-primary:focus { border-color: var(--color-primary); }
.focus\:ring-2:focus { --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color); box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000); }
.focus\:ring-primary:focus { --tw-ring-color: var(--color-primary); }
.focus\:ring-offset-2:focus { --tw-ring-offset-width: 2px; }
.focus\:ring-offset-background-light:focus { --tw-ring-offset-color: var(--color-background); }


/* 9. DARK MODE
----------------------------------------------------------------*/
/* Dark: Backgrounds & Colors */
.dark .dark\:bg-background-dark { background-color: var(--color-background); }
.dark .dark\:bg-surface-dark { background-color: var(--color-surface); }
.dark .dark\:bg-header { background-color: rgba(255, 255, 255, 0.08); }
.dark .dark\:bg-gray-600 { background-color: #4b5563; }

/* Dark: Typography */
.dark .dark\:text-text-dark { color: var(--color-text); }
.dark .dark\:text-text-primary { color: var(--color-text-primary); }
.dark .dark\:text-text-secondary { color: var(--color-text-secondary); }
.dark .dark\:text-heading-dark { color: var(--color-accent-dark); }
.dark .dark\:text-gray-100 { color: #f3f4f6; }
.dark .dark\:text-gray-200 { color: #e5e7eb; }
.dark .dark\:text-gray-400 { color: #9ca3af; }
.dark .dark\:text-gray-500 { color: #6b7280; }

/* Dark: Borders & Dividers */
.dark .dark\:border-border-dark { border-color: var(--color-border); }
.dark .dark\:divide-border-dark > :not([hidden]) ~ :not([hidden]) { border-color: var(--color-border); }

/* Dark: States */
.dark .dark\:hover\:text-dark-primary:hover { color: var(--color-text-primary); }
.dark .dark\:hover\:bg-surface-hover:hover { background-color: rgba(255, 255, 255, 0.05); }
.dark .dark\:hover\:bg-gray-800:hover { background-color: #1f2937; }
.dark .dark\:hover\:bg-gray-500:hover { background-color: #6b7280; }
.dark .dark\:focus\:ring-offset-background-dark:focus { --tw-ring-offset-color: var(--color-background); }


/* 10. RESPONSIVE DESIGN
----------------------------------------------------------------*/
/* Small breakpoint (sm) */
@media (min-width: 640px) {
  .sm\:p-8 { padding: 2rem; }
  .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
  .sm\:p-6 { padding: 1.5rem; }
}

/* Medium breakpoint (md) */
@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:col-span-2 { grid-column: span 2 / span 2; }
}

/* Large breakpoint (lg) */
@media (min-width: 1024px) {
  .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
  .lg\:p-8 { padding: 2rem; }
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:gap-8 { gap: 2rem; }
  .lg\:mb-0 { margin-bottom: 0; }
  .lg\:py-12 { padding-top: 3rem; padding-bottom: 3rem; }
  .lg\:sticky { position: -webkit-sticky; position: sticky; }
  .lg\:top-8 { top: 2rem; }
  .lg\:self-start { align-self: flex-start; }
}

/* Extra-large breakpoint (xl) */
@media (min-width: 1280px) {
  .xl\:gap-12 { gap: 3rem; }
}

.button-content-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Styles for the loader when it's active */
.button-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
}

/* When the button is disabled (during loading), hide the original text */
.c-btn:disabled .button-text {
    visibility: hidden;
}

/* 1. LAYOUT & DISPLAY */
.flex-wrap { flex-wrap: wrap; }
.aspect-video { aspect-ratio: 16 / 9; }
.aspect-square { aspect-ratio: 1 / 1; }

/* 2. SIZING */
.w-16 { width: 4rem; }
.max-w-960 { max-width: 960px; }
.min-w-72 { min-width: 18rem; } /* 288px */

/* 3. SPACING */
.pt-10 { padding-top: 2.5rem; }
.pb-3 { padding-bottom: 0.75rem; }

/* 4. TYPOGRAPHY */
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-22px { font-size: 22px; }
.font-black { font-weight: 900; }
.font-normal { font-weight: 400; }
.tracking-tighter { letter-spacing: -0.033em; }
.leading-tight { line-height: 1.25; }
.leading-normal { line-height: 1.5; }

/* 5. BACKGROUNDS & COLORS */
.text-opacity-80 { color: rgba(var(--color-text-primary-rgb), 0.8); }
.bg-cover { background-size: cover; }
.bg-center { background-position: center; }
.bg-no-repeat { background-repeat: no-repeat; }

/* 6. BORDERS */
.rounded-xl { border-radius: var(--border-radius-xl); }
.rounded-t-xl { border-top-left-radius: var(--border-radius-xl); border-top-right-radius: var(--border-radius-xl); }
.rounded-l-xl { border-top-left-radius: var(--border-radius-xl); border-bottom-left-radius: var(--border-radius-xl); }
.rounded-full { border-radius: 9999px; }
.border-primary { border-color: var(--color-primary); }

/* 7. EFFECTS */
.shadow-lg { box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); }

/* 8. INTERACTIVITY & STATES */
.hover\:border-primary:hover { border-color: var(--color-primary); }
.hover\:bg-primary-10:hover { background-color: rgba(242, 153, 74, 0.1); }
button:disabled { cursor: not-allowed; opacity: 0.6; }

/* 9. DARK MODE */
.dark .dark\:text-opacity-80 { color: rgba(var(--color-text-primary-rgb-dark, 224, 224, 224), 0.8); }
.dark .dark\:hover\:border-primary:hover { border-color: var(--color-primary); }
/* Add this to :root in base.css if you want to make dark mode opacity work reliably */
/* :root { --color-text-primary-rgb: 45, 55, 72; } */
/* .dark { --color-text-primary-rgb-dark: 224, 224, 224; } */

/* 10. RESPONSIVE DESIGN */
@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:w-auto { width: auto; }
  .sm\:flex-row { flex-direction: row; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:flex-row { flex-direction: row; }
  .lg\:w-1\/3 { width: 33.333333%; }
  .lg\:aspect-square { aspect-ratio: 1 / 1; }
  .lg\:rounded-l-lg { border-top-left-radius: var(--border-radius-lg); border-bottom-left-radius: var(--border-radius-lg); }
  .lg\:rounded-tr-none { border-top-right-radius: 0; }
}

.w-5 { width: 1.25rem; } /* 20px */
.h-5 { height: 1.25rem; } /* 20px */

.w-full { width: 100%; }

.grid-cols-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-4 { grid-column: span 4 / span 4; }
.col-span-6 { grid-column: span 6 / span 6; }
.col-span-12 { grid-column: span 12 / span 12; }

/* 3. SPACING */
.pt-2 { padding-top: 0.5rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.pb-2 { padding-bottom: 0.5rem; }
.sm\:gap-4 { gap: 1rem; } /* Note: .gap-4 already exists, this is for consistency */

/* 10. RESPONSIVE DESIGN */
@media (min-width: 768px) {
  /* ... existing md styles ... */
  .md\:grid { display: grid; }
  .md\:col-span-2 { grid-column: span 2 / span 2; }
  .md\:col-span-6 { grid-column: span 6 / span 6; }
  .md\:col-span-12 { grid-column: span 12 / span 12; }
  .md\:px-0 { padding-left: 0; padding-right: 0; }
}

/* --- APPENDS FOR CLIENT FORM --- */

/* Component: Selection Card (for Categories) */
.c-selection-card {
    position: relative;
    height: 100%;
}

/* 1. The Checkbox (Positioned absolutely in top-left) */
.c-selection-card input[type="checkbox"],
.c-selection-card input[type="radio"] {
    position: absolute;
    top: 1.15rem;  /* Aligns with padding */
    left: 1rem;
    width: 1.25rem; /* w-5 */
    height: 1.25rem; /* h-5 */
    z-index: 10;
    cursor: pointer;
    margin: 0;
    /* Inherit generic checkbox styles */
    border-radius: var(--border-radius-md);
    border-color: var(--color-border);
    color: var(--color-primary);
}

/* 2. The Label (Acts as the card body) */
.c-selection-card label {
    display: block;
    width: 100%;
    height: 100%;
    padding: 1rem 1rem 1rem 3.5rem; /* Left padding makes room for checkbox */
    background-color: var(--color-surface); /* Default white */
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-default);
    color: var(--color-text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease-in-out;
}

/* Hover State */
.c-selection-card:hover label {
    border-color: var(--color-text-secondary); /* Darker gray on hover */
    background-color: #f9fafb; /* gray-50 */
}
.dark .c-selection-card:hover label {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Checked State (Logic: Input is immediately before Label) */
.c-selection-card input:checked + label {
    border-color: var(--color-primary);
    background-color: rgba(242, 153, 74, 0.08); /* primary-50 equivalent */
    color: var(--color-primary);
    box-shadow: inset 0 0 0 1px var(--color-primary); /* Inner ring effect */
}
.dark .c-selection-card input:checked + label {
    background-color: rgba(242, 153, 74, 0.15);
}

/* Input Modifier: Gray Background */
/* Matches the design's "bg-gray-50" inputs */
.c-form-input--alt {
    background-color: #f9fafb; /* gray-50 */
    border-color: var(--color-border);
}
.c-form-input--alt:focus {
    background-color: var(--color-surface);
}
.dark .c-form-input--alt {
    background-color: #1f2937; /* gray-800 */
    border-color: var(--color-border);
}


.bg-primary-20 { background-color: rgba(242, 153, 74, 0.2); } /* Primary at 20% opacity */
.bg-error-20 { background-color: rgba(239, 68, 68, 0.2); }   /* Error at 20% opacity */

/* Min-widths for responsive table/filters */
.min-w-200px { min-width: 200px; }
.min-w-150px { min-width: 150px; }

@media (min-width: 768px) {
    .md\:table-cell {
        display: table-cell !important;
    }
}

/* --- NEW: Width Percentages for Tables --- */
.w-10pct { width: 10%; }
.w-15pct { width: 15%; }
.w-20pct { width: 20%; }
.w-35pct { width: 35%; }

/* --- NEW: Backdrop Filters (Glassmorphism) --- */
.backdrop-blur-sm { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.backdrop-blur-md { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.bg-white-90 { background-color: rgba(255, 255, 255, 0.9); }
.dark .bg-surface-90 { background-color: rgba(56, 56, 56, 0.9); }

/* --- NEW: Z-Index --- */
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.sticky { position: sticky; }

a.c-stat-card {
    text-decoration: none;
    color: inherit; /* Ensures text stays your theme color, not default link blue */
    cursor: pointer;
}

/* Optional: Ensure specific hover states don't re-add it */
a.c-stat-card:hover {
    text-decoration: none;
}