:root,
html[data-theme="light"] {
  color-scheme: light;
  --ekeko-bg: #f7f7fb;
  --ekeko-surface: #ffffff;
  --ekeko-surface-secondary: #f2f2f6;
  --ekeko-text: #191923;
  --ekeko-text-muted: #85838e;
  --ekeko-border: #e3e1e8;
  --ekeko-primary: #171e42;
  --ekeko-primary-hover: #6939e4;
  --ekeko-danger: #dc3545;
  --ekeko-success: #198754;
  --ekeko-warning: #b7791f;
  --ekeko-radius-sm: 12px;
  --ekeko-radius-md: 18px;
  --ekeko-shadow-sm: 0 6px 20px rgba(20, 20, 30, .06);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ekeko-bg: #0b0b0d;
  --ekeko-surface: #202326;
  --ekeko-surface-secondary: #292c2f;
  --ekeko-text: #e5e7eb;
  --ekeko-text-muted: #aeb4c2;
  --ekeko-border: #34363a;
  --ekeko-primary: #aaacb7;
  --ekeko-primary-hover: #865df2;
  --ekeko-danger: #dc3545;
  --ekeko-success: #35b77a;
  --ekeko-warning: #f0bd58;
  --ekeko-shadow-sm: 0 6px 20px rgba(0, 0, 0, .25);
  --white: #202326;
  --grey10: #d5d5dc;
  --grey20: #292c2f;
  --grey30: #25282b;
  --grey40: #202326;
  --green10: #214432;
}

html, body { background-color: var(--ekeko-bg); }
body { color: var(--ekeko-text); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--ekeko-primary); }
a:hover { color: var(--ekeko-primary-hover); }

.navbar.bg-primary {
  background: var(--ekeko-primary) !important;
  box-shadow: 0 5px 20px rgba(40, 25, 90, .18);
}
.navbar .logo { filter: drop-shadow(0 2px 4px rgba(0,0,0,.14)); }
.content-wrapper { color: var(--ekeko-text); }

/* Ajuste específico del chrome global en modo oscuro, según referencia de Clientes. */
html[data-theme="dark"] .navbar.bg-primary {
  background: #121214 !important;
  box-shadow: none;
}
html[data-theme="dark"] .nav-contactos {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .nav-contactos .controlSelect {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .bg-light.fixed-bottom {
  background: #121214 !important;
  border-top: 1px solid #202124;
  box-shadow: none !important;
  color: var(--ekeko-text-muted);
}
html[data-theme="dark"] .bg-light.fixed-bottom a,
html[data-theme="dark"] .bg-light.fixed-bottom .fas,
html[data-theme="dark"] .bg-light.fixed-bottom .fab {
  color: var(--ekeko-text-muted);
}
html[data-theme="dark"] .bg-light.fixed-bottom .miniTxt {
  color: var(--ekeko-primary) !important;
}
html[data-theme="dark"] .bg-light.fixed-bottom .contactosBtn,
html[data-theme="dark"] .bg-light.fixed-bottom .contactosBtn .fas {
  color: #fff;
}

/* Contraste de contenido en modo oscuro, sin alterar enlaces ni estados. */
html[data-theme="dark"] .table,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .table th,
html[data-theme="dark"] .dataTables_wrapper,
html[data-theme="dark"] .dataTables_wrapper label,
html[data-theme="dark"] .dataTables_wrapper .dataTables_info,
html[data-theme="dark"] .dataTables_wrapper .dataTables_length,
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter,
html[data-theme="dark"] .tablaClientes,
html[data-theme="dark"] .tablaServicios {
  color: #e5e7eb;
}
html[data-theme="dark"] .table td small,
html[data-theme="dark"] .table td .text-muted,
html[data-theme="dark"] .table th .text-muted,
html[data-theme="dark"] .dataTables_wrapper .text-muted,
html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] .text-muted {
  color: #aeb4c2 !important;
}
html[data-theme="dark"] .text-dark {
  color: #e5e7eb !important;
}
html[data-theme="dark"] a.text-dark,
html[data-theme="dark"] .ekeko-client-link,
html[data-theme="dark"] .ekeko-service-link {
  color: var(--ekeko-primary);
}
/* html[data-theme="dark"] .analysis-kpi strong {
  color: #c1c7e5 !important;
} */
html[data-theme="dark"] .analysis-stat strong {
  color: #e5e7eb !important;
}

/* Bootstrap modals y SweetAlert usados por los CRUD, saldo y confirmaciones. */
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .swal2-popup {
  background: #202326 !important;
  color: #e5e7eb !important;
  border: 1px solid #383a40 !important;
  border-radius: 16px !important;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .38) !important;
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .swal2-footer {
  border-color: #383a40 !important;
}
html[data-theme="dark"] .modal-title,
html[data-theme="dark"] .swal2-title,
html[data-theme="dark"] .swal2-html-container,
html[data-theme="dark"] .swal2-content,
html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .modal-body label,
html[data-theme="dark"] .swal2-popup label,
html[data-theme="dark"] .swal2-validation-message {
  color: #e5e7eb !important;
}
html[data-theme="dark"] .modal-body small,
html[data-theme="dark"] .modal-body .text-muted,
html[data-theme="dark"] .swal2-html-container small,
html[data-theme="dark"] .swal2-content small {
  color: #aeb4c2 !important;
}
html[data-theme="dark"] .modal-content input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] .modal-content select,
html[data-theme="dark"] .modal-content textarea,
html[data-theme="dark"] .swal2-popup input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] .swal2-popup select,
html[data-theme="dark"] .swal2-popup textarea,
html[data-theme="dark"] .swal2-input,
html[data-theme="dark"] .swal2-select,
html[data-theme="dark"] .swal2-textarea {
  background: #141518 !important;
  color: #e5e7eb !important;
  border: 1px solid #383a40 !important;
  border-radius: 10px !important;
}
html[data-theme="dark"] .modal-content input::placeholder,
html[data-theme="dark"] .modal-content textarea::placeholder,
html[data-theme="dark"] .swal2-popup input::placeholder,
html[data-theme="dark"] .swal2-popup textarea::placeholder,
html[data-theme="dark"] .swal2-input::placeholder,
html[data-theme="dark"] .swal2-textarea::placeholder {
  color: #aeb4c2 !important;
  opacity: .85;
}
html[data-theme="dark"] .modal-content input:focus,
html[data-theme="dark"] .modal-content select:focus,
html[data-theme="dark"] .modal-content textarea:focus,
html[data-theme="dark"] .swal2-popup input:focus,
html[data-theme="dark"] .swal2-popup select:focus,
html[data-theme="dark"] .swal2-popup textarea:focus,
html[data-theme="dark"] .swal2-input:focus,
html[data-theme="dark"] .swal2-select:focus,
html[data-theme="dark"] .swal2-textarea:focus {
  border-color: #130146 !important;
  box-shadow: 0 0 0 .2rem rgba(117,72,237,.2) !important;
}
html[data-theme="dark"] .swal2-close {
  width: 2rem;
  height: 2rem;
  color: #aeb4c2 !important;
  font-size: 1.5rem !important;
  line-height: 2rem;
}
html[data-theme="dark"] .swal2-close:hover { color: #e5e7eb !important; }
html[data-theme="dark"] .modal-content .btn,
html[data-theme="dark"] .swal2-popup .btn,
html[data-theme="dark"] .swal2-actions .swal2-styled {
  min-height: 40px;
  border-radius: 10px;
  padding: .55rem 1rem;
  font-weight: 600;
}
html[data-theme="dark"] .swal2-actions .swal2-confirm {
  background: #130146 !important;
}
html[data-theme="dark"] .swal2-actions .swal2-cancel {
  background: #383a40 !important;
  color: #e5e7eb !important;
}

.card,
.analysis-stat,
.analysis-kpi,
.analysis-opportunity,
.chart-card {
  background-color: var(--ekeko-surface);
  color: var(--ekeko-text);
  border: 1px solid var(--ekeko-border);
  border-radius: var(--ekeko-radius-md);
  box-shadow: var(--ekeko-shadow-sm);
}
html[data-theme="light"] .analysis-kpi,
html[data-theme="light"] .analysis-stat,
html[data-theme="light"] .analysis-opportunity,
html[data-theme="light"] .chart-card,
html[data-theme="dark"] .analysis-kpi,
html[data-theme="dark"] .analysis-stat,
html[data-theme="dark"] .analysis-opportunity,
html[data-theme="dark"] .chart-card {
  background-color: var(--ekeko-surface) !important;
  color: var(--ekeko-text) !important;
  border-color: var(--ekeko-border) !important;
}
.card-header, .card-footer { background-color: transparent; border-color: var(--ekeko-border); }
.text-muted, .analysis-kpi small, .analysis-stat span { color: var(--ekeko-text-muted) !important; }
.analysis-kpi span, .analysis-stat span { color: var(--ekeko-text-muted); }
.analysis-kpi strong, .analysis-stat strong, .analysis-opportunity strong { color: var(--ekeko-text); }

.btn-primary, .btn-ekeko {
  background-color: var(--ekeko-primary) !important;
  border-color: var(--ekeko-primary) !important;
  color: #fff !important;
}
.btn-primary:hover, .btn-ekeko:hover { background-color: var(--ekeko-primary-hover) !important; border-color: var(--ekeko-primary-hover) !important; }
.btn-outline-primary { color: var(--ekeko-primary); border-color: var(--ekeko-primary); }
.btn-outline-primary:hover { background-color: var(--ekeko-primary); border-color: var(--ekeko-primary); color: #fff; }
.btn-outline-secondary, .btn-link { color: var(--ekeko-text-muted); }
.btn-outline-secondary { border-color: var(--ekeko-border); }
.btn-outline-secondary:hover { background-color: var(--ekeko-surface-secondary); border-color: var(--ekeko-primary); color: var(--ekeko-primary); }

.form-control, .form-select, .form-control:focus, .form-select:focus {
  background-color: var(--ekeko-surface);
  color: var(--ekeko-text);
  border-color: var(--ekeko-border);
}
.form-control::placeholder { color: var(--ekeko-text-muted); opacity: .8; }
.form-control:focus, .form-select:focus { border-color: var(--ekeko-primary); box-shadow: 0 0 0 .2rem rgba(117,72,237,.16); }
.form-label { color: var(--ekeko-text-muted); }
.form-select option { background-color: var(--ekeko-surface); color: var(--ekeko-text); }

.table { --bs-table-bg: transparent; --bs-table-color: var(--ekeko-text); --bs-table-border-color: var(--ekeko-border); }
.table thead th { color: var(--ekeko-text-muted); border-bottom-color: var(--ekeko-border); }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: var(--ekeko-surface-secondary); color: var(--ekeko-text); }
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { color: var(--ekeko-text-muted); }
.dataTables_wrapper .pagination .page-link { background-color: var(--ekeko-surface); color: var(--ekeko-text-muted); border-color: var(--ekeko-border); }
.dataTables_wrapper .pagination .page-item.active .page-link { background-color: var(--ekeko-primary); border-color: var(--ekeko-primary); color: #fff; }
.dataTables_wrapper .pagination .page-item.disabled .page-link { background-color: var(--ekeko-surface-secondary); color: var(--ekeko-text-muted); }

.modal-content, .dropdown-menu, .popover {
  background-color: var(--ekeko-surface);
  color: var(--ekeko-text);
  border-color: var(--ekeko-border);
  border-radius: var(--ekeko-radius-md);
  box-shadow: var(--ekeko-shadow-sm);
}
.modal-header, .modal-footer { border-color: var(--ekeko-border); }
.modal-dialog { max-width: min(94vw, 760px); }
.modal-body { color: var(--ekeko-text); }
.modal-content input:not([type="checkbox"]):not([type="radio"]),
.modal-content select,
.modal-content textarea {
  border-radius: 10px;
  border-color: var(--ekeko-border);
}
.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
  border-color: var(--ekeko-primary);
  box-shadow: 0 0 0 .2rem rgba(117,72,237,.16);
}
.modal-header .btn-close {
  width: 1rem;
  height: 1rem;
  padding: .35rem;
  background-size: 1rem;
  opacity: .72;
}
.modal-header .btn-close:hover { opacity: 1; }
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(2); }
html[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.dropdown-item { color: var(--ekeko-text); }
.dropdown-item:hover, .dropdown-item:focus { background-color: var(--ekeko-surface-secondary); color: var(--ekeko-primary); }
.alert { border-radius: var(--ekeko-radius-sm); }
.badge { font-weight: 600; }

/* .nav-contactos { background: color-mix(in srgb, var(--ekeko-surface) 92%, transparent); border-bottom: 1px solid var(--ekeko-border); } */
.rowServ, .controlSelect { background: var(--ekeko-surface-secondary); color: var(--ekeko-text); border-color: var(--ekeko-border); }
.wrapperMenu .item { background: var(--ekeko-surface); color: var(--ekeko-text); border: 1px solid var(--ekeko-border); border-radius: var(--ekeko-radius-sm); }
.wrapperMenu .item:hover, .wrapperMenu .item:focus { color: var(--ekeko-primary); border-color: var(--ekeko-primary); }
.chats { color: var(--ekeko-text); }
.analysis-tag, .analisis-oportunidad-filtro { background: var(--ekeko-surface-secondary); color: var(--ekeko-primary); border-color: var(--ekeko-border); }
.analisis-oportunidad-filtro.active, .analisis-oportunidad-filtro:hover { background: var(--ekeko-primary); color: #fff; border-color: var(--ekeko-primary); }
.analysis-state.state-1 { background: color-mix(in srgb, var(--ekeko-success) 16%, transparent); color: var(--ekeko-success); }
.analysis-state.state-2 { background: color-mix(in srgb, var(--ekeko-warning) 17%, transparent); color: var(--ekeko-warning); }
.analysis-state.state-3 { background: color-mix(in srgb, var(--ekeko-danger) 16%, transparent); color: var(--ekeko-danger); }
.analysis-sheet { background: var(--ekeko-surface) !important; color: var(--ekeko-text); }
.analysis-sheet-header, .analysis-sheet-footer { border-color: var(--ekeko-border) !important; }
.analysis-mobile-nav { background: var(--ekeko-surface) !important; border-top: 1px solid var(--ekeko-border); }
.analysis-mobile-nav a, .analysis-mobile-nav button { color: var(--ekeko-text-muted); }

.ekeko-theme-toggle {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 12px;
  background: rgba(255,255,255,.12);
  color: #fff;
  transition: background-color .15s ease, transform .15s ease;
}
.ekeko-theme-toggle:hover, .ekeko-theme-toggle:focus-visible { background: rgba(255,255,255,.24); color: #fff; transform: translateY(-1px); }
.ekeko-theme-toggle-floating { position: fixed; top: 10px; right: 12px; z-index: 1200; }

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .chat,
html[data-theme="dark"] .chat-list,
html[data-theme="dark"] .headerN,
html[data-theme="dark"] .search,
html[data-theme="dark"] .actions,
html[data-theme="dark"] .searcher,
html[data-theme="dark"] .sidebarChat { background-color: var(--ekeko-surface); color: var(--ekeko-text); }
html[data-theme="dark"] .sidebar { border-color: var(--ekeko-border); }
html[data-theme="dark"] .sidebar a, html[data-theme="dark"] .headerN a { color: var(--ekeko-text); }
html[data-theme="dark"] .chat-list, html[data-theme="dark"] .message-list { background-color: var(--ekeko-surface-secondary); }
html[data-theme="dark"] .searcher input, html[data-theme="dark"] .actions input { background-color: var(--ekeko-surface-secondary); color: var(--ekeko-text); }
html[data-theme="dark"] .message.is-receiver .message-body { background-color: var(--ekeko-surface); color: var(--ekeko-text); }
html[data-theme="dark"] .message.is-sender .message-body { background-color: var(--green10); color: var(--ekeko-text); }
html[data-theme="dark"] .sidebarChat.is-active { background-color: var(--ekeko-primary); color: #fff; }

@media (max-width: 767.98px) {
  .content-wrapper { margin-top: 72px; }
  .card { border-radius: 15px; }
  .analisis-page { color: var(--ekeko-text); }
  .analysis-kpi { min-height: 108px; }
  .ekeko-theme-toggle { width: 36px; height: 36px; }
}
