/* Global Loading, Animation, and Mobile Styles */

/* Loading States */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(14, 165, 233, 0.3);
  border-radius: 50%;
  border-top-color: #0ea5e9;
  animation: spin 1s linear infinite;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 22, 40, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.loading-card {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  min-width: 200px;
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

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

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Smooth Transitions */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

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

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

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

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

/* Hover Effects */
.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
  /* Reduce padding on mobile */
  .main-content {
    padding: 1rem !important;
  }
  
  /* Stack grid layouts */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-5 {
    grid-template-columns: 1fr !important;
  }
  
  /* Sidebar responsive */
  .sidebar {
    width: 100%;
    position: relative;
    min-height: auto;
  }
  
  /* Hide sidebar on mobile, show hamburger */
  .sidebar-desktop {
    display: none;
  }
  
  /* Adjust main content margin */
  .main-content-with-sidebar {
    margin-left: 0 !important;
  }
  
  /* Smaller text on mobile */
  h1 {
    font-size: 1.75rem !important;
  }
  
  h2 {
    font-size: 1.5rem !important;
  }
  
  h3 {
    font-size: 1.25rem !important;
  }
  
  /* Adjust button padding */
  .btn,
  button {
    padding: 0.625rem 1rem !important;
    font-size: 0.875rem !important;
  }
  
  /* Tables scroll horizontally */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  /* Cards stack */
  .intelligence-card,
  .market-card,
  .view-card,
  .report-card {
    margin-bottom: 1rem;
  }
}

@media (max-width: 640px) {
  /* Extra small mobile adjustments */
  .stat-box,
  .stat-card {
    padding: 0.75rem !important;
  }
  
  .stat-value {
    font-size: 1.5rem !important;
  }
  
  .stat-label {
    font-size: 0.625rem !important;
  }
}

/* Error States */
.error-banner {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.05) 100%);
  border: 2px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.error-icon {
  color: #ef4444;
  font-size: 1.5rem;
}

.error-message {
  flex: 1;
  color: #991b1b;
}

.error-retry {
  background: #ef4444;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.error-retry:hover {
  background: #dc2626;
}

/* Success States */
.success-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.05) 100%);
  border: 2px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.success-icon {
  color: #10b981;
  font-size: 1.5rem;
}

.success-message {
  flex: 1;
  color: #065f46;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 300px;
  z-index: 10000;
  animation: slideInRight 0.3s ease-out;
}

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

.toast-success {
  border-left: 4px solid #10b981;
}

.toast-error {
  border-left: 4px solid #ef4444;
}

.toast-info {
  border-left: 4px solid #0ea5e9;
}

/* Accessibility */
.focus-visible:focus {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* Skip to main content */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #0ea5e9;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 8px 0;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

/* Print Styles */
@media print {
  .sidebar,
  nav,
  footer,
  .no-print {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0 !important;
  }
  
  .intelligence-card {
    page-break-inside: avoid;
  }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0a192f;
    --bg-secondary: #1a2942;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
  }
}

/* Performance: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
