/* ==========================================================================
   Modo oscuro — MarcadorSoftware
   Se activa con: <html data-theme="oscuro"> (ver app/ui/theme.js).
   Regla de oro: en cada override se define fondo Y texto juntos para
   garantizar contraste (nunca texto oscuro sobre fondo oscuro ni al revés).
   ========================================================================== */

/* --- Paleta oscura (reescribe tokens usados por el resto del CSS) --- */
html[data-theme="oscuro"] {
    color-scheme: dark;
    --mt-color-bg: #0f1115;
    --mt-color-surface: #171a21;
    --mt-color-primary: #0b0d11;
    --mt-color-primary-2: #10141a;
    --mt-color-text: #e8eaed;
    --mt-color-muted: #a2aab5;
    --mt-color-border: #2a303c;
    --mt-color-accent: #ff5c64;
    --mt-color-accent-hover: #ff7a81;
    --mt-color-danger: #ff7a81;
}

/* --- Base --- */
html[data-theme="oscuro"] body,
html[data-theme="oscuro"] .container-fluid {
    background-color: var(--mt-color-bg) !important;
    color: var(--mt-color-text) !important;
}
html[data-theme="oscuro"] a { color: #7ab8ff; }

/* --- Superficies (tarjetas, modales, menús, listas) --- */
html[data-theme="oscuro"] .card,
html[data-theme="oscuro"] .modal-content,
html[data-theme="oscuro"] .dropdown-menu,
html[data-theme="oscuro"] .list-group,
html[data-theme="oscuro"] .list-group-item {
    background-color: var(--mt-color-surface) !important;
    color: var(--mt-color-text) !important;
    border-color: var(--mt-color-border) !important;
}
html[data-theme="oscuro"] .card-header,
html[data-theme="oscuro"] .card-footer {
    background-color: #1c2129 !important;
    border-color: var(--mt-color-border) !important;
    color: var(--mt-color-text) !important;
}
html[data-theme="oscuro"] .modal-header,
html[data-theme="oscuro"] .modal-footer {
    border-color: var(--mt-color-border) !important;
}

/* --- Barras claras forzadas -> oscuras --- */
html[data-theme="oscuro"] .navbar-light,
html[data-theme="oscuro"] .bg-light,
html[data-theme="oscuro"] .bg-white {
    background-color: var(--mt-color-surface) !important;
    color: var(--mt-color-text) !important;
}
html[data-theme="oscuro"] .navbar-brand,
html[data-theme="oscuro"] .navbar-brand a {
    color: var(--mt-color-text) !important;
}
html[data-theme="oscuro"] .navbar-toggler-icon {
    filter: invert(1);
}
html[data-theme="oscuro"] .text-dark { color: var(--mt-color-text) !important; }
html[data-theme="oscuro"] .text-muted { color: var(--mt-color-muted) !important; }

/* --- Formularios --- */
html[data-theme="oscuro"] .form-control,
html[data-theme="oscuro"] .form-select,
html[data-theme="oscuro"] input,
html[data-theme="oscuro"] select,
html[data-theme="oscuro"] textarea {
    background-color: #10141a !important;
    border-color: var(--mt-color-border) !important;
    color: var(--mt-color-text) !important;
}
html[data-theme="oscuro"] .form-control::placeholder,
html[data-theme="oscuro"] input::placeholder { color: var(--mt-color-muted); }
html[data-theme="oscuro"] .form-control:focus,
html[data-theme="oscuro"] input:focus,
html[data-theme="oscuro"] select:focus,
html[data-theme="oscuro"] textarea:focus {
    background-color: #151a22 !important;
    color: var(--mt-color-text) !important;
    border-color: var(--mt-color-accent) !important;
}
html[data-theme="oscuro"] label,
html[data-theme="oscuro"] .form-label { color: var(--mt-color-text) !important; }

/* --- Tablas --- */
html[data-theme="oscuro"] .table {
    --bs-table-bg: transparent;
    color: var(--mt-color-text) !important;
    border-color: var(--mt-color-border) !important;
}
html[data-theme="oscuro"] .table > :not(caption) > * > * {
    background-color: var(--mt-color-surface) !important;
    color: var(--mt-color-text) !important;
    border-color: var(--mt-color-border) !important;
}
html[data-theme="oscuro"] .table-hover tbody tr:hover > * {
    background-color: #232a36 !important;
}
html[data-theme="oscuro"] .tabla-mt thead th { background-color: #10141a !important; color: #fff !important; }
html[data-theme="oscuro"] .tabla-mt tbody tr:hover { background: rgba(255, 92, 100, .12) !important; }

/* --- Dropdowns / menús --- */
html[data-theme="oscuro"] .dropdown-item { color: var(--mt-color-text) !important; }
html[data-theme="oscuro"] .dropdown-item:hover,
html[data-theme="oscuro"] .dropdown-item:focus { background-color: #232a36 !important; color: #fff !important; }
html[data-theme="oscuro"] .dropdown-divider { border-color: var(--mt-color-border); }

/* --- Componentes propios de la app --- */
html[data-theme="oscuro"] .estado-vacio,
html[data-theme="oscuro"] .estado-error,
html[data-theme="oscuro"] .tiempos-vacio { color: var(--mt-color-muted) !important; }

html[data-theme="oscuro"] .tiempo-row { border-color: var(--mt-color-border) !important; }
html[data-theme="oscuro"] .tiempo-idx,
html[data-theme="oscuro"] .tiempo-unit { color: var(--mt-color-muted) !important; }
html[data-theme="oscuro"] .tiempo-field input { background-color: #10141a !important; color: var(--mt-color-text) !important; }

html[data-theme="oscuro"] .tiempo-seccion-head { background: rgba(255, 255, 255, .05) !important; }

/* Modal de cabecera negro: ya es oscuro, mantener borde coherente */
html[data-theme="oscuro"] .CabezaModal { background: #0b0d11 !important; }

/* --- Login: fondo y textos legibles --- */
html[data-theme="oscuro"] .login-etiqueta,
html[data-theme="oscuro"] .login-forma label { color: var(--mt-color-text) !important; }
html[data-theme="oscuro"] .contenedor_login_cuadro { background-color: var(--mt-color-surface) !important; }
html[data-theme="oscuro"] .input_login { background-color: #fff; color: #111; }

/* --- Botón del toggle --- */
#mtTemaBtn {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    background: var(--mt-color-accent, #d9202b);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
    cursor: pointer;
}
#mtTemaBtn:hover { background: var(--mt-color-accent-hover, #b8151f); }
