# Dark Mode Implementation Guide ## Overview BeenVoice implements a **media query-based dark mode** system that automatically adapts to the user's system preferences. This approach provides a seamless experience without requiring manual theme switching controls. ## Implementation Approach ### Media Query-Based vs Class-Based We chose **media query-based** dark mode (`@media (prefers-color-scheme: dark)`) over class-based dark mode for the following reasons: - **Automatic System Integration**: Respects user's OS/browser theme preference - **No JavaScript Required**: Pure CSS solution with better performance - **Better Accessibility**: Follows system accessibility settings - **Seamless Experience**: No flash of incorrect theme on page load - **Reduced Complexity**: No need for theme toggle components or state management ## Configuration Changes ### 1. Tailwind CSS Configuration **File:** `tailwind.config.ts` ```typescript export default { darkMode: "media", // Changed from "class" to "media" // ... rest of config } satisfies Config; ``` ### 2. Global CSS Updates **File:** `src/styles/globals.css` Key changes made: - Replaced `.dark { }` class selector with `@media (prefers-color-scheme: dark) { :root { } }` - Maintained all existing CSS custom properties - Updated dark mode color definitions to use media queries ```css @media (prefers-color-scheme: dark) { :root { --background: oklch(0.145 0 0); --foreground: oklch(0.985 0 0); --card: oklch(0.205 0 0); /* ... all other dark mode variables */ } } ``` ## Component Updates ### Core Layout Components #### 1. Root Layout (`src/app/layout.tsx`) - Updated background gradients with dark mode variants - Improved layering structure for background effects - Added proper z-index management #### 2. Landing Page (`src/app/page.tsx`) - Comprehensive dark mode classes for all sections - Updated text colors, backgrounds, and hover states - Maintained brand consistency with green color scheme #### 3. Authentication Pages - **Sign In Page** (`src/app/auth/signin/page.tsx`) - **Register Page** (`src/app/auth/register/page.tsx`) Both pages updated with: - Dark background gradients - Card component dark backgrounds - Input field icon colors - Text color variations - Link hover states ### Navigation Components #### 1. Navbar (`src/components/Navbar.tsx`) - Glass morphism effect with dark background support - Button variant adaptations - Text color adjustments for user information #### 2. Sidebar (`src/components/Sidebar.tsx`) - Dark background with transparency - Navigation link states (active/hover) - Border color adaptations - Icon and text color updates #### 3. Mobile Sidebar (`src/components/SidebarTrigger.tsx`) - Sheet component dark styling - Navigation link consistency with desktop sidebar - Border and background adaptations ### Dashboard Components #### 1. Dashboard Page (`src/app/dashboard/page.tsx`) - Welcome text color adjustments - Maintained gradient text effects #### 2. Universal Table (`src/components/ui/universal-table.tsx`) - Comprehensive table styling updates - Header background and text colors - Cell content color adaptations - Status badge color schemes - Pagination control styling - Grid view card backgrounds ## Color System ### Text Colors - **Primary Text**: `text-gray-900 dark:text-white` - **Secondary Text**: `text-gray-700 dark:text-gray-300` - **Muted Text**: `text-gray-500 dark:text-gray-400` - **Icon Colors**: `text-gray-400 dark:text-gray-500` ### Background Colors - **Card Backgrounds**: `dark:bg-gray-800` - **Hover States**: `hover:bg-gray-100 dark:hover:bg-gray-800` - **Border Colors**: `border-gray-200 dark:border-gray-700` - **Glass Effects**: `bg-white/60 dark:bg-gray-900/60` ### Brand Colors Maintained consistent green brand colors with dark mode adaptations: - **Primary Green**: `text-green-600 dark:text-green-400` - **Emerald Accents**: `bg-emerald-100 dark:bg-emerald-900/30` ## Testing the Implementation ### Manual Testing 1. **System Theme Toggle**: - Change your OS dark/light mode setting - Verify automatic theme switching - Check for smooth transitions 2. **Page Coverage**: - Landing page - Authentication pages (sign in/register) - Dashboard and navigation - All table views and components 3. **Component Testing**: - Form elements (inputs, buttons, selects) - Cards and containers - Navigation states (hover, active) - Text readability in both modes ### Browser Developer Tools 1. **Media Query Testing**: ```css /* In DevTools Console */ document.documentElement.style.colorScheme = 'dark'; document.documentElement.style.colorScheme = 'light'; ``` 2. **Emulation**: - Chrome DevTools > Rendering > Emulate CSS prefers-color-scheme - Firefox DevTools > Settings > Dark theme simulation ### Test Component A comprehensive test component is available at `src/components/dark-mode-test.tsx` that displays: - Color variations - Button states - Form elements - Status indicators - Background patterns - Icon colors ## Best Practices for Future Development ### 1. Color Class Patterns Always pair light mode colors with dark mode variants: ```tsx // ✅ Good