/* theme.css - Global Styles, Dark Mode & Overrides */

:root {
  --bg-primary: #f3f4f6;
  --bg-secondary: #ffffff;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --accent-color: #2563eb;
  --border-color: #e5e7eb;
}

body.dark-mode {
  --bg-primary: #0f172a;
  /* Slate 900 */
  --bg-secondary: #1e293b;
  /* Slate 800 */
  --text-primary: #f1f5f9;
  /* Slate 100 */
  --text-secondary: #94a3b8;
  /* Slate 400 */
  --accent-color: #3b82f6;
  --border-color: #334155;
  /* Slate 700 */
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Glassmorphism Utilities */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

body.dark-mode .glass {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Modal Modernization */
/* Modal Modernization with Glassmorphism */
.modal-content {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #1f2937 !important;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

body.dark-mode .modal-content {
  background: rgba(30, 41, 59, 0.95) !important;
  color: #f1f5f9 !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* DARK MODE OVERRIDES - HIGH SPECIFICITY */

/* Backgrounds */
body.dark-mode.bg-white,
body.dark-mode.bg-gray-50,
body.dark-mode.bg-gray-100,
/* Fix for body class itself */
body.dark-mode.bg-gray-200,
body.dark-mode .bg-white,
body.dark-mode .bg-gray-50,
body.dark-mode .bg-gray-100,
body.dark-mode .bg-gray-200 {
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
}

body.dark-mode.bg-gray-100,
body.dark-mode .bg-gray-100 {
  background-color: var(--bg-primary) !important;
}

/* Text Colors */
body.dark-mode .text-gray-900,
body.dark-mode .text-gray-800,
body.dark-mode .text-gray-700,
body.dark-mode .text-black {
  color: var(--text-primary) !important;
}

body.dark-mode .text-gray-600,
body.dark-mode .text-gray-500,
body.dark-mode .text-gray-400 {
  color: var(--text-secondary) !important;
}

/* Borders */
body.dark-mode .border,
body.dark-mode .border-t,
body.dark-mode .border-b,
body.dark-mode .border-l,
body.dark-mode .border-r,
body.dark-mode .border-gray-200,
body.dark-mode .border-gray-300 {
  border-color: var(--border-color) !important;
}

/* Inputs & Selects */
body.dark-mode input.input-text,
body.dark-mode select.input-text,
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="password"] {
  background-color: #0f172a !important;
  /* Slate 900 */
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

body.dark-mode input::placeholder {
  color: #64748b !important;
}

/* Table Enhancements */
body.dark-mode table thead th {
  background-color: #0f172a !important;
  /* Darker header */
  color: #94a3b8 !important;
  border-bottom-color: #334155 !important;
}

body.dark-mode tbody tr:hover {
  background-color: rgba(59, 130, 246, 0.1) !important;
}

body.dark-mode tbody tr {
  background-color: var(--bg-secondary) !important;
  border-bottom-color: var(--border-color) !important;
}

/* Specific Fix for Header Text showing white on white */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
  color: var(--text-primary) !important;
}

/* Buttons */
body.dark-mode button.bg-gray-200 {
  background-color: #334155 !important;
  /* Slate 700 */
  color: #f1f5f9 !important;
}

body.dark-mode button.bg-gray-200:hover {
  background-color: #475569 !important;
  /* Slate 600 */
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

body.dark-mode ::-webkit-scrollbar-thumb {
  background-color: #475569;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
  background-color: #64748b;
}

body.dark-mode .text-red-600,
body.dark-mode .text-red-700 {
  color: #f87171 !important;
  /* Lighter red (red-400) for better visibility on dark bg */
}

body.dark-mode .text-green-600,
body.dark-mode .text-green-700 {
  color: #4ade80 !important;
  /* Lighter green (green-400) */
}

body.dark-mode .text-blue-600,
body.dark-mode .text-blue-700 {
  color: #60a5fa !important;
  /* Lighter blue (blue-400) */
}

/* Dark Mode Toggle Button */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 9999px;
  color: #6b7280;
  transition: color 0.2s;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #111827;
}

body.dark-mode .theme-toggle {
  color: #94a3b8;
}

body.dark-mode .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

/* Popover Menu Fixes */
.action-popover {
  z-index: 50;
  /* Ensure it stays above other elements */
}

body.dark-mode .action-popover {
  background-color: #1e293b !important;
  /* Slate 800 */
  border-color: #334155 !important;
}

body.dark-mode .action-popover button {
  color: #f1f5f9 !important;
}

body.dark-mode .action-popover button:hover {
  background-color: #334155 !important;
  /* Slate 700 */
  color: #fff !important;
}

/* =========================================
   ANIMACIONES DE LA BARRA LATERAL (Sidebar)
   ========================================= */

/* 1. Transición suave del ancho de la barra */
#sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Estilos base del texto para que pueda animarse */
.sidebar-text {
    /* Animamos opacidad, ancho máximo y margen para que desaparezca suavemente */
    transition: opacity 0.2s ease-in-out, max-width 0.3s ease-in-out, margin 0.3s ease-in-out;
    opacity: 1;
    max-width: 200px; /* Suficiente para el texto largo */
    white-space: nowrap;
    overflow: hidden;
    display: inline-block; /* Necesario para que respete width/max-width */
    vertical-align: middle;
}

/* 3. Estilos cuando está COLAPSADA (.sidebar-collapsed en el wrapper) */
#sidebar-wrapper.sidebar-collapsed .sidebar-text {
    opacity: 0;
    max-width: 0;
    margin: 0;
    pointer-events: none; /* Evita clicks fantasmas */
}

/* 4. Ajustes para los íconos y layout cuando está colapsada */
#sidebar-wrapper.sidebar-collapsed .sidebar-link {
    justify-content: center; /* Centrar íconos */
    padding-left: 0;
    padding-right: 0;
}

#sidebar-wrapper.sidebar-collapsed .sidebar-link svg {
    margin-right: 0; /* Quitar margen derecho del ícono */
}

/* 5. Ocultar título y logo grande al colapsar */
#sidebar-wrapper.sidebar-collapsed .brand-name,
#sidebar-wrapper.sidebar-collapsed .brand-logo-container div {
    display: none; /* El contenedor de texto del header */
}

#sidebar-wrapper.sidebar-collapsed .brand-logo-container {
    justify-content: center;
    width: 100%;
}