/*
 * OSUS.AI - Main Global Styles
 * Version: 1.0.0
 * Framework: Bootstrap 5.3 + Custom Extensions
 * RTL Support: Full Arabic Layout
 * Last Updated: June 2025
 */

/* ===================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   =================================== */

   :root {
    /* OSUS Brand Colors */
    --osus-primary: #2c5aa0;
    --osus-primary-light: #4a7bc8;
    --osus-primary-dark: #1e3f73;
    --osus-secondary: #f4b942;
    --osus-secondary-light: #f7c96a;
    --osus-secondary-dark: #e09f1c;
    
    /* Egyptian Cultural Colors */
    --osus-gold: #d4af37;
    --osus-gold-light: #e6c757;
    --osus-gold-dark: #b8941f;
    --osus-sand: #f5f1e8;
    --osus-sand-light: #faf8f3;
    --osus-sand-dark: #e8e0d0;
    --osus-bronze: #cd7f32;
    --osus-copper: #b87333;
    
    /* Semantic Colors */
    --osus-success: #198754;
    --osus-danger: #dc3545;
    --osus-warning: #ffc107;
    --osus-info: #0dcaf0;
    --osus-light: #f8f9fa;
    --osus-dark: #212529;
    
    /* Neutral Grays */
    --osus-gray-50: #f9fafb;
    --osus-gray-100: #f3f4f6;
    --osus-gray-200: #e5e7eb;
    --osus-gray-300: #d1d5db;
    --osus-gray-400: #9ca3af;
    --osus-gray-500: #6b7280;
    --osus-gray-600: #4b5563;
    --osus-gray-700: #374151;
    --osus-gray-800: #1f2937;
    --osus-gray-900: #111827;
    
    /* Typography */
    --osus-font-arabic: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --osus-font-english: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --osus-font-mono: 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', monospace;
    
    /* Font Sizes */
    --osus-text-xs: 0.75rem;      /* 12px */
    --osus-text-sm: 0.875rem;     /* 14px */
    --osus-text-base: 1rem;       /* 16px */
    --osus-text-lg: 1.125rem;     /* 18px */
    --osus-text-xl: 1.25rem;      /* 20px */
    --osus-text-2xl: 1.5rem;      /* 24px */
    --osus-text-3xl: 1.875rem;    /* 30px */
    --osus-text-4xl: 2.25rem;     /* 36px */
    --osus-text-5xl: 3rem;        /* 48px */
    
    /* Spacing Scale */
    --osus-space-0: 0;
    --osus-space-1: 0.25rem;      /* 4px */
    --osus-space-2: 0.5rem;       /* 8px */
    --osus-space-3: 0.75rem;      /* 12px */
    --osus-space-4: 1rem;         /* 16px */
    --osus-space-5: 1.25rem;      /* 20px */
    --osus-space-6: 1.5rem;       /* 24px */
    --osus-space-8: 2rem;         /* 32px */
    --osus-space-10: 2.5rem;      /* 40px */
    --osus-space-12: 3rem;        /* 48px */
    --osus-space-16: 4rem;        /* 64px */
    --osus-space-20: 5rem;        /* 80px */
    
    /* Border Radius */
    --osus-radius-none: 0;
    --osus-radius-sm: 0.125rem;   /* 2px */
    --osus-radius-base: 0.25rem;  /* 4px */
    --osus-radius-md: 0.375rem;   /* 6px */
    --osus-radius-lg: 0.5rem;     /* 8px */
    --osus-radius-xl: 0.75rem;    /* 12px */
    --osus-radius-2xl: 1rem;      /* 16px */
    --osus-radius-3xl: 1.5rem;    /* 24px */
    --osus-radius-full: 9999px;
    
    /* Shadows */
    --osus-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --osus-shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --osus-shadow-base: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --osus-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --osus-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --osus-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --osus-shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --osus-shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    
    /* Transitions */
    --osus-transition-fast: all 0.15s ease-in-out;
    --osus-transition-base: all 0.2s ease-in-out;
    --osus-transition-slow: all 0.3s ease-in-out;
    --osus-transition-slower: all 0.5s ease-in-out;
    
    /* Z-Index Scale */
    --osus-z-0: 0;
    --osus-z-10: 10;
    --osus-z-20: 20;
    --osus-z-30: 30;
    --osus-z-40: 40;
    --osus-z-50: 50;
    --osus-z-auto: auto;
    --osus-z-dropdown: 1000;
    --osus-z-sticky: 1020;
    --osus-z-fixed: 1030;
    --osus-z-modal-backdrop: 1040;
    --osus-z-modal: 1050;
    --osus-z-popover: 1060;
    --osus-z-tooltip: 1070;
    --osus-z-toast: 1080;
  }
  
  /* ===================================
     BASE TYPOGRAPHY & RTL SUPPORT
     =================================== */
  
  html {
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
  }
  
  body {
    font-family: var(--osus-font-arabic);
    font-size: var(--osus-text-base);
    line-height: 1.6;
    color: var(--osus-gray-800);
    background-color: var(--osus-sand-light);
    direction: rtl;
    text-align: right;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  /* English text direction override */
  [lang="en"], .text-en {
    direction: ltr;
    text-align: left;
    font-family: var(--osus-font-english);
  }
  
  /* Arabic text optimization */
  [lang="ar"], .text-ar {
    direction: rtl;
    text-align: right;
    font-family: var(--osus-font-arabic);
  }
  
  /* ===================================
     BOOTSTRAP OVERRIDES & EXTENSIONS
     =================================== */
  
  /* Container Customizations */
  .container,
  .container-fluid,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl {
    padding-right: var(--osus-space-4);
    padding-left: var(--osus-space-4);
  }
  
  /* Button Customizations */
  .btn {
    font-family: var(--osus-font-arabic);
    font-weight: 500;
    border-radius: var(--osus-radius-md);
    transition: var(--osus-transition-fast);
    border: 1px solid transparent;
    padding: var(--osus-space-2) var(--osus-space-4);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--osus-space-2);
  }
  
  .btn:hover,
  .btn:focus {
    transform: translateY(-1px);
    box-shadow: var(--osus-shadow-md);
  }
  
  .btn:active {
    transform: translateY(0);
    box-shadow: var(--osus-shadow-sm);
  }
  
  /* OSUS Custom Button Variants */
  .btn-osus-primary {
    background: linear-gradient(135deg, var(--osus-primary), var(--osus-primary-dark));
    color: white;
    border-color: var(--osus-primary);
  }
  
  .btn-osus-primary:hover {
    background: linear-gradient(135deg, var(--osus-primary-dark), var(--osus-primary));
    border-color: var(--osus-primary-dark);
    color: white;
  }
  
  .btn-osus-secondary {
    background: linear-gradient(135deg, var(--osus-secondary), var(--osus-secondary-dark));
    color: var(--osus-dark);
    border-color: var(--osus-secondary);
    font-weight: 600;
  }
  
  .btn-osus-secondary:hover {
    background: linear-gradient(135deg, var(--osus-secondary-dark), var(--osus-secondary));
    border-color: var(--osus-secondary-dark);
    color: var(--osus-dark);
  }
  
  .btn-osus-gold {
    background: linear-gradient(135deg, var(--osus-gold), var(--osus-gold-dark));
    color: var(--osus-dark);
    border-color: var(--osus-gold);
    font-weight: 600;
  }
  
  .btn-osus-gold:hover {
    background: linear-gradient(135deg, var(--osus-gold-dark), var(--osus-gold));
    border-color: var(--osus-gold-dark);
    color: var(--osus-dark);
  }
  
  /* Icon Buttons */
  .btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--osus-radius-lg);
  }
  
  .btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: var(--osus-radius-base);
  }
  
  .btn-icon-lg {
    width: 48px;
    height: 48px;
    border-radius: var(--osus-radius-xl);
  }
  
  /* Card Customizations */
  .card {
    border: 1px solid var(--osus-gray-200);
    border-radius: var(--osus-radius-xl);
    box-shadow: var(--osus-shadow-sm);
    transition: var(--osus-transition-base);
    background: white;
  }
  
  .card:hover {
    box-shadow: var(--osus-shadow-lg);
    transform: translateY(-2px);
  }
  
  .card-header {
    background: var(--osus-sand-light);
    border-bottom: 1px solid var(--osus-gray-200);
    padding: var(--osus-space-4);
    border-radius: var(--osus-radius-xl) var(--osus-radius-xl) 0 0;
  }
  
  .card-body {
    padding: var(--osus-space-6);
  }
  
  .card-footer {
    background: var(--osus-sand-light);
    border-top: 1px solid var(--osus-gray-200);
    padding: var(--osus-space-4);
    border-radius: 0 0 var(--osus-radius-xl) var(--osus-radius-xl);
  }
  
  /* Form Customizations */
  .form-control,
  .form-select {
    border: 1px solid var(--osus-gray-300);
    border-radius: var(--osus-radius-md);
    transition: var(--osus-transition-fast);
    font-family: var(--osus-font-arabic);
  }
  
  .form-control:focus,
  .form-select:focus {
    border-color: var(--osus-primary);
    box-shadow: 0 0 0 0.2rem rgba(44, 90, 160, 0.25);
  }
  
  .form-label {
    font-weight: 500;
    color: var(--osus-gray-700);
    margin-bottom: var(--osus-space-2);
  }
  
  /* Badge Customizations */
  .badge {
    font-weight: 500;
    border-radius: var(--osus-radius-full);
    padding: var(--osus-space-1) var(--osus-space-3);
  }
  
  /* Alert Customizations */
  .alert {
    border-radius: var(--osus-radius-lg);
    border: none;
    padding: var(--osus-space-4);
  }
  
  .alert-primary {
    background: rgba(44, 90, 160, 0.1);
    color: var(--osus-primary-dark);
  }
  
  .alert-success {
    background: rgba(25, 135, 84, 0.1);
    color: var(--osus-success);
  }
  
  .alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
  }
  
  .alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--osus-danger);
  }
  
  /* ===================================
     NAVIGATION & HEADER STYLES
     =================================== */
  
  .navbar-osus {
    background: linear-gradient(135deg, var(--osus-primary), var(--osus-primary-dark));
    backdrop-filter: blur(10px);
    box-shadow: var(--osus-shadow-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .navbar-brand {
    font-weight: 700;
    font-size: var(--osus-text-xl);
    color: white !important;
  }
  
  .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    transition: var(--osus-transition-fast);
    padding: var(--osus-space-2) var(--osus-space-4);
    border-radius: var(--osus-radius-md);
  }
  
  .nav-link:hover,
  .nav-link:focus {
    color: white !important;
    background: rgba(255, 255, 255, 0.1);
  }
  
  .nav-link.active {
    color: white !important;
    background: rgba(255, 255, 255, 0.2);
  }
  
  /* Mega Menu Styles */
  .mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    box-shadow: var(--osus-shadow-xl);
    border-radius: 0 0 var(--osus-radius-xl) var(--osus-radius-xl);
    padding: var(--osus-space-8);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--osus-transition-base);
    z-index: var(--osus-z-dropdown);
  }
  
  .nav-item:hover .mega-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  
  .mega-menu-category h6 {
    color: var(--osus-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--osus-gold);
    padding-bottom: var(--osus-space-2);
    margin-bottom: var(--osus-space-3);
  }
  
  .category-links {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .category-links li {
    margin-bottom: var(--osus-space-2);
  }
  
  .category-links a {
    color: var(--osus-gray-600);
    text-decoration: none;
    transition: var(--osus-transition-fast);
    display: flex;
    align-items: center;
    gap: var(--osus-space-2);
    padding: var(--osus-space-2);
    border-radius: var(--osus-radius-base);
  }
  
  .category-links a:hover {
    color: var(--osus-primary);
    background: var(--osus-sand-light);
  }
  
  /* ===================================
     HERO SECTION STYLES
     =================================== */
  
  .hero-section {
    background: linear-gradient(135deg, 
      var(--osus-primary) 0%, 
      var(--osus-primary-dark) 50%, 
      var(--osus-secondary) 100%);
    color: white;
    padding: var(--osus-space-20) 0;
    position: relative;
    overflow: hidden;
  }
  
  .hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><polygon fill="rgba(255,255,255,0.05)" points="0,0 1000,300 1000,1000 0,700"/></svg>');
    background-size: cover;
    pointer-events: none;
  }
  
  .hero-content {
    position: relative;
    z-index: 2;
  }
  
  .hero-title {
    font-size: var(--osus-text-5xl);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--osus-space-6);
  }
  
  .hero-subtitle {
    font-size: var(--osus-text-xl);
    line-height: 1.6;
    opacity: 0.9;
    margin-bottom: var(--osus-space-8);
  }
  
  /* ===================================
     UTILITY CLASSES
     =================================== */
  
  /* Spacing Utilities */
  .p-xs { padding: var(--osus-space-1); }
  .p-sm { padding: var(--osus-space-2); }
  .p-md { padding: var(--osus-space-4); }
  .p-lg { padding: var(--osus-space-6); }
  .p-xl { padding: var(--osus-space-8); }
  
  .m-xs { margin: var(--osus-space-1); }
  .m-sm { margin: var(--osus-space-2); }
  .m-md { margin: var(--osus-space-4); }
  .m-lg { margin: var(--osus-space-6); }
  .m-xl { margin: var(--osus-space-8); }
  
  /* Text Utilities */
  .text-osus-primary { color: var(--osus-primary); }
  .text-osus-secondary { color: var(--osus-secondary); }
  .text-osus-gold { color: var(--osus-gold); }
  
  .bg-osus-primary { background-color: var(--osus-primary); }
  .bg-osus-secondary { background-color: var(--osus-secondary); }
  .bg-osus-gold { background-color: var(--osus-gold); }
  .bg-osus-sand { background-color: var(--osus-sand); }
  
  /* Border Utilities */
  .border-osus-primary { border-color: var(--osus-primary); }
  .border-osus-secondary { border-color: var(--osus-secondary); }
  .border-osus-gold { border-color: var(--osus-gold); }
  
  /* Shadow Utilities */
  .shadow-xs { box-shadow: var(--osus-shadow-xs); }
  .shadow-sm { box-shadow: var(--osus-shadow-sm); }
  .shadow-md { box-shadow: var(--osus-shadow-md); }
  .shadow-lg { box-shadow: var(--osus-shadow-lg); }
  .shadow-xl { box-shadow: var(--osus-shadow-xl); }
  
  /* Rounded Utilities */
  .rounded-xs { border-radius: var(--osus-radius-sm); }
  .rounded-sm { border-radius: var(--osus-radius-base); }
  .rounded-md { border-radius: var(--osus-radius-md); }
  .rounded-lg { border-radius: var(--osus-radius-lg); }
  .rounded-xl { border-radius: var(--osus-radius-xl); }
  .rounded-2xl { border-radius: var(--osus-radius-2xl); }
  .rounded-3xl { border-radius: var(--osus-radius-3xl); }
  
  /* Interactive States */
  .cursor-pointer { cursor: pointer; }
  .cursor-not-allowed { cursor: not-allowed; }
  
  .hover-lift {
    transition: var(--osus-transition-base);
  }
  
  .hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--osus-shadow-lg);
  }
  
  /* ===================================
     HTMX INTEGRATION STYLES
     =================================== */
  
  /* HTMX Loading States */
  .htmx-request {
    opacity: 0.7;
    transition: var(--osus-transition-fast);
    pointer-events: none;
  }
  
  .htmx-request::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--osus-primary);
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: htmx-spinner 1s linear infinite;
  }
  
  @keyframes htmx-spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* HTMX Animation States */
  .htmx-added {
    animation: htmx-fadeInUp 0.3s ease-out;
  }
  
  .htmx-removed {
    animation: htmx-fadeOutDown 0.3s ease-in;
  }
  
  .htmx-swapping {
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
  }
  
  .htmx-settling {
    opacity: 1;
    transition: opacity 0.15s ease-in-out;
  }
  
  @keyframes htmx-fadeInUp {
    0% {
      opacity: 0;
      transform: translateY(20px);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  @keyframes htmx-fadeOutDown {
    0% {
      opacity: 1;
      transform: translateY(0);
    }
    100% {
      opacity: 0;
      transform: translateY(20px);
    }
  }
  
  /* ===================================
     RESPONSIVE DESIGN
     =================================== */
  
  /* Mobile First Approach */
  @media (max-width: 768px) {
    .hero-title {
      font-size: var(--osus-text-3xl);
    }
    
    .hero-subtitle {
      font-size: var(--osus-text-lg);
    }
    
    .container,
    .container-fluid {
      padding-right: var(--osus-space-3);
      padding-left: var(--osus-space-3);
    }
    
    .btn {
      padding: var(--osus-space-3) var(--osus-space-4);
    }
    
    .card-body {
      padding: var(--osus-space-4);
    }
  }
  
  /* Tablet Styles */
  @media (min-width: 768px) and (max-width: 1024px) {
    .hero-title {
      font-size: var(--osus-text-4xl);
    }
  }
  
  /* Desktop Styles */
  @media (min-width: 1024px) {
    .hero-section {
      padding: var(--osus-space-20) 0;
    }
  }
  
  /* ===================================
     ACCESSIBILITY IMPROVEMENTS
     =================================== */
  
  /* Focus Indicators */
  .btn:focus,
  .form-control:focus,
  .form-select:focus,
  .nav-link:focus {
    outline: 2px solid var(--osus-primary);
    outline-offset: 2px;
  }
  
  /* Reduced Motion Support */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* High Contrast Mode Support */
  @media (prefers-contrast: high) {
    .card {
      border: 2px solid var(--osus-gray-800);
    }
    
    .btn {
      border: 2px solid currentColor;
    }
  }
  
  /* ===================================
     PRINT STYLES
     =================================== */
  
  @media print {
    .navbar,
    .btn,
    .hero-section {
      display: none !important;
    }
    
    body {
      background: white !important;
      color: black !important;
    }
    
    .card {
      border: 1px solid black;
      box-shadow: none;
    }
  }