/**
 * NCA GRC Platform - Custom Styles
 * Complements Tailwind CSS with additional styling
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --nca-green: #00843D;
    --nca-green-light: #00a84c;
    --nca-green-dark: #006b32;
    --nca-dark: #1e3a5f;
    --nca-dark-light: #2a4d7a;
    --nca-dark-darker: #152a45;
    --sidebar-width: 16rem;
}

/* ============================================
   Global Resets & Base Styles
   ============================================ */
[x-cloak] {
    display: none !important;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Dark scrollbar for sidebar */
.sidebar-scrollbar::-webkit-scrollbar-track {
    background: var(--nca-dark-darker);
}

.sidebar-scrollbar::-webkit-scrollbar-thumb {
    background: #4a5568;
}

.sidebar-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* ============================================
   Typography
   ============================================ */
.text-gradient {
    background: linear-gradient(135deg, var(--nca-green) 0%, var(--nca-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   Form Styling
   ============================================ */
.form-input,
.form-select,
.form-textarea {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--nca-green);
    box-shadow: 0 0 0 3px rgba(0, 132, 61, 0.1);
    outline: none;
}

/* Form validation states */
.form-input.is-valid {
    border-color: #10b981;
}

.form-input.is-invalid {
    border-color: #ef4444;
}

.form-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Checkbox and Radio styling */
.form-checkbox:checked,
.form-radio:checked {
    background-color: var(--nca-green);
    border-color: var(--nca-green);
}

/* ============================================
   Table Styling
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.data-table thead {
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Sortable table headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    background-color: #f1f5f9;
}

/* ============================================
   Card Styling
   ============================================ */
.card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

html.dark .card {
    background-color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

html.dark .card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

html.dark .card-header {
    border-bottom-color: #4b5563;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    background-color: #f8fafc;
    border-radius: 0 0 0.5rem 0.5rem;
}

html.dark .card-footer {
    border-top-color: #4b5563;
    background-color: #1f2937;
}

/* Dashboard stat cards */
.stat-card {
    background-color: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--nca-green);
    transition: background-color 0.2s ease-in-out;
}

html.dark .stat-card {
    background-color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1e293b;
}

html.dark .stat-card-value {
    color: #f9fafb;
}

.stat-card-label {
    font-size: 0.875rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

html.dark .stat-card-label {
    color: #9ca3af;
}

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

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

.btn-primary {
    background-color: var(--nca-green);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--nca-green-dark);
}

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

.btn-secondary:hover:not(:disabled) {
    background-color: #cbd5e1;
}

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

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.btn-outline:hover:not(:disabled) {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

/* Icon buttons */
.btn-icon {
    padding: 0.5rem;
    border-radius: 0.375rem;
}

/* ============================================
   Loading & Spinners
   ============================================ */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #e2e8f0;
    border-top-color: var(--nca-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 1rem;
    height: 1rem;
}

.spinner-lg {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
}

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

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 0.25rem;
}

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

/* ============================================
   HTMX Loading Indicators
   ============================================ */
.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

/* Disable clicks during HTMX request - only for specific indicators, not the body */
.htmx-request.htmx-indicator {
    opacity: 1;
    pointer-events: none;
}

/* Buttons and form elements should be disabled during requests */
.htmx-request button,
.htmx-request input[type="submit"],
.htmx-request .btn {
    pointer-events: none;
    opacity: 0.7;
}

/* Sidebar links should NEVER be disabled - keep them always clickable */
.sidebar-nav-item,
.sidebar-nav-item.htmx-request,
nav[hx-boost] a {
    pointer-events: auto !important;
    opacity: 1 !important;
}

/* Main content area should always be interactive */
#main-content,
body,
html {
    pointer-events: auto !important;
}

/* Only disable pointer events on the actual elements that are loading, not their children */
.htmx-request > * {
    pointer-events: auto;
}

/* Progress bar indicator */
.htmx-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--nca-green);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease-in-out;
    z-index: 9999;
}

.htmx-request ~ .htmx-progress,
.htmx-request .htmx-progress {
    transform: scaleX(0.7);
}

/* ============================================
   Sidebar Styling
   ============================================ */
.sidebar {
    background-color: var(--nca-dark);
    width: var(--sidebar-width);
    min-height: 100vh;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #cbd5e1;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
    margin: 0.25rem 0.75rem;
}

.sidebar-nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav-item.active {
    background-color: var(--nca-green);
    color: white;
}

.sidebar-nav-item svg {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 1rem 1rem 0.5rem;
    margin-top: 0.5rem;
}

/* ============================================
   Badge Styling
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-neutral {
    background-color: #f1f5f9;
    color: #475569;
}

/* Compliance status badges */
.badge-compliant {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-partial {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-non-compliant {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-not-assessed {
    background-color: #f1f5f9;
    color: #475569;
}

/* ============================================
   Progress Bars
   ============================================ */
.progress-bar {
    height: 0.5rem;
    background-color: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--nca-green);
    border-radius: 9999px;
    transition: width 0.3s ease-in-out;
}

.progress-bar-fill.warning {
    background-color: #f59e0b;
}

.progress-bar-fill.danger {
    background-color: #ef4444;
}

/* ============================================
   Dropdown Menus
   ============================================ */
.dropdown-menu {
    position: absolute;
    right: 0;
    margin-top: 0.5rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    min-width: 12rem;
    z-index: 50;
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: #475569;
    font-size: 0.875rem;
    transition: background-color 0.15s ease-in-out;
}

.dropdown-item:hover {
    background-color: #f8fafc;
}

.dropdown-item:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

.dropdown-divider {
    height: 1px;
    background-color: #e2e8f0;
    margin: 0.5rem 0;
}

/* ============================================
   Modal Styling
   ============================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 50;
}

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

.modal-body {
    padding: 1.5rem;
}

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

/* ============================================
   Alerts & Notifications
   ============================================ */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
}

.alert svg {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

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

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    min-width: 20rem;
    animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-out {
    animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================
   Tooltip Styling
   ============================================ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background-color: #1e293b;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
    margin-bottom: 0.5rem;
    z-index: 100;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ============================================
   Responsive Utilities
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 40;
        transition: transform 0.3s ease-in-out;
    }

    .sidebar.open {
        transform: translateX(0);
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sidebar,
    .navbar,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #e2e8f0;
    }
}

/* ============================================
   Accessibility
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--nca-green);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background-color: var(--nca-green);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 9999;
    transition: top 0.3s ease-in-out;
}

.skip-link:focus {
    top: 0;
}

/* ============================================
   Gantt Chart Styling
   ============================================ */
.gantt-container {
    overflow-x: auto;
    background: white;
    border-radius: 0.5rem;
}

.gantt .bar-wrapper:hover .bar {
    opacity: 0.85;
}

/* Status-based bar colors */
.gantt .bar-proposed .bar { fill: #9CA3AF; }
.gantt .bar-approved .bar { fill: #3B82F6; }
.gantt .bar-in-progress .bar { fill: #F59E0B; }
.gantt .bar-completed .bar { fill: #22C55E; }
.gantt .bar-on-hold .bar { fill: #EF4444; }
.gantt .bar-default .bar { fill: #6B7280; }

.gantt .bar-progress {
    fill: rgba(0, 0, 0, 0.15);
}

.gantt .bar-label {
    fill: #1f2937;
    font-weight: 500;
}

.gantt .bar-label.big {
    fill: white;
    font-weight: 500;
}

.gantt .grid-background {
    fill: #fafafa;
}

.gantt .grid-header {
    fill: #f3f4f6;
    stroke: #e5e7eb;
}

.gantt .tick {
    stroke: #e5e7eb;
}

.gantt .today-highlight {
    fill: rgba(0, 132, 61, 0.1);
}

/* Gantt popup styling */
.gantt-popup-wrapper {
    z-index: 100;
}

.gantt-popup {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
    min-width: 200px;
}

.gantt-popup h4 {
    font-weight: 600;
    color: #111827;
    margin-bottom: 8px;
}

.gantt-popup p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 4px 0;
}

/* View mode buttons */
.view-mode-btn {
    transition: all 0.15s ease-in-out;
}

.view-mode-btn.active {
    background-color: var(--nca-green);
    color: white;
    border-color: var(--nca-green);
}

/* Legend styling */
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #6b7280;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Line clamp utility */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================
   Dark Mode Styles
   ============================================ */

/*
 * IMPORTANT: These styles use !important to override Tailwind CDN utilities.
 * The .dark class is applied to the <html> element by Alpine.js
 */

/* Dark mode scrollbar */
html.dark ::-webkit-scrollbar-track {
    background: #1f2937;
}

html.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Dark mode cards - using lighter gray for better contrast */
/* Using html.dark for highest specificity */
html.dark .card,
html.dark .stat-card,
html.dark [class*="rounded"][class*="bg-white"],
html.dark [class*="shadow"][class*="bg-white"],
html.dark div.bg-white,
html.dark section.bg-white,
html.dark article.bg-white {
    background-color: #374151 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

html.dark .card:hover,
html.dark .stat-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4) !important;
}

html.dark .card-header {
    border-bottom-color: #4b5563 !important;
}

html.dark .card-footer {
    border-top-color: #4b5563 !important;
    background-color: #1f2937 !important;
}

/* Force dark backgrounds on common card patterns using Tailwind classes */
html.dark .rounded-lg.bg-white,
html.dark .rounded-xl.bg-white,
html.dark .rounded-md.bg-white,
html.dark .rounded.bg-white,
html.dark div[class*="bg-white"],
html.dark section[class*="bg-white"],
html.dark article[class*="bg-white"] {
    background-color: #374151 !important;
}

/* Dashboard stat cards (typically have border-l-4) */
html.dark [class*="border-l-4"].bg-white,
html.dark [class*="border-l-"].bg-white {
    background-color: #374151 !important;
}

html.dark .stat-card-value {
    color: #f9fafb;
}

html.dark .stat-card-label {
    color: #9ca3af;
}

/* Dark mode tables */
html.dark .table-container {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

html.dark .data-table thead {
    background-color: #1f2937;
    border-bottom-color: #4b5563;
}

html.dark .data-table th {
    color: #d1d5db;
}

html.dark .data-table td {
    border-bottom-color: #4b5563;
    color: #e5e7eb;
}

html.dark .data-table tbody tr:hover {
    background-color: #4b5563;
}

html.dark .data-table th.sortable:hover {
    background-color: #4b5563;
}

/* Dark mode buttons */
html.dark .btn-secondary {
    background-color: #374151;
    color: #e5e7eb;
}

html.dark .btn-secondary:hover:not(:disabled) {
    background-color: #4b5563;
}

html.dark .btn-outline {
    border-color: #4b5563;
    color: #d1d5db;
}

html.dark .btn-outline:hover:not(:disabled) {
    background-color: #374151;
    border-color: #6b7280;
}

/* Dark mode forms */
html.dark .form-input,
html.dark .form-select,
html.dark .form-textarea {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

html.dark .form-input::placeholder,
html.dark .form-select::placeholder,
html.dark .form-textarea::placeholder {
    color: #9ca3af;
}

/* Dark mode dropdowns */
html.dark .dropdown-menu {
    background-color: #374151;
    border-color: #4b5563;
}

html.dark .dropdown-item {
    color: #e5e7eb;
}

html.dark .dropdown-item:hover {
    background-color: #4b5563;
}

html.dark .dropdown-divider {
    background-color: #4b5563;
}

/* Dark mode modals */
html.dark .modal {
    background-color: #374151;
}

html.dark .modal-header {
    border-bottom-color: #4b5563;
}

html.dark .modal-footer {
    border-top-color: #4b5563;
}

/* Dark mode loading */
html.dark .loading-overlay {
    background-color: rgba(17, 24, 39, 0.8);
}

html.dark .skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
}

/* Dark mode progress bar */
html.dark .progress-bar {
    background-color: #374151;
}

/* Dark mode badges - keep colors vibrant */
html.dark .badge-success {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

html.dark .badge-warning {
    background-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

html.dark .badge-danger {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

html.dark .badge-info {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

html.dark .badge-neutral {
    background-color: #374151;
    color: #d1d5db;
}

/* Dark mode alerts */
html.dark .alert-success {
    background-color: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: #34d399;
}

html.dark .alert-warning {
    background-color: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

html.dark .alert-danger {
    background-color: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

html.dark .alert-info {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60a5fa;
}

/* Dark mode toasts */
html.dark .toast {
    background-color: #374151;
    color: #f9fafb;
}

/* Dark mode tooltips */
html.dark [data-tooltip]::after {
    background-color: #f9fafb;
    color: #111827;
}

/* Dark mode Gantt chart */
html.dark .gantt-container {
    background: #1f2937;
}

html.dark .gantt .grid-background {
    fill: #111827;
}

html.dark .gantt .grid-header {
    fill: #1f2937;
    stroke: #374151;
}

html.dark .gantt .tick {
    stroke: #374151;
}

html.dark .gantt .bar-label {
    fill: #f9fafb;
}

/* Frappe Gantt SVG text elements in dark mode */
html.dark .gantt text {
    fill: #e5e7eb;
}

html.dark .gantt .lower-text,
html.dark .gantt .upper-text {
    fill: #9ca3af;
}

html.dark .gantt .grid-row:nth-child(even) {
    fill: #1f2937;
}

html.dark .gantt .grid-row:nth-child(odd) {
    fill: #111827;
}

html.dark .gantt .row-line {
    stroke: #374151;
}

html.dark .gantt-popup {
    background: #374151;
    border-color: #4b5563;
}

html.dark .gantt-popup h4 {
    color: #f9fafb;
}

html.dark .gantt-popup p {
    color: #9ca3af;
}

/* Dark mode overrides for Tailwind utilities - using html.dark for highest specificity */
html.dark .text-gray-900 { color: #f9fafb !important; }
html.dark .text-gray-800 { color: #f3f4f6 !important; }
html.dark .text-gray-700 { color: #e5e7eb !important; }
html.dark .text-gray-600 { color: #d1d5db !important; }
html.dark .text-gray-500 { color: #9ca3af !important; }
html.dark .text-gray-400 { color: #9ca3af !important; }

/* Background overrides - using html.dark for specificity */
html.dark .bg-white { background-color: #374151 !important; }
html.dark .bg-gray-50 { background-color: #1f2937 !important; }
html.dark .bg-gray-100 { background-color: #374151 !important; }
html.dark .bg-gray-200 { background-color: #4b5563 !important; }

/* Border overrides */
html.dark .border-gray-100 { border-color: #4b5563 !important; }
html.dark .border-gray-200 { border-color: #4b5563 !important; }
html.dark .border-gray-300 { border-color: #6b7280 !important; }

/* Hover state overrides */
html.dark .hover\:bg-gray-50:hover { background-color: #4b5563 !important; }
html.dark .hover\:bg-gray-100:hover { background-color: #4b5563 !important; }

/* Ring/focus overrides */
html.dark .ring-white { --tw-ring-color: #374151 !important; }
html.dark .divide-gray-200 > :not([hidden]) ~ :not([hidden]) { border-color: #4b5563 !important; }

/* Shadow adjustments for dark mode */
html.dark .shadow { box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3), 0 1px 2px -1px rgb(0 0 0 / 0.3) !important; }
html.dark .shadow-sm { box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.3) !important; }
html.dark .shadow-md { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3) !important; }
html.dark .shadow-lg { box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3) !important; }

/* Force all white backgrounds to dark in dark mode - comprehensive selector */
html.dark *[class*="bg-white"]:not(.dark\:bg-gray-700):not(.dark\:bg-gray-800):not([class*="dark:bg-"]) {
    background-color: #374151 !important;
}
