/**
 * CSS Utilities & Design System for Challendo
 * Central design tokens, utilities and animations
 * 
 * Phase 3a CSS Consolidation: utilities-consolidated.css + utilities-extended.css → utilities.css
 * Author: Generated for Challendo Project  
 * Created: 2025-01-09
 * Updated: 2025-10-13 - Phase 3a CSS Consolidation Complete
 * Purpose: CSP-compliant CSS with centralized design system
 */

/* ==========================================================================
   DESIGN TOKEN SYSTEM - Core variables for consistent design
   ========================================================================== */

:root {
  /* === COLOR SYSTEM === */
  
  /* Gray Scale - Most frequently used colors */
  --gray-50: #f8f9fa;     /* Light backgrounds */
  --gray-100: #f1f5f9;
  --gray-200: #e9ecef;    /* Borders, dividers */
  --gray-300: #dee2e6;    /* Form borders */
  --gray-400: #ced4da;
  --gray-500: #6c757d;    /* Muted text - MOST USED */
  --gray-600: #495057;    /* Secondary text */
  --gray-700: #343a40;
  --gray-800: #212529;    /* Dark text */
  --gray-900: #0f172a;
  
  /* Legacy color mapping for compatibility */
  --white: #ffffff;
  --black: #000000;
  --light-gray: var(--gray-100);
  --medium-gray: var(--gray-500);
  --dark-gray: var(--gray-800);
  
  /* Primary Brand Colors */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;   /* Main brand color */
  --primary-600: #2563eb;   /* Links, buttons */
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;
  
  /* Legacy primary mapping */
  --primary-color: var(--primary-600);
  --primary-dark: var(--primary-700);
  --primary-light: var(--primary-100);
  
  /* Secondary Colors */
  --secondary-50: #f8fafc;
  --secondary-100: #f1f5f9;
  --secondary-500: #64748b;
  --secondary-600: #475569;
  --secondary-700: #334155;
  
  /* Success Colors */
  --success-50: #f0fdf4;
  --success-100: #dcfce7;
  --success-500: #22c55e;
  --success-600: #16a34a;
  --success-700: #15803d;
  
  /* Warning Colors */
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;
  
  /* Error/Danger Colors */
  --error-50: #fef2f2;
  --error-100: #fee2e2;
  --error-500: #ef4444;
  --error-600: #dc2626;
  --error-700: #b91c1c;
  --danger-600: var(--error-600);
  
  /* Info Colors */
  --info-50: #eff6ff;
  --info-100: #dbeafe;
  --info-500: #3b82f6;
  --info-600: var(--primary-600);
  --info-700: var(--primary-700);
  
  /* === SPACING SYSTEM === */
  --space-xs: 0.25rem;    /* 4px */
  --space-sm: 0.5rem;     /* 8px */
  --space-md: 1rem;       /* 16px - MOST USED */
  --space-lg: 1.5rem;     /* 24px */
  --space-xl: 2rem;       /* 32px */
  --space-2xl: 3rem;      /* 48px */
  --space-3xl: 4rem;      /* 64px */
  
  /* === TYPOGRAPHY === */
  /* Font family defined in variables.css */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  
  /* === BORDER RADIUS === */
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  --border-radius-full: 9999px;
  
  /* === SHADOWS === */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.18);
  
  /* Shadow color variations */
  --primary-shadow: rgba(59, 130, 246, 0.1);
  --primary-focus-shadow: rgba(59, 130, 246, 0.15);
  --primary-hover-shadow: rgba(59, 130, 246, 0.3);
  
  /* === TRANSITIONS === */
  --transition-base: all 0.2s ease;
  --transition-fast: all 0.1s ease;
  --transition-slow: all 0.3s ease;
  
  /* === Z-INDEX SYSTEM === */
  --z-dropdown: 1000;
  --z-modal: 1050;
  --z-tooltip: 1100;
  --z-toast: 1200;
  
  /* === LEGACY SUPPORT === */
  --text-color: var(--gray-800);
  --muted-color: var(--gray-500);
  --border-color: var(--gray-200);
  --hover-bg: var(--gray-50);
}

/* ==========================================================================
   DISPLAY UTILITIES
   ========================================================================== */

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

/* JS Display Toggle Classes */
.js-hidden { display: none !important; }
.js-visible { display: block !important; }
.js-visible-flex { display: flex !important; }
.js-visible-inline { display: inline !important; }
.js-visible-inline-block { display: inline-block !important; }

/* ==========================================================================
   SPACING UTILITIES - Using Bootstrap 5 utilities
   ========================================================================== */

/* Bootstrap 5 provides: mt-0 through mt-5, mb-*, ml-*, mr-*, ms-*, me-*, p-*, pt-*, pb-*, px-*, py-*
   Custom extensions beyond Bootstrap's range */

.mt-6 { margin-top: 3rem !important; }
.mb-6 { margin-bottom: 3rem !important; }

/* ==========================================================================
   FLEXBOX UTILITIES - Using Bootstrap 5 utilities
   ========================================================================== */

/* Bootstrap 5 provides: d-flex, flex-wrap, flex-nowrap, justify-content-*, align-items-*, gap-* */
/* All flexbox utilities now use Bootstrap's built-in classes */

/* ==========================================================================
   COLOR UTILITIES
   ========================================================================== */

/* Text Colors */
.text-success { color: var(--success-600, #16a34a) !important; }
.text-warning { color: var(--warning-600, #d97706) !important; }
.text-danger { color: var(--danger-600, #dc2626) !important; }
.text-info { color: var(--primary-600, #2563eb) !important; }
.text-muted { color: var(--gray-500, #6b7280) !important; }
.text-primary { color: var(--primary-600, #2563eb) !important; }
.text-secondary { color: var(--gray-600, #4b5563) !important; }
.text-white { color: var(--white, #ffffff) !important; }
.text-black { color: var(--black, #000000) !important; }
.text-small { font-size: 0.9rem !important; }

/* Background Colors */
.bg-success { background-color: var(--success-600, #16a34a) !important; }
.bg-success-light { background-color: var(--success-100, #dcfce7) !important; }
.bg-warning { background-color: var(--warning-600, #d97706) !important; }
.bg-warning-light { background-color: var(--warning-100, #fef3c7) !important; }
.bg-danger { background-color: var(--danger-600, #dc2626) !important; }
.bg-danger-light { background-color: var(--danger-100, #fee2e2) !important; }
.bg-info { background-color: var(--primary-600, #2563eb) !important; }
.bg-info-light { background-color: var(--primary-100, #dbeafe) !important; }
.bg-primary { background-color: var(--primary-600, #2563eb) !important; }
.bg-primary-light { background-color: var(--primary-50, #eff6ff) !important; }
.bg-secondary { background-color: var(--gray-500, #6b7280) !important; }
.bg-secondary-light { background-color: var(--gray-100, #f3f4f6) !important; }
.bg-light { background-color: var(--gray-50, #f9fafb) !important; }
.bg-white { background-color: var(--white, #ffffff) !important; }

/* ==========================================================================
   NOTIFICATION TAG STYLES
   ========================================================================== */

.notification-tag {
  display: inline-block;
  padding: var(--space-xs, 0.25rem) var(--space-sm, 0.5rem);
  border-radius: var(--border-radius-full, 9999px);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: 500;
  color: var(--white, #ffffff);
}

.notification-tag--success { background-color: var(--success-600, #16a34a); }
.notification-tag--warning { background-color: var(--warning-500, #f59e0b); color: var(--black, #000000); }
.notification-tag--info { background-color: var(--primary-600, #2563eb); }
.notification-tag--secondary { background-color: var(--gray-500, #6b7280); }

/* ==========================================================================
   TEXT & TYPOGRAPHY UTILITIES
   ========================================================================== */

/* Bootstrap 5 provides: text-start, text-center, text-end (logical properties)
   Legacy aliases for backward compatibility */
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.font-italic { font-style: italic !important; }
.font-normal { font-style: normal !important; }

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

/* === WORD BREAK UTILITIES === */
.word-break-all { word-break: break-all !important; }

/* ==========================================================================
   BORDER & LAYOUT UTILITIES
   ========================================================================== */

.rounded-0 { border-radius: 0 !important; }
.rounded-sm { border-radius: var(--border-radius-sm, 4px) !important; }
.rounded { border-radius: var(--border-radius-md, 8px) !important; }
.rounded-lg { border-radius: var(--border-radius-lg, 12px) !important; }
.rounded-xl { border-radius: var(--border-radius-xl, 16px) !important; }
.rounded-full { border-radius: var(--border-radius-full, 9999px) !important; }

/* Bootstrap 5 provides: w-100, h-100, w-auto, h-auto
   Custom aliases for Tailwind-like syntax */
.w-full { width: 100% !important; }
.h-full { height: 100% !important; }

.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }
.position-static { position: static !important; }

.overflow-hidden { overflow: hidden !important; }
.overflow-visible { overflow: visible !important; }
.overflow-auto { overflow: auto !important; }

/* === BUTTON RESET UTILITY === */
.btn-reset {
  border: none !important;
  background: none !important;
  padding: inherit !important;
}

/* === PROGRESS BAR UTILITIES === */
.progress-thin { height: 4px !important; }

/* === IMAGE UTILITIES === */
.img-thumbnail {
  max-width: 100px !important;
  max-height: 100px !important;
  object-fit: cover !important;
}

.img-responsive {
  max-width: 100% !important;
  height: auto !important;
}

/* === DYNAMIC COLOR CSS VARIABLES === */
.category-bg { background-color: var(--category-color, #6b7280) !important; }
.category-text { color: var(--category-color, #6b7280) !important; }

/* === PROGRESS BAR DYNAMIC WIDTH === */
.progress-dynamic { width: var(--progress-width, 0%) !important; }
.participation-fill { width: var(--participation-width, 0%) !important; }
.success-rate-fill { width: var(--success-rate, 0%) !important; }

/* ==========================================================================
   ANIMATION UTILITIES
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideInDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-30px); }
  60% { transform: translateY(-15px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80% { transform: translateX(10px); }
}

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

/* Animation Classes */
.animate-fade-in { animation: fadeIn 0.3s ease-in; }
.animate-fade-out { animation: fadeOut 0.3s ease-out; }
.animate-slide-in-down { animation: slideInDown 0.4s ease-out; }
.animate-slide-in-up { animation: slideInUp 0.4s ease-out; }
.animate-slide-in-right { animation: slideInRight 0.3s ease-out; }
.animate-pulse { animation: pulse 1s ease-in-out infinite; }
.animate-bounce { animation: bounce 1s ease-in-out infinite; }
.animate-shake { animation: shake 0.5s ease-in-out; }
.animate-spin { animation: spin 1s linear infinite; }

/* ==========================================================================
   RESPONSIVE UTILITIES - Using Bootstrap 5 responsive utilities
   ========================================================================== */

/* Bootstrap 5 provides responsive variants:
   d-{sm|md|lg|xl|xxl}-{none|block|flex|inline|inline-block}
   text-{sm|md|lg|xl|xxl}-{start|center|end}
   All responsive display and text utilities now use Bootstrap's built-in classes */

/* ==========================================================================
   PRINT UTILITIES
   ========================================================================== */

@media print {
  .no-print { display: none !important; }
}

/* ==========================================================================
   NOTIFICATION SETTINGS - CSP COMPLIANT STYLES
   ========================================================================== */

/* Email indicator for notification previews */
.email-indicator {
    float: right;
    color: #007bff;
    font-size: 0.75rem;
}

/* Changes detected state for save button */
.btn-save.changes-detected {
    background: #ffc107 !important;
}

/* ==========================================================================
   CSP-COMPLIANT UTILITY CLASSES
   ========================================================================== */

/* Display utilities */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.invisible {
    visibility: hidden !important;
}

/* Overflow utilities */
.overflow-hidden {
    overflow: hidden !important;
}

.overflow-visible {
    overflow: visible !important;
}

/* Height utilities */
.height-100vh {
    height: 100vh !important;
}

.height-auto {
    height: auto !important;
}

/* Opacity utilities */
.opacity-0 {
    opacity: 0 !important;
}

.opacity-50 {
    opacity: 0.5 !important;
}

.opacity-70 {
    opacity: 0.7 !important;
}

.opacity-100 {
    opacity: 1 !important;
}

/* Color utilities - duplicate definitions removed, using Bootstrap 5 color utilities */

/* Background utilities */
.bg-danger-light {
    background-color: #ffe6e6 !important;
}

.border-danger {
    border-color: #e74c3c !important;
}

/* State utilities */
.disabled {
    pointer-events: none !important;
    opacity: 0.5 !important;
}

/* Transform utilities */
.scale-up {
    transform: scale(1.05) !important;
}

.scale-down {
    transform: scale(0.95) !important;
}

.scale-normal {
    transform: scale(1) !important;
}

/* Positioning utilities */
.position-fixed {
    position: fixed !important;
}

.position-absolute {
    position: absolute !important;
}

.position-relative {
    position: relative !important;
}

.z-index-modal {
    z-index: 1055 !important;
}

.z-index-dropdown {
    z-index: 1000 !important;
}

/* Pointer events */
.pointer-events-none {
    pointer-events: none !important;
}

.pointer-events-auto {
    pointer-events: auto !important;
}

/* Animation utilities */
.fade-out {
    animation: fadeOut 0.3s ease forwards !important;
}

.slide-out {
    animation: slideOut 0.3s ease forwards !important;
}

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