/* =====================================================================
   IRRIVISION.IO THEME SYSTEM
   CSS Custom Properties for Light/Dark Mode Support
   ===================================================================== */

:root {
    /* Light Mode Colors (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #e5e7eb;
    --bg-active: #d1d5db;
    
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --text-muted: #9ca3af;
    --text-inverse: #ffffff;
    
    --border-primary: #e5e7eb;
    --border-secondary: #d1d5db;
    --border-focus: #3b82f6;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Status Colors */
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --error: #ef4444;
    --error-bg: #fee2e2;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    
    /* Brand Colors */
    --brand-primary: #3b82f6;
    --brand-secondary: #06b6d4;
    --brand-accent: #10b981;
    
    /* Input/Form Colors */
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-text: #111827;
    --input-placeholder: #9ca3af;
    --input-focus-ring: rgba(59, 130, 246, 0.2);
    
    /* Card/Panel Colors */
    --card-bg: #ffffff;
    --card-border: #e5e7eb;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    
    /* Header Colors */
    --header-bg: #ffffff;
    --header-border: #e5e7eb;
    --header-text: #111827;
    
    /* Sidebar Colors (for modules like IrriView that use dark sidebar) */
    --sidebar-bg: #1f2937;
    --sidebar-text: #f9fafb;
    --sidebar-text-muted: #9ca3af;
    --sidebar-hover: #374151;
    --sidebar-active: #06b6d4;
    
    /* Module Card Colors */
    --module-card-text: #ffffff;
    
    /* Table Colors */
    --table-header-bg: #f9fafb;
    --table-row-even: #ffffff;
    --table-row-odd: #f9fafb;
    --table-row-hover: #f3f4f6;
    --table-border: #e5e7eb;
}

/* Dark Mode Variables */
[data-theme="dark"],
.dark-mode {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --bg-hover: #4b5563;
    --bg-active: #6b7280;
    
    --text-primary: #f9fafb;
    --text-secondary: #e5e7eb;
    --text-tertiary: #9ca3af;
    --text-muted: #6b7280;
    --text-inverse: #111827;
    
    --border-primary: #374151;
    --border-secondary: #4b5563;
    --border-focus: #60a5fa;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    
    /* Status Colors (adjusted for dark mode) */
    --success-bg: rgba(16, 185, 129, 0.2);
    --warning-bg: rgba(245, 158, 11, 0.2);
    --error-bg: rgba(239, 68, 68, 0.2);
    --info-bg: rgba(59, 130, 246, 0.2);
    
    /* Input/Form Colors */
    --input-bg: #1f2937;
    --input-border: #4b5563;
    --input-text: #f9fafb;
    --input-placeholder: #6b7280;
    --input-focus-ring: rgba(96, 165, 250, 0.3);
    
    /* Card/Panel Colors */
    --card-bg: #1f2937;
    --card-border: #374151;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    
    /* Header Colors */
    --header-bg: #1f2937;
    --header-border: #374151;
    --header-text: #f9fafb;
    
    /* Table Colors */
    --table-header-bg: #374151;
    --table-row-even: #1f2937;
    --table-row-odd: #111827;
    --table-row-hover: #374151;
    --table-border: #374151;
}

/* Apply theme variables to common elements */
body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Override Tailwind classes with CSS variables for theme support */
.bg-white {
    background-color: var(--bg-primary) !important;
}

.bg-gray-100 {
    background-color: var(--bg-secondary) !important;
}

.bg-gray-50 {
    background-color: var(--bg-tertiary) !important;
}

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

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

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

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

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

/* Theme-aware header */
header {
    background-color: var(--header-bg) !important;
    border-color: var(--header-border) !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Theme-aware cards (NOT module cards - they maintain their colored backgrounds) */
.card,
.bg-white.rounded-lg,
.bg-white.shadow {
    background-color: var(--card-bg) !important;
    border-color: var(--card-border) !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Theme-aware inputs */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder) !important;
}

/* Theme-aware tables */
.data-table th {
    background-color: var(--table-header-bg);
    color: var(--text-secondary);
}

.data-table td {
    background-color: var(--table-row-even);
    color: var(--text-primary);
    border-color: var(--table-border);
}

.data-table tr:nth-child(odd) td {
    background-color: var(--table-row-odd);
}

.data-table tr:hover td {
    background-color: var(--table-row-hover);
}

/* Theme Toggle Button Styles */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-hover);
}

.theme-toggle-icon {
    font-size: 1rem;
    color: var(--text-secondary);
}

.theme-toggle-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Theme Selector (dropdown style) */
.theme-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-option:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-secondary);
}

.theme-option.active {
    background-color: var(--info-bg);
    border-color: var(--brand-primary);
}

.theme-option-icon {
    font-size: 1.25rem;
    width: 2rem;
    text-align: center;
}

.theme-option-label {
    font-weight: 500;
    color: var(--text-primary);
}

.theme-option-description {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* =====================================================================
   MODULE CARD THEME SYSTEM
   Cards should keep their colored backgrounds but text adapts to ensure visibility
   ===================================================================== */

/* Module cards - maintain colorful backgrounds in all themes */
/* DO NOT set background-color here - let Tailwind color classes apply */
.module-card {
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.module-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

/* Light mode: Module cards need darker colored backgrounds for contrast */
:root .module-card {
    /* Module cards keep their colored backgrounds */
}

/* Module card text - always white on colored backgrounds */
.module-card-content {
    color: #ffffff !important;
}

.module-card-content .module-icon,
.module-card-content .module-title,
.module-card-content .module-subtitle {
    color: #ffffff !important;
}

/* Explicitly set module card colors to override any theme interference */
.module-card.bg-blue-600 { background-color: #2563eb !important; }
.module-card.bg-blue-500 { background-color: #3b82f6 !important; }
.module-card.bg-blue-400 { background-color: #60a5fa !important; }
.module-card.bg-cyan-500 { background-color: #06b6d4 !important; }
.module-card.bg-teal-500 { background-color: #14b8a6 !important; }
.module-card.bg-orange-500 { background-color: #f97316 !important; }
.module-card.bg-green-500 { background-color: #22c55e !important; }
.module-card.bg-green-600 { background-color: #16a34a !important; }
.module-card.bg-green-400 { background-color: #4ade80 !important; }
.module-card.bg-purple-500 { background-color: #a855f7 !important; }
.module-card.bg-yellow-500 { background-color: #eab308 !important; }
.module-card.bg-red-500 { background-color: #ef4444 !important; }
.module-card.bg-amber-600 { background-color: #d97706 !important; }
.module-card.bg-emerald-500 { background-color: #10b981 !important; }
.module-card.bg-gray-800 { background-color: #1f2937 !important; }
.module-card.bg-indigo-500 { background-color: #6366f1 !important; }
.module-card.bg-violet-500 { background-color: #8b5cf6 !important; }
.module-card.bg-sky-500 { background-color: #0ea5e9 !important; }
.module-card.bg-sky-600 { background-color: #0284c7 !important; }
.module-card.bg-purple-600 { background-color: #8e44ad !important; }
.module-card.bg-orange-600 { background-color: #ea580c !important; }
.module-card.bg-cyan-600 { background-color: #0891b2 !important; }

/* Ensure text visibility on colored module cards */
.module-card .text-white {
    color: #ffffff !important;
}

/* =====================================================================
   DROPDOWN AND POPUP THEME SUPPORT
   ===================================================================== */

/* Dropdowns should follow theme */
.dropdown-menu,
#userDropdown,
#companyDropdown {
    background-color: var(--card-bg) !important;
    border-color: var(--border-primary) !important;
    box-shadow: var(--shadow-lg);
}

.dropdown-item {
    color: var(--text-primary) !important;
    background-color: transparent !important;
}

.dropdown-item:hover {
    background-color: var(--bg-hover) !important;
}

.dropdown-item.active {
    background-color: var(--info-bg) !important;
    border-left: 2px solid var(--brand-primary) !important;
}

/* Dropdown headers/dividers */
.dropdown-header,
#userDropdown .text-xs.text-gray-500,
#companyDropdown .text-xs.text-gray-500 {
    color: var(--text-muted) !important;
    border-color: var(--border-primary) !important;
}

/* =====================================================================
   STATUS BAR THEME SUPPORT
   ===================================================================== */

.status-bar,
.bg-white.rounded-lg.shadow {
    background-color: var(--card-bg) !important;
    border-color: var(--card-border) !important;
    color: var(--text-primary);
}

.status-bar .text-gray-600,
.status-bar .text-gray-500 {
    color: var(--text-tertiary) !important;
}

/* =====================================================================
   IRRIVIEW MODULE THEME SUPPORT
   Dark mode is native to IrriView, light mode needs CSS variable overrides
   ===================================================================== */

/* IrriView uses its own dark aesthetic by default */
/* These variables allow IrriView to adapt when in light mode context */
:root {
    /* IrriView specific colors - default dark aesthetic */
    --iv-bg-primary: #111827;
    --iv-bg-secondary: #1f2937;
    --iv-bg-tertiary: #374151;
    --iv-text-primary: #ffffff;
    --iv-text-secondary: #e5e7eb;
    --iv-text-muted: #9ca3af;
    --iv-border: #374151;
    --iv-accent: #06b6d4;
}

/* IrriView always maintains its dark theme regardless of global theme */
/* This is intentional - data visualization dashboards work better dark */

/* =====================================================================
   END THEME SYSTEM
   ===================================================================== */

/* Navigation Logo Styling */
.logo-container {
    display: flex;
    align-items: center;
    margin-right: 1rem;
}

.logo-image {
    height: 32px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

/* Header Enhancement */
header {
    background-color: var(--header-bg) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Module Cards Enhancement */
.module-card {
    transition: transform 0.2s ease-in-out;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.table-container {
    overflow-x: auto;
}

.data-table {
    min-width: 100%;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}

/* Dynamic column sizing for Systems table */
.data-table.systems-table {
    position: relative;
    table-layout: auto !important; /* Allow automatic column sizing */
    width: 100%;
}

.data-table.systems-table th,
.data-table.systems-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dynamic column widths - let browser calculate optimal sizes */
.data-table.systems-table th:nth-child(1), 
.data-table.systems-table td:nth-child(1) {
    width: auto;
    min-width: 200px; /* Minimum for system names */
    max-width: 50%; /* Don't take up too much space */
}

.data-table.systems-table th:nth-child(2), 
.data-table.systems-table td:nth-child(2) {
    width: auto;
    min-width: 100px;
}

.data-table.systems-table th:nth-child(3), 
.data-table.systems-table td:nth-child(3) {
    width: auto;
    min-width: 120px;
}

.data-table.systems-table th:nth-child(4), 
.data-table.systems-table td:nth-child(4) {
    width: auto;
    min-width: 160px !important; /* More space for actions */
    text-align: center !important;
}

/* Override base actions column styling for systems table */
.data-table.systems-table td.actions {
    width: auto !important;
    min-width: 160px !important;
    max-width: none !important;
    white-space: nowrap !important;
}

/* Extra specific override for System Name column - allow wrapping if needed */
.data-table.systems-table th:first-child,
.data-table.systems-table td:first-child {
    white-space: normal !important; /* Allow text wrapping for very long names */
    word-wrap: break-word;
    hyphens: auto;
}

/* Hover tooltip for truncated text */
.data-table.systems-table td[title]:hover::after {
    content: attr(title);
    position: absolute;
    background: #374151;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    opacity: 0;
    animation: tooltip-fade-in 0.3s ease-in-out 0.5s forwards;
    pointer-events: none;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--table-border);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    color: var(--text-primary);
}

.data-table td.actions {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
    padding: 8px 12px;
    text-align: center;
    white-space: nowrap;
}

.data-table th:last-child,
.data-table td:last-child {
    text-align: center;
}

.data-table th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    color: var(--text-secondary);
}

.data-table tr:hover {
    background-color: var(--table-row-hover);
}

.data-table tbody tr:nth-child(even) {
    background-color: var(--table-row-even);
}

.data-table tbody tr:nth-child(odd) {
    background-color: var(--table-row-odd);
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--brand-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.json-view {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-primary);
}

/* Account/Company Dropdown Styles */
.dropdown-item {
    transition: all 0.15s ease-in-out;
    color: var(--text-primary);
}

.dropdown-item:hover {
    background-color: var(--bg-hover);
}

.dropdown-item.active {
    background-color: var(--info-bg);
    border-left: 2px solid var(--brand-primary);
}

.dropdown-container {
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-container::-webkit-scrollbar {
    width: 4px;
}

.dropdown-container::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.dropdown-container::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

.dropdown-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Account buttons - theme aware */
.account-button {
    transition: all 0.15s ease-in-out;
    background-color: var(--bg-primary) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-primary) !important;
}

.account-button:hover {
    background-color: var(--bg-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Accounts Module Styles */
.accounts-module {
    max-width: 100%;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    border: 1px solid #d1d5db;
    background-color: #f9fafb;
    color: #6b7280;
    font-weight: 500;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.tab-button:hover {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
}

.tab-button.active {
    background-color: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

/* Admin tabs - theme aware */
.admin-tab {
    color: var(--text-muted);
    border-color: transparent;
}

.admin-tab:hover {
    color: var(--text-secondary);
    border-color: var(--border-secondary);
}

.admin-tab.active {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* Navigation tabs border */
nav.border-b {
    border-color: var(--border-primary) !important;
}

.account-tab {
    display: none;
}

.account-tab.active {
    display: block;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background-color: #3b82f6 !important;
    color: white !important;
    border: 1px solid #3b82f6 !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background-color: #1d4ed8 !important;
    border-color: #1d4ed8 !important;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-success {
    background-color: #16a34a !important;
    color: white !important;
    border: 1px solid #16a34a !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-success:hover {
    background-color: #15803d !important;
    border-color: #15803d !important;
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: inline-block;
    vertical-align: middle;
    width: 2rem;
    height: 2rem;
    line-height: 1;
    text-align: center;
}

.btn-edit {
    background-color: #10b981;
    color: white;
}

.btn-edit:hover {
    background-color: #059669;
}

.btn-delete {
    background-color: #ef4444;
    color: white;
}

.btn-delete:hover {
    background-color: #dc2626;
}

.btn-icon-danger {
    background-color: #fecaca;
    color: #dc2626;
}

.btn-icon-danger:hover {
    background-color: #fca5a5;
}

.btn-icon-success {
    background-color: #dcfce7;
    color: #16a34a;
}

.btn-icon-success:hover {
    background-color: #bbf7d0;
}

.btn-icon-info {
    background-color: #dbeafe;
    color: #2563eb;
}

.btn-icon-info:hover {
    background-color: #bfdbfe;
}

.btn-icon-primary {
    background-color: #e0e7ff;
    color: #3730a3;
}

.btn-icon-primary:hover {
    background-color: #c7d2fe;
}

.btn-icon-warning {
    background-color: #fef3c7;
    color: #d97706;
}

.btn-icon-warning:hover {
    background-color: #fde68a;
}

.btn-icon-secondary {
    background-color: #f1f5f9;
    color: #475569;
}

.btn-icon-secondary:hover {
    background-color: #e2e8f0;
}

.btn-icon-disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-icon-disabled:hover {
    background-color: #f3f4f6;
    color: #9ca3af;
}

.actions {
    display: inline-block;
    text-align: center;
    white-space: nowrap;
    min-width: 100px;
}

.actions .btn-icon {
    display: inline-block;
    margin: 0 2px;
    vertical-align: middle;
}

.form-container {
    max-width: 100%;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: border-color 0.15s ease-in-out;
    background-color: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.form-select[multiple] {
    height: auto;
    min-height: 6rem;
}

.form-select option {
    padding: 0.5rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-lg {
    max-width: 900px;
    width: 95%;
}

/* Full screen modal styles */
.modal-fullscreen {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
}

.modal-fullscreen .modal-content.modal-fullscreen-content {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen .modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen .modal-body .map-controls {
    flex-shrink: 0;
}

.modal-fullscreen .modal-body #geofenceMap {
    flex: 1;
    height: auto !important;
    min-height: 0;
}

.modal-fullscreen .modal-header {
    flex-shrink: 0;
}

.modal-fullscreen .modal-footer {
    flex-shrink: 0;
}

/* Ensure normal modal map has proper height */
.modal:not(.modal-fullscreen) #geofenceMap {
    height: 500px !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    flex: 1;
}

/* Modal header button styles */
.modal-header-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    min-width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-header-buttons .btn-outline-primary {
    color: #3b82f6;
    border: 1px solid #3b82f6;
    background: transparent;
}

.modal-header-buttons .btn-outline-primary:hover {
    background: #3b82f6;
    color: white;
}

.modal-header-buttons .btn-outline-secondary {
    color: #6b7280;
    border: 1px solid #6b7280;
    background: transparent;
}

.modal-header-buttons .btn-outline-secondary:hover {
    background: #6b7280;
    color: white;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #374151;
    background-color: #f3f4f6;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e5e5;
    background-color: #f9fafb;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.form-label.required::after {
    content: ' *';
    color: #dc2626;
}

.form-input {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-input:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.form-select {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.25rem 2rem 0.25rem 0.75rem;
    background-color: white;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    appearance: none;
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-lg {
    max-width: 900px;
    width: 95%;
}

/* Full screen modal styles */
.modal-fullscreen {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
}

.modal-fullscreen .modal-content.modal-fullscreen-content {
    max-width: 100vw;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen .modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen .modal-body .map-controls {
    flex-shrink: 0;
}

.modal-fullscreen .modal-body #geofenceMap {
    flex: 1;
    height: auto !important;
    min-height: 0;
}

.modal-fullscreen .modal-header {
    flex-shrink: 0;
}

.modal-fullscreen .modal-footer {
    flex-shrink: 0;
}

/* Ensure normal modal map has proper height */
.modal:not(.modal-fullscreen) #geofenceMap {
    height: 500px !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    flex: 1;
}

/* Modal header button styles */
.modal-header-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    min-width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-header-buttons .btn-outline-primary {
    color: #3b82f6;
    border: 1px solid #3b82f6;
    background: transparent;
}

.modal-header-buttons .btn-outline-primary:hover {
    background: #3b82f6;
    color: white;
}

.modal-header-buttons .btn-outline-secondary {
    color: #6b7280;
    border: 1px solid #6b7280;
    background: transparent;
}

.modal-header-buttons .btn-outline-secondary:hover {
    background: #6b7280;
    color: white;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #374151;
    background-color: #f3f4f6;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid #e5e5e5;
    background-color: #f9fafb;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.form-label.required::after {
    content: ' *';
    color: #dc2626;
}

.form-input {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-input:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.form-select {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.25rem 2rem 0.25rem 0.75rem;
    background-color: white;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    appearance: none;
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Administration Module Styles */
.admin-tab {
    transition: all 0.2s ease-in-out;
}

.admin-tab:hover {
    color: #374151 !important;
    border-color: #d1d5db !important;
}

.admin-tab.active {
    color: #2563eb !important;
    border-color: #2563eb !important;
}

.admin-section {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Modal backdrop */
.modal-backdrop {
    backdrop-filter: blur(4px);
}

/* Table hover effects */
.admin-section table tbody tr:hover {
    background-color: #f9fafb;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.status-badge.active {
    background-color: #dcfce7;
    color: #16a34a;
}

.status-badge.inactive {
    background-color: #fef2f2;
    color: #dc2626;
}

/* Action buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: all 0.15s ease-in-out;
}

.action-btn:hover {
    background-color: #f3f4f6;
}

.action-btn.danger:hover {
    background-color: #fef2f2;
    color: #dc2626;
}

.action-btn.primary:hover {
    background-color: #eff6ff;
    color: #2563eb;
}

/* Restricted module indicator */
.restricted-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background-color: #fef2f2;
    color: #dc2626;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.restricted-indicator i {
    margin-right: 0.25rem;
}

/* JSON editor styling */
.json-editor {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.75rem;
    resize: vertical;
}

.json-editor:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    background-color: #ffffff;
}

/* Responsive table */
@media (max-width: 768px) {
    .admin-section table {
        font-size: 0.875rem;
    }
    
    .admin-section table th,
    .admin-section table td {
        padding: 0.5rem 0.25rem;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .accounts-module .grid {
        grid-template-columns: 1fr;
    }
    
    .tab-button {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .data-table {
        font-size: 0.875rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
        vertical-align: middle;
    }
    
    .form-container {
        padding: 1rem 0;
    }
}

/* Form validation styles */
.form-input:invalid,
.form-select:invalid {
    border-color: #ef4444;
}

.form-input:valid,
.form-select:valid {
    border-color: #10b981;
}

/* Loading and success states */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-loading {
    position: relative;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Success/Error messages */
.alert {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
}

.alert-success {
    color: #065f46;
    background-color: #d1fae5;
    border-color: #a7f3d0;
}

.alert-error {
    color: #991b1b;
    background-color: #fee2e2;
    border-color: #fecaca;
}

/* Improved table actions */
.actions .btn-icon {
    margin: 0 2px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.actions .btn-icon:first-child {
    margin-left: 0;
}

.actions .btn-icon:last-child {
    margin-right: 0;
}

/* Better dropdown styling */
.form-select[multiple] option:checked {
    background-color: #3b82f6;
    color: white;
}

/* Improved focus states */
.tab-button:focus,
.btn:focus,
.btn-icon:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Small button styles */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

/* Map Controls Styles */
.map-controls {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid #e5e7eb;
}

.map-controls select {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.25rem 0.5rem;
    background-color: white;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.map-controls select:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Ensure map container takes full space */
#geofenceMap {
    border-radius: 0 0 0.5rem 0.5rem;
}

/* Fix: Leaflet map z-index isolation — prevent map layers (tile/marker/popup panes
   use z-index 200-700) from bleeding through modals and other overlay UI.
   isolation:isolate creates a new stacking context scoped to the map container. */
#svc-detail-map,
#svc-ticket-map,
#geofenceMap,
.leaflet-container {
    isolation: isolate;
}

/* Style the leaflet attribution */
.leaflet-control-attribution {
    font-size: 11px !important;
    background: rgba(255, 255, 255, 0.8) !important;
}

/* Utility classes for spacing */
.me-2 {
    margin-right: 0.5rem;
}

/* Base button styles if not already defined */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.btn:hover {
    text-decoration: none;
}

.btn:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Systems display controls */
.form-select {
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    padding: 0.25rem 2rem 0.25rem 0.75rem;
    background-color: white;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    appearance: none;
}

.form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Table header controls styling */
.bg-gray-50 {
    background-color: #f9fafb;
}

/* System Map fullscreen styles */
.modal-fullscreen .modal-body #systemMap {
    flex: 1;
    height: auto !important;
    min-height: 0;
}

.modal:not(.modal-fullscreen) #systemMap {
    height: 600px !important;
}

/* Expandable Description Styling */
.role-description-cell {
    max-width: 250px;
    word-wrap: break-word;
    white-space: normal;
}

.description-toggle-btn {
    transition: color 0.2s ease-in-out;
    text-decoration: none;
    border: none;
    background: none;
    padding: 0;
    margin: 0;
}

.description-toggle-btn:hover {
    text-decoration: underline;
}

.description-toggle-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Table column width optimization for roles table */
#rolesTableBody tr td:nth-child(2) {
    max-width: 250px;
    min-width: 150px;
    width: 250px;
}

/* ============================================
   THEME-AWARE FORM ELEMENTS
   These override hardcoded colors with CSS variables
   ============================================ */

/* Form inputs - theme aware */
.form-input,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--input-text) !important;
}

.form-input:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
    background-color: var(--input-bg) !important;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 2px var(--input-focus-ring) !important;
}

.form-input::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--input-placeholder) !important;
}

/* Select dropdown arrow - theme aware */
.form-select,
select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 0.5rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.5em 1.5em !important;
    padding-right: 2.5rem !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

[data-theme="dark"] .form-select,
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 0.5rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.5em 1.5em !important;
}

/* Select option elements for dark mode */
[data-theme="dark"] select option {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
}

/* Disabled form inputs */
.form-input:disabled,
.form-select:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ============================================
   THEME-AWARE UTILITY OVERRIDES
   Override Tailwind hardcoded backgrounds/text colors
   ============================================ */

/* Background colors - override Tailwind grays */
[data-theme="dark"] .bg-gray-50 {
    background-color: #1e293b !important;
}

[data-theme="dark"] .bg-gray-100 {
    background-color: #1e293b !important;
}

[data-theme="dark"] .bg-gray-200 {
    background-color: #334155 !important;
}

[data-theme="dark"] .bg-white {
    background-color: var(--bg-secondary) !important;
}

/* Text colors - override Tailwind grays */
[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-900 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-600 {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-gray-400 {
    color: var(--text-muted) !important;
}

/* Border colors */
[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300 {
    border-color: var(--border-primary) !important;
}

/* Filter container backgrounds */
[data-theme="dark"] .filter-section,
[data-theme="dark"] .filters-container,
[data-theme="dark"] .p-4.bg-gray-50,
[data-theme="dark"] .p-6.bg-gray-50 {
    background-color: #1e293b !important;
    border-color: var(--border-primary) !important;
}

/* Table styling for dark mode */
[data-theme="dark"] table tbody tr:hover {
    background-color: var(--bg-hover) !important;
}

[data-theme="dark"] table th {
    background-color: var(--table-header-bg) !important;
    color: var(--text-secondary) !important;
}

[data-theme="dark"] table td {
    border-color: var(--table-border) !important;
}

/* Ensure hover states work in dark mode */
[data-theme="dark"] .hover\:bg-gray-50:hover {
    background-color: var(--bg-hover) !important;
}

[data-theme="dark"] .hover\:bg-gray-100:hover {
    background-color: var(--bg-hover) !important;
}

/* Modal backgrounds */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-body {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--border-primary) !important;
}

/* Card and panel backgrounds */
[data-theme="dark"] .card,
[data-theme="dark"] .panel,
[data-theme="dark"] .rounded-lg.bg-white,
[data-theme="dark"] .shadow.bg-white {
    background-color: var(--card-bg) !important;
    border-color: var(--card-border) !important;
}

/* Dropdown menus */
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] [role="menu"] {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-primary) !important;
}

[data-theme="dark"] .dropdown-item,
[data-theme="dark"] [role="menuitem"] {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] [role="menuitem"]:hover {
    background-color: var(--bg-hover) !important;
}

/* Label styling */
[data-theme="dark"] label {
    color: var(--text-secondary) !important;
}

/* Headings in dark mode */
[data-theme="dark"] h1, 
[data-theme="dark"] h2, 
[data-theme="dark"] h3, 
[data-theme="dark"] h4, 
[data-theme="dark"] h5, 
[data-theme="dark"] h6 {
    color: var(--text-primary) !important;
}

/* Paragraph and span text */
[data-theme="dark"] p,
[data-theme="dark"] span:not(.badge):not([class*="bg-"]):not([class*="text-"]) {
    color: var(--text-primary);
}

/* Links in dark mode */
[data-theme="dark"] a:not(.btn):not([class*="bg-"]):not([class*="text-blue"]):not([class*="text-green"]):not([class*="text-red"]) {
    color: var(--accent-primary);
}

/* Dividers */
[data-theme="dark"] hr,
[data-theme="dark"] .divider {
    border-color: var(--border-primary) !important;
}

/* Code blocks */
[data-theme="dark"] code,
[data-theme="dark"] pre {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}

/* Scrollbar styling for dark mode */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #1e293b;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Tailwind placeholder color overrides */
[data-theme="dark"] .placeholder-gray-500::placeholder {
    color: #9ca3af !important;
}

[data-theme="dark"] input.placeholder-gray-500::placeholder,
[data-theme="dark"] textarea.placeholder-gray-500::placeholder {
    color: #9ca3af !important;
}

/* Focus ring offset color for dark mode */
[data-theme="dark"] .focus\:ring-offset-2:focus {
    --tw-ring-offset-color: var(--bg-secondary);
}

/* Additional background overrides for semi-transparent backgrounds */
[data-theme="dark"] .bg-opacity-50,
[data-theme="dark"] .bg-black\/50 {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

/* Ensure all remaining gray backgrounds in dark mode are properly styled */
[data-theme="dark"] [class*="bg-gray-"]:not(.bg-gray-600):not(.bg-gray-700):not(.bg-gray-800):not(.bg-gray-900) {
    background-color: var(--bg-tertiary) !important;
}

/* Override remaining gray text colors */
[data-theme="dark"] [class*="text-gray-"]:not(.text-gray-100):not(.text-gray-200):not(.text-gray-300) {
    color: var(--text-secondary) !important;
}

/* Hover state overrides for dark mode */
[data-theme="dark"] .hover\:text-gray-700:hover {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .hover\:border-gray-300:hover {
    border-color: var(--border-primary) !important;
}

/* Admin tab styling for dark mode */
[data-theme="dark"] .admin-tab,
[data-theme="dark"] .account-sub-tab,
[data-theme="dark"] .automation-sub-tab {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .admin-tab:hover,
[data-theme="dark"] .account-sub-tab:hover,
[data-theme="dark"] .automation-sub-tab:hover {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .admin-tab.active,
[data-theme="dark"] .account-sub-tab.active,
[data-theme="dark"] .automation-sub-tab.active {
    color: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

/* Rounded card/panel backgrounds in dark mode */
[data-theme="dark"] .rounded-lg:not([style*="background"]):not(.bg-blue-600):not(.bg-blue-500):not(.bg-blue-400):not(.bg-cyan-500):not(.bg-teal-500):not(.bg-orange-500):not(.bg-green-500):not(.bg-green-600):not(.bg-green-400):not(.bg-purple-500):not(.bg-yellow-500):not(.bg-red-500):not(.bg-amber-600):not(.bg-emerald-500):not(.bg-gray-800):not(.bg-indigo-500):not(.bg-violet-500):not(.bg-sky-500):not(.bg-sky-600):not(.bg-purple-600) {
    background-color: var(--card-bg);
}

/* Shadow class backgrounds for dark mode */
[data-theme="dark"] .shadow,
[data-theme="dark"] .shadow-md,
[data-theme="dark"] .shadow-lg {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2) !important;
}