/* CSS Custom Properties */
:root {
  /* Dark Theme Gradients */
  --dark-bg-start: #0A0A0F;
  --dark-bg-mid: #1A1A2E;
  --dark-bg-end: #16213E;
  
  /* Light Theme Gradients */
  --light-bg-start: #F8FAFF;
  --light-bg-mid: #EEF4FF;
  --light-bg-end: #E6F0FF;
  
  /* Accent Colors */
  --premium-gold: #D4AF37;
  --success-green: #22C55E;
  --caution-red: #EF4444;
  --primary-blue: #1565C0;
  --secondary-blue: #1976D2;
}

/* Base Styles */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: background-color 0.3s ease;
}

/* Premium Card Component */
.premium-card {
  border-radius: 1rem;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.dark .premium-card {
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.1);
}

.premium-card:hover {
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

/* Loading Skeleton Animation */
@keyframes skeleton-loading {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.1) 25%,
    rgba(0, 0, 0, 0.2) 50%,
    rgba(0, 0, 0, 0.1) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

.dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.1) 25%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0.1) 75%
  );
  background-size: 200% 100%;
}

/* Chart Container Styles */
canvas {
  max-width: 100%;
  height: auto !important;
}

/* Counter Animation */
.counter {
  display: inline-block;
}

/* Smooth Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 5px;
}

.dark ::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 5px;
  transition: background 0.3s ease;
}

.dark ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.5);
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Focus Styles for Accessibility */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .premium-card {
    background: white !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .premium-card {
    border-width: 2px;
  }
  
  button {
    border: 2px solid currentColor;
  }
}

/* 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;
  }
}

/* Custom Utility Classes */
.glass-effect {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass-effect {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Module Card Hover Effects */
.module-card {
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  opacity: 0;
  transform: scale(0);
  transition: all 0.5s ease;
}

.module-card:hover::before {
  opacity: 1;
  transform: scale(1);
}

/* Loading States */
.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: loading-bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loading-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Tooltip Styles */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 0.875rem;
  border-radius: 0.375rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Modal Backdrop Blur */
.modal-backdrop {
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.5);
}

/* Comprehensive Mobile Responsiveness */
@media (max-width: 768px) {
  /* Tables */
  table {
    font-size: 0.875rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  th, td {
    padding: 0.5rem !important;
    min-width: 120px;
  }
  
  .hide-mobile {
    display: none;
  }
  
  /* Typography */
  h1 {
    font-size: 2.5rem !important;
  }
  
  h2 {
    font-size: 2rem !important;
  }
  
  h3 {
    font-size: 1.5rem !important;
  }
  
  /* Navigation */
  nav {
    padding: 1rem !important;
  }
  
  /* Cards and Containers */
  .premium-card,
  .glass-card {
    margin: 0.5rem;
    padding: 1rem !important;
  }
  
  /* Buttons */
  button,
  .btn {
    padding: 0.75rem 1.5rem !important;
    font-size: 0.875rem !important;
  }
  
  /* Grid layouts */
  .grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
  
  /* Flex layouts */
  .flex-col-mobile {
    flex-direction: column !important;
  }
  
  /* Spacing */
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  
  /* Charts */
  canvas {
    max-height: 300px !important;
  }
  
  /* Forms */
  input,
  select,
  textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
}

/* Chart.js Dark Mode Overrides */
.dark canvas {
  filter: invert(1) hue-rotate(180deg);
}

/* Custom Input Styles */
input[type="file"] {
  cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
  visibility: hidden;
}

/* Progress Bar Animation */
.progress-bar {
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Card Shine Effect */
.card-shine {
  position: relative;
  overflow: hidden;
}

.card-shine::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  transform: rotate(45deg) translateY(100%);
  transition: transform 0.6s;
}

.card-shine:hover::before {
  transform: rotate(45deg) translateY(-100%);
}

/* Success Animation */
@keyframes success-check {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.success-animation {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: success-check 0.5s ease-out forwards;
}

/* Pulse Animation for Notifications */
@keyframes notification-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

.notification-dot {
  animation: notification-pulse 2s infinite;
}

/* Dropdown and Form Input Styling for Dark Theme */
.dark select,
select {
  background-color: rgba(0, 0, 0, 0.3) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.dark select option,
select option {
  background-color: #1a1a2e !important;
  color: white !important;
  padding: 8px !important;
}

.dark select option:hover,
.dark select option:focus,
.dark select option:checked,
select option:hover,
select option:focus,
select option:checked {
  background-color: #9333ea !important;
  color: white !important;
}

/* Override specific background colors for dropdowns */
.dark select[class*="bg-white"],
.dark select[class*="bg-gray-800"],
select[class*="bg-white"],
select[class*="bg-gray-800"] {
  background-color: rgba(0, 0, 0, 0.3) !important;
  color: white !important;
}

/* Input Styling for Dark Theme */
.dark input[type="text"],
.dark input[type="email"],
.dark input[type="password"],
.dark textarea,
input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  background-color: rgba(0, 0, 0, 0.3) !important;
  color: white !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.dark input[type="text"]:focus,
.dark input[type="email"]:focus,
.dark input[type="password"]:focus,
.dark textarea:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: rgba(147, 51, 234, 0.5) !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.2) !important;
}

.dark input::placeholder,
.dark textarea::placeholder,
input::placeholder,
textarea::placeholder {
  color: rgba(156, 163, 175, 0.8) !important;
}

/* Override specific input background colors */
.dark input[class*="bg-white"],
.dark input[class*="bg-gray"],
.dark textarea[class*="bg-white"],
.dark textarea[class*="bg-gray"],
input[class*="bg-white"],
input[class*="bg-gray"],
textarea[class*="bg-white"],
textarea[class*="bg-gray"] {
  background-color: rgba(0, 0, 0, 0.3) !important;
  color: white !important;
}

/* Comprehensive form element styling for dark theme */
.dark input,
.dark select,
.dark textarea,
input,
select,
textarea {
  background-color: rgba(0, 0, 0, 0.3) !important;
  color: white !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Ensure dropdown options are properly styled */
.dark select option,
select option {
  background-color: #1a1a2e !important;
  color: white !important;
}

/* Fix for webkit appearance */
.dark select,
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px !important;
}

/* Premium Popup System Styles */
.popup-backdrop {
  backdrop-filter: blur(12px) saturate(180%);
  background: rgba(0, 0, 0, 0.6);
  animation: fadeIn 0.3s ease-out;
}

.popup-content {
  background: rgba(10, 10, 35, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: popupSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popupSlideIn {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popup-header {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1) 0%, rgba(0, 128, 255, 0.1) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.popup-icon {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 128, 255, 0.2) 100%);
  border: 1px solid rgba(0, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 255, 255, 0.2);
}

.popup-feature-item {
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.popup-feature-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}

.popup-demo-notice {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1) 0%, rgba(0, 128, 255, 0.1) 100%);
  border: 1px solid rgba(0, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.popup-demo-notice::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.help-button {
  background: linear-gradient(135deg, #00FFFF 0%, #0080FF 100%);
  box-shadow: 
    0 8px 32px rgba(0, 255, 255, 0.3),
    0 4px 16px rgba(0, 128, 255, 0.2);
  animation: helpButtonPulse 2s ease-in-out infinite;
}

.help-button:hover {
  box-shadow: 
    0 12px 40px rgba(0, 255, 255, 0.4),
    0 6px 20px rgba(0, 128, 255, 0.3);
  transform: scale(1.1) translateY(-2px);
}

@keyframes helpButtonPulse {
  0%, 100% {
    box-shadow: 
      0 8px 32px rgba(0, 255, 255, 0.3),
      0 4px 16px rgba(0, 128, 255, 0.2);
  }
  50% {
    box-shadow: 
      0 12px 40px rgba(0, 255, 255, 0.4),
      0 6px 20px rgba(0, 128, 255, 0.3);
  }
}

/* Popup Button Styles */
.popup-button-primary {
  background: linear-gradient(135deg, #00FFFF 0%, #0080FF 100%);
  color: #0A0A23;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 255, 255, 0.3);
}

.popup-button-primary:hover {
  background: linear-gradient(135deg, #66FFFF 0%, #3399FF 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 255, 255, 0.4);
}

.popup-button-secondary {
  color: rgba(156, 163, 175, 1);
  transition: all 0.3s ease;
}

.popup-button-secondary:hover {
  color: rgba(209, 213, 219, 1);
  background: rgba(255, 255, 255, 0.05);
}

/* Tablet Responsiveness */
@media (max-width: 1024px) and (min-width: 769px) {
  .container {
    padding-left: 2rem !important;
    padding-right: 2rem !important;
  }
  
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  h1 {
    font-size: 3rem !important;
  }
  
  h2 {
    font-size: 2.5rem !important;
  }
}

/* Responsive Popup Styles */
@media (max-width: 768px) {
  .popup-content {
    margin: 1rem;
    max-width: calc(100vw - 2rem);
  }
  
  .popup-header {
    padding: 1rem;
  }
  
  .popup-body {
    padding: 1rem;
  }
  
  .popup-footer {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }
  
  .help-button {
    width: 3rem;
    height: 3rem;
    bottom: 1rem;
    right: 1rem;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  h1 {
    font-size: 2rem !important;
  }
  
  h2 {
    font-size: 1.75rem !important;
  }
  
  h3 {
    font-size: 1.25rem !important;
  }
  
  .container {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  
  .premium-card,
  .glass-card {
    margin: 0.25rem;
    padding: 0.75rem !important;
  }
  
  button,
  .btn {
    padding: 0.5rem 1rem !important;
    font-size: 0.8rem !important;
  }
}

/* Large Screens */
@media (min-width: 1440px) {
  .container {
    max-width: 1400px;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  button,
  a,
  input,
  select {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .service-card:hover,
  .module-card:hover,
  .card-shine:hover::before {
    transform: none;
  }
  
  /* Optimize animations for touch */
  .cursor,
  .cursor-follower {
    display: none !important;
  }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
  /* Optimize for retina displays */
  .premium-card,
  .glass-card {
    border-width: 0.5px;
  }
}

/* Landscape Mobile Optimization */
@media (max-width: 768px) and (orientation: landscape) {
  .min-h-screen {
    min-height: 100vh;
  }
  
  nav {
    padding: 0.5rem !important;
  }
  
  h1 {
    font-size: 2rem !important;
  }
  
  h2 {
    font-size: 1.5rem !important;
  }
}

/* iOS Safari Specific */
@supports (-webkit-touch-callout: none) {
  /* Fix iOS Safari viewport issues */
  .min-h-screen {
    min-height: -webkit-fill-available;
  }
  
  /* Prevent zoom on input focus */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  .popup-content {
    animation: none;
  }
  
  .help-button {
    animation: none;
  }
  
  .popup-demo-notice::before {
    animation: none;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .popup-content {
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.95);
  }
  
  .popup-feature-item {
    border: 1px solid rgba(255, 255, 255, 0.3);
  }
}