/* Minimal app styling on top of Tailwind */

html, body {
  background: #ffffff;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

html.dark, html.dark body {
  background: #111827;
}

/* ========== Dark mode - main content area ========== */
html.dark main .bg-white { background-color: #1f2937 !important; }
html.dark main .bg-gray-50 { background-color: #1f2937 !important; }
html.dark main .bg-gray-100 { background-color: #374151 !important; }
html.dark main .border-gray-200 { border-color: #374151 !important; }
html.dark main .border-gray-100 { border-color: #374151 !important; }
html.dark main .border-gray-300 { border-color: #4b5563 !important; }
html.dark main .text-gray-900 { color: #f9fafb !important; }
html.dark main .text-gray-800 { color: #f3f4f6 !important; }
html.dark main .text-gray-700 { color: #e5e7eb !important; }
html.dark main .text-gray-600 { color: #d1d5db !important; }
html.dark main .text-gray-500 { color: #9ca3af !important; }
html.dark main .text-gray-400 { color: #9ca3af !important; }
html.dark main .divide-gray-100 { border-color: #374151 !important; }
html.dark main .divide-gray-200 { border-color: #4b5563 !important; }
html.dark main input, html.dark main textarea, html.dark main select {
  background-color: #374151 !important;
  border-color: #4b5563 !important;
  color: #f9fafb !important;
}
html.dark main input::placeholder, html.dark main textarea::placeholder { color: #9ca3af; }
html.dark main thead tr.bg-gray-50,
html.dark main thead.bg-gray-50,
html.dark main tr.bg-gray-50 { background-color: #374151 !important; }
html.dark main tbody tr:hover,
html.dark main tr.hover\:bg-gray-50:hover { background-color: #374151 !important; }
html.dark main .hover\:bg-gray-100:hover { background-color: #4b5563 !important; }
html.dark main .bg-blue-50, html.dark main .bg-gray-50.hover\:bg-blue-100 { background-color: #1e3a5f !important; }
html.dark main .bg-red-50 { background-color: #3f1f1f !important; }
html.dark main .text-blue-700, html.dark main .text-blue-800 { color: #93c5fd !important; }
html.dark main .text-green-700, html.dark main .text-green-800 { color: #86efac !important; }
html.dark main .text-yellow-700 { color: #fde047 !important; }
html.dark main .text-red-700 { color: #fca5a5 !important; }
html.dark main a.bg-gray-50:hover, html.dark main .bg-gray-100.hover\:bg-gray-200:hover { background-color: #4b5563 !important; }

/* ========== Dark mode - sidebar active states ========== */
html.dark #sidebar .bg-blue-50,
html.dark #sidebar .sidebar-link.bg-blue-50 { background-color: #1e3a5f !important; }
html.dark #sidebar .bg-emerald-50 { background-color: #134e3a !important; }
html.dark #sidebar .bg-violet-50 { background-color: #2e1065 !important; }
html.dark #sidebar .bg-orange-50 { background-color: #431407 !important; }
html.dark #sidebar .bg-teal-50 { background-color: #134e4a !important; }
html.dark #sidebar .bg-pink-50 { background-color: #4c0519 !important; }
html.dark #sidebar .bg-sky-50 { background-color: #0c4a6e !important; }
html.dark #sidebar .bg-amber-50 { background-color: #451a03 !important; }
html.dark #sidebar .bg-rose-50 { background-color: #431407 !important; }
html.dark #sidebar .bg-cyan-50 { background-color: #134e4a !important; }
html.dark #sidebar .bg-slate-50 { background-color: #1e293b !important; }
html.dark #sidebar .bg-red-50 { background-color: #450a0a !important; }
html.dark #sidebar .bg-indigo-50 { background-color: #312e81 !important; }

/* ========== Dark mode - status badges, flash messages ========== */
html.dark main .bg-green-50 { background-color: #14532d !important; }
html.dark main .bg-yellow-100 { background-color: #422006 !important; }
html.dark main .bg-blue-100 { background-color: #1e3a5f !important; }
html.dark main .bg-purple-100 { background-color: #3b0764 !important; }
html.dark main .bg-green-100 { background-color: #14532d !important; }
html.dark main .bg-red-100 { background-color: #450a0a !important; }
html.dark main .text-yellow-800 { color: #fde047 !important; }
html.dark main .text-blue-800 { color: #93c5fd !important; }
html.dark main .text-purple-800 { color: #e9d5ff !important; }
html.dark main .text-green-800 { color: #86efac !important; }
html.dark main .text-red-800 { color: #fca5a5 !important; }
html.dark main .border-green-200 { border-color: #166534 !important; }

/* ========== Dark mode - gradients (from-* to-white) ========== */
html.dark main .to-white { --tw-gradient-to: #1f2937 !important; --tw-gradient-stops: var(--tw-gradient-from), #1f2937 !important; }
html.dark main .from-green-50 { --tw-gradient-from: #14532d !important; }
html.dark main .from-blue-50 { --tw-gradient-from: #1e3a5f !important; }
html.dark main .from-red-50 { --tw-gradient-from: #450a0a !important; }
html.dark main .border-b-2.border-gray-200 { border-color: #374151 !important; }
html.dark main tr.hover\:bg-green-50\/30:hover { background-color: rgba(22, 101, 52, 0.3) !important; }
html.dark main tr.hover\:bg-blue-50\/30:hover { background-color: rgba(30, 58, 95, 0.3) !important; }
html.dark main .border-2.border-red-200 { border-color: #7f1d1d !important; }
html.dark main .border-red-200 { border-color: #7f1d1d !important; }
html.dark main .bg-yellow-50 { background-color: #422006 !important; }

/* ========== Dark mode - reports, peer-checked cards, more gradients ========== */
html.dark main .from-indigo-50 { --tw-gradient-from: #312e81 !important; }
html.dark main .from-gray-50 { --tw-gradient-from: #1f2937 !important; }
html.dark main .peer-checked\:bg-green-50 { background-color: #14532d !important; }
html.dark main .peer-checked\:bg-blue-50 { background-color: #1e3a5f !important; }
html.dark main .peer-checked\:bg-indigo-50 { background-color: #312e81 !important; }
html.dark main .peer-checked\:bg-purple-50 { background-color: #3b0764 !important; }
html.dark main .peer-checked\:bg-emerald-50 { background-color: #134e3a !important; }
html.dark main .peer-checked\:bg-red-50 { background-color: #450a0a !important; }
html.dark main .peer-checked\:border-green-500 { border-color: #22c55e !important; }
html.dark main .peer-checked\:border-blue-500 { border-color: #3b82f6 !important; }
html.dark main .peer-checked\:border-indigo-500 { border-color: #6366f1 !important; }
html.dark main .peer-checked\:border-purple-500 { border-color: #a855f7 !important; }
html.dark main .peer-checked\:border-emerald-500 { border-color: #10b981 !important; }
html.dark main .peer-checked\:border-red-500 { border-color: #ef4444 !important; }
html.dark main .text-green-600 { color: #86efac !important; }
html.dark main .bg-indigo-50 { background-color: #312e81 !important; }
html.dark main .bg-emerald-50 { background-color: #134e3a !important; }
html.dark main .bg-purple-50 { background-color: #3b0764 !important; }
html.dark main .bg-indigo-100 { background-color: #3730a3 !important; }

html[dir="rtl"] body {
  font-family: "Cairo", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
}

html[dir="ltr"] body {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
}

/* Ensure proper RTL support */
* {
  box-sizing: border-box;
}

/* Better RTL readability for tables */
table th, table td {
  vertical-align: top;
}

/* Responsive table wrapper */
.overflow-auto {
  -webkit-overflow-scrolling: touch;
}

/* Ensure buttons are properly sized on mobile */
button, .btn {
  touch-action: manipulation;
}

/* Exclude small icon buttons from min-height */
button:not(.btn-icon) {
  min-height: 40px;
}

/* Small icon buttons like close, toggle */
button.btn-icon,
#sidebarClose,
#sidebarToggle,
#notificationsBtn {
  min-height: auto !important;
  padding: 0 !important;
}

/* ========== Sidebar Styles ========== */
#sidebar {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

#sidebar .sidebar-link {
  will-change: opacity, transform;
}

/* LTR sidebar border */
html[dir="ltr"] #sidebar {
  border-right: 1px solid #e5e7eb;
}

/* RTL sidebar border */
html[dir="rtl"] #sidebar {
  border-left: 1px solid #e5e7eb;
}

/* ========== Mobile-specific ========== */
@media (max-width: 767px) {
  body {
    overflow-x: hidden;
  }
  
  .p-4 {
    padding: 1rem !important;
  }
  
  .grid {
    grid-template-columns: 1fr !important;
  }
}

/* ========== Desktop sidebar space ========== */
@media (min-width: 768px) {
  html[dir="rtl"] .md\:mr-72 {
    margin-right: 18rem !important;
  }
  html[dir="ltr"] .md\:mr-72 {
    margin-left: 18rem !important;
    margin-right: 0 !important;
  }
}

/* ========== Print ========== */
@media print {
  .no-print { display: none !important; }
  .print-block { display: block !important; }
  body { background: #fff !important; }
  
  .md\:mr-72 {
    margin-right: 0 !important;
    margin-left: 0 !important;
  }
}

/* ========== Focus styles ========== */
*:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ========== Desktop enhancements ========== */
@media (min-width: 1024px) {
  main {
    max-width: 1600px;
    margin: 0 auto;
  }
  
  table td, table th {
    padding: 1rem 1.5rem !important;
  }
  
  body {
    font-size: 16px;
  }
  
  button, .btn, a.btn-primary {
    min-height: 48px;
    padding: 0.75rem 1.5rem;
  }
}
