/* ✅ CSS DARK MODE ULTRA AGGRESSIVO - Forza TUTTI i contrasti */

/* ===== DARK MODE BASE ===== */
.dark {
  background-color: #111827 !important;
  color: #f9fafb !important;
}

.dark body {
  background-color: #111827 !important;
  color: #f9fafb !important;
}

.dark main {
  background-color: #111827 !important;
  color: #f9fafb !important;
}

/* ===== FORZA ASSOLUTA - TUTTI GLI SFONDI BIANCHI/GRIGI ===== */
.dark .bg-white,
.dark .bg-gray-50,
.dark .bg-gray-100,
.dark .bg-gray-200,
.dark .bg-gray-300 {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
}

/* ===== FORZA ASSOLUTA - TUTTI I TESTI SCURI ===== */
.dark .text-gray-800,
.dark .text-gray-700,
.dark .text-gray-600,
.dark .text-gray-500,
.dark .text-gray-400,
.dark .text-gray-300,
.dark .text-gray-900,
.dark .text-black {
  color: #f9fafb !important;
}

/* ===== FORZA TUTTI I CONTENITORI E FIGLI ===== */
.dark div,
.dark section,
.dark article,
.dark aside,
.dark header,
.dark footer {
  /* Se hanno sfondo bianco/grigio, forzalo scuro */
}

.dark div[class*="bg-white"],
.dark div[class*="bg-gray"],
.dark section[class*="bg-white"],
.dark section[class*="bg-gray"],
.dark article[class*="bg-white"],
.dark article[class*="bg-gray"] {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
}

/* ===== FORZA TUTTI I TESTI DENTRO CONTENITORI ===== */
.dark .bg-white *,
.dark .bg-gray-50 *,
.dark .bg-gray-100 *,
.dark .bg-gray-200 * {
  color: #f9fafb !important;
}

/* ===== ECCEZIONI - NON TOCCARE QUESTI ===== */
.dark img,
.dark svg,
.dark video,
.dark canvas,
.dark iframe {
  background-color: transparent !important;
  filter: none !important;
}

/* ===== CARD SPECIFICHE ===== */
.dark .card,
.dark .card-accessible,
.dark [class*="card"],
.dark [class*="rounded"] {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
}

/* ===== TESTI ROSSI → GIALLI ===== */
.dark .text-red-600,
.dark .text-red-700,
.dark .text-red-500,
.dark .text-red-800 {
  color: #fbbf24 !important; /* Giallo brillante */
}

.dark .text-red-200,
.dark .text-red-300,
.dark .text-red-400 {
  color: #fde047 !important; /* Giallo chiaro */
}

/* ===== BADGE E TAG ===== */
.dark .bg-red-100 {
  background-color: #7f1d1d !important;
  color: #fde047 !important;
}

.dark .bg-blue-100 {
  background-color: #1e3a8a !important;
  color: #93c5fd !important;
}

.dark .bg-green-100 {
  background-color: #14532d !important;
  color: #86efac !important;
}

.dark .bg-yellow-100 {
  background-color: #713f12 !important;
  color: #fde047 !important;
}

.dark .bg-purple-100 {
  background-color: #581c87 !important;
  color: #c4b5fd !important;
}

/* ===== BORDI ===== */
.dark .border-gray-200,
.dark .border-gray-300,
.dark .border-gray-400 {
  border-color: #374151 !important;
}

/* ===== INPUT E FORM ===== */
.dark input,
.dark select,
.dark textarea,
.dark .form-input {
  background-color: #374151 !important;
  color: #f9fafb !important;
  border-color: #4b5563 !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
  color: #9ca3af !important;
}

/* ===== PULSANTI ===== */
.dark .bg-red-600 {
  background-color: #dc2626 !important;
  color: #ffffff !important;
}

.dark .bg-blue-600 {
  background-color: #2563eb !important;
  color: #ffffff !important;
}

.dark .bg-gray-600 {
  background-color: #4b5563 !important;
  color: #ffffff !important;
}

/* ===== HOVER STATES ===== */
.dark .hover\:bg-gray-100:hover {
  background-color: #374151 !important;
}

.dark .hover\:bg-gray-200:hover {
  background-color: #4b5563 !important;
}

.dark .hover\:text-gray-600:hover {
  color: #d1d5db !important;
}

/* ===== HEADER E FOOTER SPECIFICI ===== */
.dark header {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
}

.dark footer {
  background-color: #111827 !important;
  color: #f9fafb !important;
}

/* ===== MODAL E OVERLAY ===== */
.dark .modal-content,
.dark .modal-overlay {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
}

/* ===== TABELLE ===== */
.dark table,
.dark thead,
.dark tbody,
.dark tr,
.dark th,
.dark td {
  background-color: #1f2937 !important;
  color: #f9fafb !important;
  border-color: #374151 !important;
}

/* ===== OMBRE ===== */
.dark .shadow-lg,
.dark .shadow-xl,
.dark .shadow-2xl {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3) !important;
}

/* ===== FOCUS STATES ===== */
.dark *:focus {
  outline: 2px solid #fbbf24 !important;
  outline-offset: 2px;
}

/* ===== GRADIENTI ===== */
.dark .bg-gradient-to-r,
.dark .bg-gradient-to-br,
.dark .bg-gradient-to-t,
.dark [class*="gradient"] {
  background: #1f2937 !important;
}

/* ===== LISTE ===== */
.dark ul,
.dark ol,
.dark li {
  color: #f9fafb !important;
}

/* ===== LINK ===== */
.dark a {
  color: #60a5fa !important;
}

.dark a:hover {
  color: #93c5fd !important;
}

/* ===== ALTO CONTRASTO ===== */
.high-contrast {
  background-color: #000000 !important;
  color: #ffffff !important;
}

.high-contrast *:not(img):not(svg):not(video) {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

.high-contrast .bg-red-600,
.high-contrast .bg-blue-600,
.high-contrast button {
  background-color: #ffff00 !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
}

/* ===== MOBILE - ACCESSIBILITÀ ===== */
@media (max-width: 1023px) {
  div[role="region"][aria-label="Controlli di accessibilità"] {
    position: fixed !important;
    bottom: 1.5rem !important;
    right: 1.5rem !important;
    top: auto !important;
    z-index: 99999 !important;
  }
}

@media (min-width: 1024px) {
  div[role="region"][aria-label="Controlli di accessibilità"] {
    position: fixed !important;
    top: 1.5rem !important;
    right: 1.5rem !important;
    bottom: auto !important;
    z-index: 99999 !important;
  }
}

/* ===== HAMBURGER MENU ===== */
@media (max-width: 1023px) {
  header .lg\:hidden {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    background-color: rgba(107, 114, 128, 0.1) !important;
    color: #374151 !important;
    border: 2px solid #374151 !important;
    border-radius: 0.5rem !important;
    padding: 0.75rem !important;
    min-height: 48px !important;
    min-width: 48px !important;
    z-index: 1001 !important;
  }
  
  .dark header .lg\:hidden {
    background-color: rgba(249, 250, 251, 0.1) !important;
    color: #f9fafb !important;
    border-color: #f9fafb !important;
  }
}

/* ===== FORZA UNIVERSALE - ULTIMA RISORSA ===== */
.dark-force * {
  color: #f9fafb !important;
  background-color: #1f2937 !important;
}

.dark-force img,
.dark-force svg,
.dark-force video {
  background-color: transparent !important;
}

/* ===== DEBUG - Per identificare problemi ===== */
.debug-dark .bg-white {
  border: 3px solid red !important;
}

.debug-dark .text-gray-800 {
  background: yellow !important;
  color: black !important;
}