/* Dark mode variables */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #475569;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  --accent-purple: #8b5cf6;
}

/* Base dark theme */
body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* Header */
header {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
}

/* Cards */
.bg-white {
  background-color: var(--bg-card) !important;
}

.shadow {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

/* Text colors */
.text-gray-900 {
  color: var(--text-primary) !important;
}

.text-gray-500 {
  color: var(--text-secondary) !important;
}

.text-gray-600 {
  color: var(--text-muted) !important;
}

.text-gray-700 {
  color: var(--text-secondary) !important;
}

/* Table styling */
.bg-gray-50 {
  background-color: var(--bg-secondary) !important;
}

.divide-gray-200 > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--border-color);
}

.border-gray-200 {
  border-color: var(--border-color) !important;
}

.border-gray-300 {
  border-color: var(--border-color) !important;
}

/* Hover effects */
.hover\:bg-gray-50:hover {
  background-color: var(--bg-secondary) !important;
}

/* Auth modal */
#auth-modal .bg-white {
  background-color: var(--bg-card) !important;
}

/* Form inputs */
input[type="password"] {
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

input[type="password"]:focus {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Buttons */
.bg-blue-600 {
  background-color: var(--accent-blue) !important;
}

.hover\:bg-blue-700:hover {
  background-color: #2563eb !important;
}

/* Status badges - keep original colors but adjust for dark mode */
.bg-blue-100 {
  background-color: rgba(59, 130, 246, 0.2) !important;
}

.text-blue-800 {
  color: #93c5fd !important;
}

.bg-green-100 {
  background-color: rgba(16, 185, 129, 0.2) !important;
}

.text-green-800 {
  color: #6ee7b7 !important;
}

.bg-red-100 {
  background-color: rgba(239, 68, 68, 0.2) !important;
}

.text-red-800 {
  color: #fca5a5 !important;
}

.bg-yellow-100 {
  background-color: rgba(245, 158, 11, 0.2) !important;
}

.text-yellow-800 {
  color: #fcd34d !important;
}

.bg-purple-100 {
  background-color: rgba(139, 92, 246, 0.2) !important;
}

.text-purple-800 {
  color: #c4b5fd !important;
}

.bg-orange-100 {
  background-color: rgba(249, 115, 22, 0.2) !important;
}

.text-orange-800 {
  color: #fdba74 !important;
}

.bg-indigo-100 {
  background-color: rgba(99, 102, 241, 0.2) !important;
}

.text-indigo-800 {
  color: #c7d2fe !important;
}

.bg-gray-100 {
  background-color: rgba(148, 163, 184, 0.2) !important;
}

.text-gray-800 {
  color: var(--text-secondary) !important;
}

/* Green section header */
.bg-green-50 {
  background-color: rgba(16, 185, 129, 0.1) !important;
}

/* Loading overlay */
#loading-overlay {
  background-color: rgba(0, 0, 0, 0.7) !important;
}

#loading-overlay .bg-white {
  background-color: var(--bg-card) !important;
}

/* Links */
.text-blue-600 {
  color: var(--accent-blue) !important;
}

.hover\:text-blue-900:hover {
  color: #93c5fd !important;
}

.text-red-600 {
  color: var(--accent-red) !important;
}

.hover\:text-red-800:hover {
  color: #fca5a5 !important;
}

/* Animations */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .5;
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

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

/* Custom scrollbar for tables */
.overflow-x-auto::-webkit-scrollbar {
    height: 8px;
}

.overflow-x-auto::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.overflow-x-auto::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.overflow-x-auto::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Loading states */
.loading-skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Enhanced Mobile Responsiveness */

/* Mobile-first approach */
@media (max-width: 640px) {
  /* Header adjustments */
  header .flex {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 0;
  }
  
  header h1 {
    font-size: 1.125rem;
  }
  
  /* Overview cards - stack vertically on mobile */
  .grid.grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-5 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Card content adjustments */
  .overflow-hidden.shadow.rounded-lg .p-5 {
    padding: 1rem;
  }
  
  /* Table responsiveness */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Table text sizing */
  .min-w-full td,
  .min-w-full th {
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
  }
  
  /* Hide less important columns on mobile */
  .mobile-hide {
    display: none;
  }
  
  /* Auth modal adjustments */
  #auth-modal .max-w-md {
    max-width: 90vw;
    margin: 1rem;
  }
  
  /* Button adjustments */
  .px-6.py-3 {
    padding: 0.5rem 1rem;
  }
  
  /* Section headers */
  .px-4.py-5.sm\:px-6 {
    padding: 1rem;
  }
  
  .px-4.py-5.sm\:px-6 h3 {
    font-size: 1.125rem;
  }
  
  .px-4.py-5.sm\:px-6 p {
    font-size: 0.875rem;
    margin-top: 0.25rem;
  }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
  /* Overview cards - 2 columns on tablet */
  .grid.grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-5 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Table adjustments */
  .min-w-full td,
  .min-w-full th {
    padding: 0.75rem;
    font-size: 0.875rem;
  }
}

/* Large tablet/small desktop */
@media (min-width: 1025px) and (max-width: 1280px) {
  /* Overview cards - 3 columns */
  .grid.grid-cols-1.sm\:grid-cols-2.lg\:grid-cols-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  button,
  a {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Better button spacing */
  .space-x-4 > :not([hidden]) ~ :not([hidden]) {
    margin-left: 1rem;
  }
  
  /* Improved table row touch targets */
  tbody tr {
    min-height: 60px;
  }
}

/* Landscape phone adjustments */
@media (max-width: 896px) and (orientation: landscape) {
  /* Reduce header height in landscape */
  header .h-16 {
    height: 3rem;
  }
  
  /* Adjust card padding */
  .p-5 {
    padding: 0.75rem;
  }
  
  /* Smaller text in landscape */
  .text-lg {
    font-size: 1rem;
  }
}

/* Very small screens */
@media (max-width: 375px) {
  /* Further reduce padding */
  .max-w-7xl.mx-auto.px-4 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  /* Smaller card icons */
  .text-2xl {
    font-size: 1.5rem;
  }
  
  /* Compact table cells */
  .px-6.py-4 {
    padding: 0.5rem 0.25rem;
  }
}

/* Print styles */
@media print {
  /* Hide interactive elements */
  button,
  #auth-modal,
  #loading-overlay {
    display: none !important;
  }
  
  /* Optimize for print */
  body {
    background: white !important;
    color: black !important;
  }
  
  .bg-white,
  .bg-gray-50 {
    background: white !important;
  }
  
  /* Ensure tables fit */
  .overflow-x-auto {
    overflow: visible !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #ffffff;
    --text-secondary: #ffffff;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .animate-pulse,
  .animate-spin,
  .loading-skeleton {
    animation: none;
  }
}
/* Message Modal Dark Mode Styles */
#message-modal .bg-white {
  background-color: var(--bg-card) !important;
}

#message-modal .bg-gray-50 {
  background-color: var(--bg-secondary) !important;
}

#message-modal .border-gray-200 {
  border-color: var(--border-color) !important;
}

#message-modal .text-gray-900 {
  color: var(--text-primary) !important;
}

#message-modal .text-gray-500 {
  color: var(--text-secondary) !important;
}

#message-modal .text-gray-400 {
  color: var(--text-muted) !important;
}

#message-modal .hover\:text-gray-600:hover {
  color: var(--text-secondary) !important;
}

/* Message bubbles */
.bg-blue-100.border-l-4.border-blue-500 {
  background-color: rgba(59, 130, 246, 0.1) !important;
  border-left-color: var(--accent-blue) !important;
}

.bg-green-100.border-l-4.border-green-500 {
  background-color: rgba(16, 185, 129, 0.1) !important;
  border-left-color: var(--accent-green) !important;
}

.bg-gray-100.border-l-4.border-gray-500 {
  background-color: rgba(148, 163, 184, 0.1) !important;
  border-left-color: var(--border-color) !important;
}

/* Message text colors */
.text-blue-700 {
  color: #93c5fd !important;
}

.text-green-700 {
  color: #6ee7b7 !important;
}

.text-gray-700 {
  color: var(--text-secondary) !important;
}

.text-gray-800 {
  color: var(--text-primary) !important;
}

/* Modal close button */
.bg-gray-600 {
  background-color: var(--bg-secondary) !important;
}

.hover\:bg-gray-700:hover {
  background-color: var(--border-color) !important;
}
/* Fix Modal Scrolling */
#message-modal {
  padding: 1rem;
}

#message-modal .bg-white {
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

/* Ensure scrollbar is always visible */
#message-modal .overflow-y-auto {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-secondary);
}

#message-modal .overflow-y-auto::-webkit-scrollbar {
  width: 8px;
}

#message-modal .overflow-y-auto::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

#message-modal .overflow-y-auto::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

#message-modal .overflow-y-auto::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Better message spacing */
#message-history {
  padding-bottom: 2rem;
}

/* Responsive modal */
@media (max-width: 768px) {
  #message-modal {
    padding: 0.5rem;
  }
  
  #message-modal .bg-white {
    height: 90vh;
    max-height: 90vh;
  }
  
  #message-modal .px-6 {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Ensure close button is always accessible */
#message-modal button[onclick="dashboard.closeMessageModal()"] {
  min-height: 44px;
  min-width: 44px;
}
/* Agent and Response styling */
.fas.fa-check-circle {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.fas.fa-circle {
    opacity: 0.5;
}

/* Tooltip for checkmarks */
[title] {
    position: relative;
    cursor: help;
}

/* Agent badge dark mode adjustments */
.bg-cyan-100 {
    background-color: rgba(6, 182, 212, 0.2) !important;
}

.text-cyan-700 {
    color: #67e8f9 !important;
}
