/*
 * Loyalty Platform - Modern UI Styles
 * Custom CSS and Design Tokens
 * 
 * Note: Tailwind CSS is loaded separately via app/assets/tailwind/application.css
 * which compiles to app/assets/builds/tailwind.css
 */

/* Custom Design Tokens */
@theme {
  /* Extended Color Palette */
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;
  --color-primary-200: #bfdbfe;
  --color-primary-300: #93c5fd;
  --color-primary-400: #60a5fa;
  --color-primary-500: #3b82f6;
  --color-primary-600: #2563eb;
  --color-primary-700: #1d4ed8;
  --color-primary-800: #1e40af;
  --color-primary-900: #1e3a8a;
  
  --color-success-50: #f0fdf4;
  --color-success-100: #dcfce7;
  --color-success-500: #22c55e;
  --color-success-600: #16a34a;
  --color-success-700: #15803d;
  
  --color-danger-50: #fef2f2;
  --color-danger-100: #fee2e2;
  --color-danger-500: #ef4444;
  --color-danger-600: #dc2626;
  --color-danger-700: #b91c1c;
  
  --color-warning-50: #fefce8;
  --color-warning-100: #fef9c3;
  --color-warning-500: #eab308;
  --color-warning-600: #ca8a04;
  
  /* Custom Spacing */
  --spacing-18: 4.5rem;
  --spacing-88: 22rem;
  
  /* Custom Shadows */
  --shadow-soft: 0 2px 15px -3px rgb(0 0 0 / 0.07), 0 10px 20px -2px rgb(0 0 0 / 0.04);
  --shadow-glow: 0 0 15px rgb(59 130 246 / 0.5);
  --shadow-glow-sm: 0 0 10px rgb(59 130 246 / 0.3);
  
  /* Animations */
  --animate-fade-in: fadeIn 0.3s ease-in-out;
  --animate-slide-up: slideUp 0.4s ease-out;
  --animate-slide-down: slideDown 0.3s ease-out;
  --animate-scale-in: scaleIn 0.2s ease-out;
  --animate-shimmer: shimmer 2s infinite;
  
  /* Border Radius */
  --radius-2xl: 1rem;
  --radius-3xl: 1.5rem;
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-rainbow: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

/* Keyframe Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

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

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 5px rgb(59 130 246 / 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgb(59 130 246 / 0.6);
  }
}

@keyframes bounce-in {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Custom Utility Classes */
.animate-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.animate-slide-up {
  animation: slideUp 0.4s ease-out;
}

.animate-slide-down {
  animation: slideDown 0.3s ease-out;
}

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

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

.animate-bounce-in {
  animation: bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Glass Morphism Effect */
.glass {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.glass-dark {
  background: rgba(31, 41, 55, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Gradient Text */
.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Card Hover Effects */
.card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Button Styles */
.btn {
  @apply inline-flex items-center justify-center px-4 py-2 border rounded-lg text-sm font-medium transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2;
}

.btn-primary {
  @apply btn bg-gradient-to-r from-blue-600 to-blue-700 text-white border-transparent hover:from-blue-700 hover:to-blue-800 focus:ring-blue-500 shadow-md hover:shadow-lg;
}

.btn-secondary {
  @apply btn bg-white text-gray-700 border-gray-300 hover:bg-gray-50 focus:ring-blue-500 shadow-sm hover:shadow-md;
}

.btn-success {
  @apply btn bg-gradient-to-r from-green-600 to-green-700 text-white border-transparent hover:from-green-700 hover:to-green-800 focus:ring-green-500 shadow-md hover:shadow-lg;
}

.btn-danger {
  @apply btn bg-gradient-to-r from-red-600 to-red-700 text-white border-transparent hover:from-red-700 hover:to-red-800 focus:ring-red-500 shadow-md hover:shadow-lg;
}

/* Form Input Styles */
.form-input {
  @apply block w-full rounded-lg border-gray-300 shadow-sm transition-all duration-200 focus:border-blue-500 focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50;
}

.form-input:focus {
  @apply ring-2 ring-blue-500 border-blue-500;
}

/* Badge Styles */
.badge {
  @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
}

.badge-primary {
  @apply badge bg-blue-100 text-blue-800;
}

.badge-success {
  @apply badge bg-green-100 text-green-800;
}

.badge-warning {
  @apply badge bg-yellow-100 text-yellow-800;
}

.badge-danger {
  @apply badge bg-red-100 text-red-800;
}

.badge-gray {
  @apply badge bg-gray-100 text-gray-800;
}

/* Skeleton Loader */
.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 0px,
    #e0e0e0 40px,
    #f0f0f0 80px
  );
  background-size: 1000px;
  animation: shimmer 2s infinite;
}

/* Modern Notification System */
.notification {
  background: white;
  border-radius: 8px;
  pointer-events: auto;
  position: relative;
  min-width: 400px;
  max-width: 500px;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.notification-enter {
  opacity: 1;
  transform: translateX(0);
}

.notification-exit {
  opacity: 0;
  transform: translateX(120%);
  transition: all 0.3s ease-in;
}

.notification-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.notification-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-message {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  line-height: 1.5;
}

.notification-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  pointer-events: auto;
}

.notification-close:hover {
  color: #4b5563;
  background: #f3f4f6;
}

.notification-progress-wrapper {
  @apply absolute bottom-0 left-0 right-0 h-1 bg-gray-100 overflow-hidden;
}

.notification-progress {
  @apply h-full;
  width: 100%;
}

/* Success */
.notification-success {
  border-left: 4px solid #10b981;
}

.notification-success .notification-icon {
  @apply text-green-600;
}

.notification-success .notification-progress {
  @apply bg-green-600;
}

/* Error */
.notification-error {
  border-left: 4px solid #ef4444;
}

.notification-error .notification-icon {
  @apply text-red-600;
}

.notification-error .notification-progress {
  @apply bg-red-600;
}

/* Warning */
.notification-warning {
  border-left: 4px solid #f59e0b;
}

.notification-warning .notification-icon {
  @apply text-orange-600;
}

.notification-warning .notification-progress {
  @apply bg-orange-600;
}

/* Info */
.notification-info {
  border-left: 4px solid #3b82f6;
}

.notification-info .notification-icon {
  @apply text-blue-600;
}

.notification-info .notification-progress {
  @apply bg-blue-600;
}

/* Loading Spinner */
.spinner {
  border: 3px solid rgba(59, 130, 246, 0.1);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Smooth Transitions */
.transition-smooth {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus Visible Styles for Accessibility */
*:focus-visible {
  @apply outline-none ring-2 ring-blue-500 ring-offset-2;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  @apply bg-gray-100;
}

::-webkit-scrollbar-thumb {
  @apply bg-gray-400 rounded-full;
}

::-webkit-scrollbar-thumb:hover {
  @apply bg-gray-500;
}

/* Table Enhancements */
.table-hover tbody tr {
  @apply transition-colors duration-150;
}

.table-hover tbody tr:hover {
  @apply bg-blue-50;
}

/* Metric Card Gradients */
.metric-card-gradient-blue {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.metric-card-gradient-green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.metric-card-gradient-purple {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

.metric-card-gradient-orange {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* ========================================
   NAVIGATION STYLES
   ======================================== */

/* Desktop Navigation Items */
.nav-item {
  @apply inline-flex items-center space-x-2 px-3 py-2 rounded-lg text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 transition-all duration-200;
}

.nav-item-active {
  @apply bg-indigo-50 text-indigo-700 font-semibold;
}

.nav-item-admin {
  @apply text-purple-600 hover:text-purple-700 hover:bg-purple-50;
}

.nav-item-admin.nav-item-active {
  @apply bg-purple-50 text-purple-700;
}

/* Workspace Switcher */
.workspace-switcher {
  @apply flex items-center space-x-2 px-3 py-2 rounded-lg text-sm bg-white border border-gray-200 hover:border-gray-300 hover:shadow-sm transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2;
}

/* User Menu Button */
.user-menu-button {
  @apply flex items-center space-x-2 px-2 py-1.5 rounded-lg hover:bg-gray-50 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2;
}

/* Dropdown Menu */
.dropdown-menu {
  @apply hidden absolute mt-2 w-64 rounded-lg shadow-lg bg-white ring-1 ring-black ring-opacity-5 z-50 overflow-hidden;
}

.dropdown-item {
  @apply flex items-center px-3 py-2.5 text-sm text-gray-700 hover:bg-gray-50 transition-colors duration-150;
}

.dropdown-item-active {
  @apply bg-indigo-50 text-indigo-700 font-medium;
}

.dropdown-item-icon {
  @apply flex items-center justify-center w-8 h-8 mr-3 rounded-lg flex-shrink-0;
}

/* Mobile Menu */
.mobile-menu-button {
  @apply p-2 rounded-lg text-gray-600 hover:text-gray-900 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500 transition-colors duration-200;
}

.mobile-menu-panel {
  @apply hidden fixed top-0 left-0 bottom-0 w-80 max-w-[85vw] bg-white shadow-2xl z-50 transform -translate-x-full transition-transform duration-300 ease-in-out;
}

.mobile-menu-item {
  @apply flex items-center px-3 py-2.5 rounded-lg text-sm font-medium text-gray-700 hover:bg-gray-100 transition-colors duration-200;
}

.mobile-menu-item-active {
  @apply bg-indigo-600 text-white shadow-md;
}

.mobile-menu-item-admin {
  @apply text-purple-600 hover:bg-purple-50;
}

.mobile-menu-item-admin.mobile-menu-item-active {
  @apply bg-purple-600 text-white;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
  @apply fixed inset-0 bg-black bg-opacity-50 z-40 transition-opacity duration-300;
}

/* Dashboard Filter Dropdowns */
select.appearance-none::-ms-expand {
  display: none;
}

.dashboard-filter-select {
  @apply appearance-none block w-full pl-11 pr-10 py-2.5 bg-white border border-gray-300 rounded-xl shadow-sm text-sm font-medium text-gray-900 hover:border-indigo-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition-all duration-200 cursor-pointer;
}

.dashboard-filter-select:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

/* Floating Label Input */
.floating-label {
  @apply relative;
}

.floating-label input:focus ~ label,
.floating-label input:not(:placeholder-shown) ~ label {
  @apply text-xs -top-2.5 left-2 bg-white px-2 text-blue-600;
}

.floating-label label {
  @apply absolute left-3 top-3 text-gray-500 transition-all duration-200 pointer-events-none;
}

/* Progress Bar */
.progress-bar {
  @apply h-2 bg-gray-200 rounded-full overflow-hidden;
}

.progress-bar-fill {
  @apply h-full bg-gradient-to-r from-blue-500 to-blue-600 transition-all duration-500 ease-out;
}

/* Divider with Text */
.divider {
  @apply flex items-center text-sm text-gray-500 my-4;
}

.divider::before,
.divider::after {
  content: '';
  @apply flex-1 border-t border-gray-300;
}

.divider span {
  @apply px-4;
}

/* Stat Trend Arrows */
.trend-up {
  @apply text-green-600;
}

.trend-down {
  @apply text-red-600;
}

/* Chart Container */
.chart-container {
  @apply bg-white rounded-lg shadow-sm p-6 card-hover;
}

/* Responsive Table Wrapper */
.table-responsive {
  @apply overflow-x-auto rounded-lg shadow;
}

/* Empty State */
.empty-state {
  @apply flex flex-col items-center justify-center py-12 text-center;
}

.empty-state-icon {
  @apply w-16 h-16 text-gray-400 mb-4;
}

/* Print Styles */
@media print {
  .no-print {
    display: none !important;
  }
}
