/* 
 * DocFlow Connect - Enhanced Dark Mode
 * A comprehensive dark mode implementation that ensures all elements
 * look professional and maintain readability in dark mode
 */

/* Base dark mode setup with smooth transition */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
  }
  
  body.dark-mode {
    background-color: #111827; /* Rich dark background */
    color: #e5e7eb;
  }
  
  /* App container */
  body.dark-mode #app-container {
    background-color: #111827;
  }
  
  /* ===== TYPOGRAPHY ===== */
  
  body.dark-mode h1, 
  body.dark-mode h2, 
  body.dark-mode h3, 
  body.dark-mode h4, 
  body.dark-mode h5, 
  body.dark-mode h6 {
    color: #f9fafb;
  }
  
  body.dark-mode .text-gray-900 {
    color: #f9fafb !important;
  }
  
  body.dark-mode .text-gray-800 {
    color: #f1f5f9 !important;
  }
  
  body.dark-mode .text-gray-700 {
    color: #e5e7eb !important;
  }
  
  body.dark-mode .text-gray-600 {
    color: #d1d5db !important;
  }
  
  body.dark-mode .text-gray-500 {
    color: #9ca3af !important;
  }
  
  body.dark-mode .text-gray-400 {
    color: #6b7280 !important;
  }
  
  /* ===== BACKGROUNDS ===== */
  
  body.dark-mode .bg-white {
    background-color: #1f2937 !important;
  }
  
  body.dark-mode .bg-gray-50 {
    background-color: #1a1f2c !important;
  }
  
  body.dark-mode .bg-gray-100 {
    background-color: #242b38 !important;
  }
  
  body.dark-mode .bg-blue-100 {
    background-color: #1e3a8a !important;
  }
  
  body.dark-mode .bg-green-100 {
    background-color: #064e3b !important;
  }
  
  body.dark-mode .bg-red-100 {
    background-color: #7f1d1d !important;
  }
  
  body.dark-mode .bg-yellow-100 {
    background-color: #78350f !important;
  }
  
  body.dark-mode .bg-indigo-100 {
    background-color: #3730a3 !important;
  }
  
  /* ===== BORDERS ===== */
  
  body.dark-mode .border {
    border-color: #374151 !important;
  }
  
  body.dark-mode .border-gray-200 {
    border-color: #374151 !important;
  }
  
  body.dark-mode .border-gray-300 {
    border-color: #4b5563 !important;
  }
  
  body.dark-mode .border-blue-500 {
    border-color: #3b82f6 !important;
  }
  
  /* ===== HEADER AND NAVIGATION ===== */
  
  body.dark-mode #main-app > div:first-child {
    background-color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  }
  
  /* Tabs in dark mode */
  body.dark-mode .manual-tabs {
    background-color: #1f2937;
  }
  
  body.dark-mode .manual-tabs nav {
    border-bottom-color: #374151;
  }
  
  body.dark-mode .tab-button {
    color: #9ca3af;
  }
  
  body.dark-mode .tab-button:hover:not(.tab-active) {
    color: #d1d5db;
    border-bottom-color: #4b5563;
  }
  
  body.dark-mode .tab-button.tab-active, 
  body.dark-mode #tab-all-manuals.text-blue-600 {
    color: #60a5fa !important; /* Brighter blue in dark mode */
    border-bottom-color: #60a5fa !important;
  }
  
  /* ===== CARDS AND CONTAINERS ===== */
  
  /* Section containers */
  body.dark-mode .bg-white.shadow.overflow-hidden.sm\:rounded-lg.mb-6 {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
  
  /* Section headers */
  body.dark-mode .bg-white.shadow.overflow-hidden.sm\:rounded-lg.mb-6 .px-4.py-5.sm\:px-6 {
    background-color: #1f2937;
    border-bottom-color: #374151;
  }
  
  /* Project card */
  body.dark-mode .project-card {
    background-color: #1f2937;
    border-color: #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }
  
  body.dark-mode .project-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
  
  /* Manual card */
  body.dark-mode .manual-card {
    background-color: #1f2937;
    border-color: #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }
  
  body.dark-mode .manual-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
  
  /* Selected manual/project */
  body.dark-mode .project-selected,
  body.dark-mode .manual-selected {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 1px #3b82f6, 0 3px 6px rgba(59, 130, 246, 0.2) !important;
    background-color: #263045 !important;
  }
  
  /* Extracted pages styles */
  body.dark-mode #extracted-pages-container {
    background-color: #1f2937;
  }
  
  body.dark-mode #extracted-pages-numbers {
    background-color: #263045;
    border-top-color: #374151;
    border-bottom-color: #374151;
  }
  
  body.dark-mode .page-card {
    background-color: #1f2937;
    border-color: #374151;
  }
  
  body.dark-mode .page-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
  
  body.dark-mode .page-card-selected {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 1px #3b82f6, 0 3px 6px rgba(59, 130, 246, 0.2) !important;
  }
  
  body.dark-mode .page-card .bg-gray-100 {
    background-color: #263045 !important;
  }
  
  /* ===== FORM ELEMENTS ===== */
  
  body.dark-mode input[type="text"],
  body.dark-mode input[type="email"],
  body.dark-mode input[type="password"],
  body.dark-mode textarea {
    background-color: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
  }
  
  body.dark-mode input[type="text"]:focus,
  body.dark-mode input[type="email"]:focus,
  body.dark-mode input[type="password"]:focus,
  body.dark-mode textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  }
  
  body.dark-mode input[type="checkbox"] {
    border-color: #4b5563;
  }
  
  /* ===== BUTTONS AND INTERACTIVE ELEMENTS ===== */
  
  /* Primary button */
  body.dark-mode .bg-blue-600 {
    background-color: #2563eb !important;
  }
  
  body.dark-mode .bg-blue-600:hover {
    background-color: #1d4ed8 !important;
  }
  
  body.dark-mode .text-blue-600 {
    color: #60a5fa !important;
  }
  
  body.dark-mode .text-blue-800 {
    color: #3b82f6 !important;
  }
  
  /* Secondary button */
  body.dark-mode button.bg-gray-50,
  body.dark-mode button.bg-white {
    background-color: #374151 !important;
    border-color: #4b5563 !important;
    color: #e5e7eb !important;
  }
  
  body.dark-mode button.bg-gray-50:hover,
  body.dark-mode button.bg-white:hover {
    background-color: #4b5563 !important;
  }
  
  /* Button hover effects */
  body.dark-mode button:not(:disabled):hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
  
  /* ===== MODALS ===== */
  
  body.dark-mode .fixed.inset-0.z-50.overflow-y-auto {
    background-color: rgba(0, 0, 0, 0.7);
  }
  
  body.dark-mode .bg-gray-50.px-4.py-3.sm\:px-6.sm\:flex.sm\:flex-row-reverse {
    background-color: #263045 !important;
    border-top-color: #374151;
  }
  
  /* ===== STATUS BADGES ===== */
  
  /* Make badges more vibrant in dark mode */
  body.dark-mode .bg-blue-100.text-blue-800 {
    background-color: #1e40af !important;
    color: #bfdbfe !important;
  }
  
  body.dark-mode .bg-green-100.text-green-800 {
    background-color: #065f46 !important;
    color: #a7f3d0 !important;
  }
  
  body.dark-mode .bg-red-100.text-red-800 {
    background-color: #991b1b !important;
    color: #fecaca !important;
  }
  
  body.dark-mode .bg-yellow-100.text-yellow-800 {
    background-color: #92400e !important;
    color: #fef3c7 !important;
  }
  
  body.dark-mode .bg-indigo-100.text-indigo-800 {
    background-color: #4338ca !important;
    color: #c7d2fe !important;
  }
  
  body.dark-mode .bg-purple-100.text-purple-800 {
    background-color: #6d28d9 !important;
    color: #e9d5ff !important;
  }
  
  /* ===== PDF PREVIEW ===== */
  
  body.dark-mode #pdf-preview-modal .bg-white,
  body.dark-mode #markdown-preview-modal .bg-white,
  body.dark-mode #excel-preview-modal .bg-white {
    background-color: #1f2937 !important;
  }
  
  body.dark-mode #pdf-preview-iframe,
  body.dark-mode #excel-preview-iframe {
    background-color: #374151;
    border-radius: 0.375rem;
  }
  
  body.dark-mode #markdown-preview-content {
    color: #e5e7eb;
  }
  
  body.dark-mode .prose h1,
  body.dark-mode .prose h2,
  body.dark-mode .prose h3 {
    color: #f9fafb !important;
  }
  
  body.dark-mode .prose p {
    color: #e5e7eb !important;
  }
  
  /* ===== SCROLLBARS ===== */
  
  /* Webkit (Chrome, Safari, newer Edge) */
  body.dark-mode ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
  }
  
  body.dark-mode ::-webkit-scrollbar-track {
    background: #1f2937;
  }
  
  body.dark-mode ::-webkit-scrollbar-thumb {
    background-color: #4b5563;
    border-radius: 6px;
    border: 3px solid #1f2937;
  }
  
  body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background-color: #6b7280;
  }
  
  /* Firefox */
  body.dark-mode * {
    scrollbar-width: thin;
    scrollbar-color: #4b5563 #1f2937;
  }
  
  /* ===== NOTIFICATIONS ===== */
  
  body.dark-mode #notification.bg-blue-100 {
    background-color: #1e3a8a !important;
    border-color: #3b82f6 !important;
    color: #bfdbfe !important;
  }
  
  body.dark-mode #notification.bg-green-100 {
    background-color: #064e3b !important;
    border-color: #10b981 !important;
    color: #a7f3d0 !important;
  }
  
  body.dark-mode #notification.bg-red-100 {
    background-color: #7f1d1d !important;
    border-color: #ef4444 !important;
    color: #fecaca !important;
  }
  
  /* ===== EMPTY STATES ===== */
  
  body.dark-mode #no-manuals-message svg,
  body.dark-mode #no-projects-message svg,
  body.dark-mode #no-extracted-pages-message svg,
  body.dark-mode #no-excel-files-message svg {
    color: #4b5563 !important;
  }
  
  /* ===== EXCEL FILES SECTION ===== */
  
  body.dark-mode #excel-files-container {
    background-color: #1f2937;
  }
  
  body.dark-mode #master-excel-card {
    background-color: #263045 !important;
    border-color: #374151 !important;
  }
  
  body.dark-mode .excel-file-card {
    background-color: #1f2937;
    border-color: #374151;
  }
  
  /* ===== ICONS WITH DUAL COLORS ===== */
  
  /* Icon color adjustments */
  body.dark-mode svg:not([class*="text-"]) {
    color: #d1d5db;
  }
  
  /* ===== LOGIN SCREEN ===== */
  
  body.dark-mode #login-container {
    background-color: #111827;
  }
  
  body.dark-mode #login-container .bg-white {
    background-color: #1f2937 !important;
  }
  
  /* ===== SMOOTH TRANSITION ===== */
  
  /* Apply transitions to all elements for smooth mode switching */
  * {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease, 
                box-shadow 0.3s ease;
  }
  
  /* ===== DARK MODE TOGGLE ===== */
  
  .dark-mode-toggle {
    position: relative;
    width: 50px;
    height: 24px;
    margin-right: 10px;
  }
  
  .dark-mode-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
  }
  
  .dark-mode-toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
  }
  
  .dark-mode-toggle .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
  }
  
  .dark-mode-toggle input:checked + .slider {
    background-color: #3b82f6;
  }
  
  .dark-mode-toggle input:checked + .slider:before {
    transform: translateX(26px);
  }
  
  .dark-mode-toggle .sun-icon,
  .dark-mode-toggle .moon-icon {
    position: absolute;
    top: 5px;
    font-size: 14px;
    transition: opacity 0.3s ease;
  }
  
  .dark-mode-toggle .sun-icon {
    left: 3px;
    opacity: 1;
    color: #ff9d00;
    top: 2px;
  }
  
  .dark-mode-toggle .moon-icon {
    right: 6px;
    opacity: 0;
    color: #463f3f;
    top: 1px;
  }
  
  .dark-mode-toggle input:checked ~ .sun-icon {
    opacity: 0;
  }
  
  .dark-mode-toggle input:checked ~ .moon-icon {
    opacity: 1;
  }
  
  /* Special handling for white logos in dark mode */
  body.dark-mode img[src*="logo"] {
    filter: brightness(0) invert(1);
  }