/* ============================================================
   TEMA GLOBAL - Base oscura
   Reglas genéricas para fondos, textos, formularios y tablas.
   Solo se aplican cuando html[data-theme="dark"].
   ============================================================ */

html[data-theme="dark"],
html[data-theme="dark"] body {
    background-color: var(--bg-app) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .main-layout,
html[data-theme="dark"] .content,
html[data-theme="dark"] .content.cuerpo,
html[data-theme="dark"] .cuerpo,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .contenido-subdireccion,
html[data-theme="dark"] #main-content {
    background-color: var(--bg-app) !important;
    color: var(--text-primary) !important;
}

/* ---------- Superficies comunes ---------- */
html[data-theme="dark"] .card,
html[data-theme="dark"] .container,
html[data-theme="dark"] .container-info,
html[data-theme="dark"] .recuadro,
html[data-theme="dark"] .contentt,
html[data-theme="dark"] .containerr,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .panel-card,
html[data-theme="dark"] .box,
html[data-theme="dark"] .surface,
html[data-theme="dark"] .table-container,
html[data-theme="dark"] .table-wrapper,
html[data-theme="dark"] .table-wrapper--premium,
html[data-theme="dark"] .table-card,
html[data-theme="dark"] .filters-container,
html[data-theme="dark"] .filter-section,
html[data-theme="dark"] .cohort-filters,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .action-dropdown,
html[data-theme="dark"] .details-tooltip,
html[data-theme="dark"] .ui-timepicker-list,
html[data-theme="dark"] .combo-menu,
html[data-theme="dark"] .summary-card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .detail-chip,
html[data-theme="dark"] .source-card__item,
html[data-theme="dark"] .readonly-box,
html[data-theme="dark"] .kebab-btn,
html[data-theme="dark"] .user-info-card,
html[data-theme="dark"] .user-academic-card,
html[data-theme="dark"] .action-card,
html[data-theme="dark"] .attendance-section,
html[data-theme="dark"] .program-group,
html[data-theme="dark"] .program-header,
html[data-theme="dark"] .ficha-card,
html[data-theme="dark"] .table-card-header,
html[data-theme="dark"] .attendance-table-wrapper,
html[data-theme="dark"] .edit-form-card,
html[data-theme="dark"] .password-form-card,
html[data-theme="dark"] .edit-info-card,
html[data-theme="dark"] .password-info-card,
html[data-theme="dark"] .profile-edit-main-card,
html[data-theme="dark"] .ep-card,
html[data-theme="dark"] .caas-container,
html[data-theme="dark"] .caas-form,
html[data-theme="dark"] .caas-form-container,
html[data-theme="dark"] .caas-progress-container,
html[data-theme="dark"] .plant-hours-summary,
html[data-theme="dark"] .plant-hours-table-wrap,
html[data-theme="dark"] .type-card,
html[data-theme="dark"] .day-selector label,
html[data-theme="dark"] .ep-btn-outline,
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-cancel,
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .disponible-badge,
html[data-theme="dark"] .ep-badge-code,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] .competency-search-input {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Superficies secundarias */
html[data-theme="dark"] .filters-container,
html[data-theme="dark"] .filter-section,
html[data-theme="dark"] .container-title-form,
html[data-theme="dark"] .table-wrapper--premium,
html[data-theme="dark"] .table-card-header,
html[data-theme="dark"] .program-header,
html[data-theme="dark"] .user-academic-card,
html[data-theme="dark"] .profile-edit-main-card .form-section,
html[data-theme="dark"] .caas-form-container,
html[data-theme="dark"] .caas-days-grid,
html[data-theme="dark"] .caas-excel-section,
html[data-theme="dark"] .source-card__item,
html[data-theme="dark"] .day-selector label,
html[data-theme="dark"] .ep-badge-code,
html[data-theme="dark"] .disponible-badge,
html[data-theme="dark"] .page-info,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .no-records,
html[data-theme="dark"] .is-empty {
    background-color: var(--bg-surface-2) !important;
}

/* ---------- Textos ---------- */
html[data-theme="dark"] .content h1,
html[data-theme="dark"] .content h2,
html[data-theme="dark"] .content h3,
html[data-theme="dark"] .content h4,
html[data-theme="dark"] .content h5,
html[data-theme="dark"] .content h6,
html[data-theme="dark"] .main-content h1,
html[data-theme="dark"] .main-content h2,
html[data-theme="dark"] .main-content h3,
html[data-theme="dark"] .main-content h4,
html[data-theme="dark"] .main-content h5,
html[data-theme="dark"] .main-content h6 {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .content p,
html[data-theme="dark"] .content label,
html[data-theme="dark"] .content li,
html[data-theme="dark"] .content small,
html[data-theme="dark"] .content td,
html[data-theme="dark"] .content th,
html[data-theme="dark"] .main-content p,
html[data-theme="dark"] .main-content label,
html[data-theme="dark"] .main-content li {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .texto,
html[data-theme="dark"] .title,
html[data-theme="dark"] .title-dash,
html[data-theme="dark"] .section-title,
html[data-theme="dark"] .table-title,
html[data-theme="dark"] .table-title span,
html[data-theme="dark"] .user-detail-value,
html[data-theme="dark"] .truncate-tooltip,
html[data-theme="dark"] .panel-card__header h2,
html[data-theme="dark"] .hero-card h1,
html[data-theme="dark"] .reprogramming-hero h1,
html[data-theme="dark"] .stat-value,
html[data-theme="dark"] .summary-card__value,
html[data-theme="dark"] .stat-card__value,
html[data-theme="dark"] .competence-name,
html[data-theme="dark"] .action-label,
html[data-theme="dark"] .action-description,
html[data-theme="dark"] .noticia p,
html[data-theme="dark"] .welcome-subtitle,
html[data-theme="dark"] .user-detail-label,
html[data-theme="dark"] .history-pagination-summary {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .small-text,
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .stat-label,
html[data-theme="dark"] .stat-card__label,
html[data-theme="dark"] .summary-card__label,
html[data-theme="dark"] .summary-card__meta,
html[data-theme="dark"] .stat-card__meta,
html[data-theme="dark"] .panel-card__header p,
html[data-theme="dark"] .section-subtitle,
html[data-theme="dark"] .helper-text,
html[data-theme="dark"] .warning-text,
html[data-theme="dark"] .history-empty,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .page-description,
html[data-theme="dark"] .pagination-info,
html[data-theme="dark"] .details-label,
html[data-theme="dark"] .details-item,
html[data-theme="dark"] .details-empty,
html[data-theme="dark"] .notification-message,
html[data-theme="dark"] .notification-time,
html[data-theme="dark"] .notification-empty,
html[data-theme="dark"] .verify-email-help {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] a:not(.btn):not(.action-btn):not(.menu-toggle):not(.noticia):not(.logout-button):not([class*="btn"]) {
    color: var(--accent-text);
}

html[data-theme="dark"] .back-link,
html[data-theme="dark"] .view-all,
html[data-theme="dark"] .ep-action-link,
html[data-theme="dark"] .history-pagination-link {
    color: var(--accent-text) !important;
}

html[data-theme="dark"] hr,
html[data-theme="dark"] .divider {
    border-color: var(--border-color) !important;
}

/* ---------- Formularios ---------- */
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="file"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .data-input,
html[data-theme="dark"] .caas-input,
html[data-theme="dark"] .caas-select,
html[data-theme="dark"] .filter-input,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] .input-fecha,
html[data-theme="dark"] .timepicker,
html[data-theme="dark"] .large-input,
html[data-theme="dark"] .medium-input,
html[data-theme="dark"] .short-input,
html[data-theme="dark"] .programa,
html[data-theme="dark"] .ep-field input,
html[data-theme="dark"] .ep-field select,
html[data-theme="dark"] .ep-field textarea,
html[data-theme="dark"] .form-field input,
html[data-theme="dark"] .form-field select,
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group select,
html[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] .filter-group input,
html[data-theme="dark"] .filter-group select {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--input-border) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .form-input::placeholder,
html[data-theme="dark"] .data-input::placeholder {
    color: var(--text-muted) !important;
    opacity: 1;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] .form-input:focus,
html[data-theme="dark"] .data-input:focus,
html[data-theme="dark"] .caas-input:focus,
html[data-theme="dark"] .caas-select:focus,
html[data-theme="dark"] .filter-input:focus,
html[data-theme="dark"] .search-input:focus,
html[data-theme="dark"] .form-field input:focus,
html[data-theme="dark"] .form-field select:focus,
html[data-theme="dark"] .ep-field input:focus,
html[data-theme="dark"] .ep-field select:focus {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--input-focus) !important;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.16) !important;
}

html[data-theme="dark"] input:disabled,
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] textarea:disabled,
html[data-theme="dark"] .form-input-disabled,
html[data-theme="dark"] .edit-profile-page .form-group.readonly input,
html[data-theme="dark"] .profile-edit-main-card .form-input-disabled {
    background-color: var(--bg-surface-2) !important;
    color: var(--text-muted) !important;
    border-color: var(--border-color) !important;
    opacity: 1;
}

html[data-theme="dark"] select option {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"] {
    accent-color: var(--accent);
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill {
    -webkit-text-fill-color: var(--text-primary) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset !important;
    caret-color: var(--text-primary);
}

/* ---------- Tablas ---------- */
html[data-theme="dark"] table {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] thead,
html[data-theme="dark"] thead tr,
html[data-theme="dark"] table th {
    background-color: var(--table-head-bg) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] tbody tr {
    background-color: transparent;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.015);
}

html[data-theme="dark"] tbody tr:hover,
html[data-theme="dark"] .attendance-table tbody tr:hover {
    background-color: var(--table-row-hover) !important;
}

html[data-theme="dark"] td,
html[data-theme="dark"] th {
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] table tbody td,
html[data-theme="dark"] table tbody th {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .apprentice-count,
html[data-theme="dark"] .ficha-pill,
html[data-theme="dark"] .date-pill {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .empty-row td,
html[data-theme="dark"] .empty-programming-row td,
html[data-theme="dark"] .attendance-record {
    background-color: var(--bg-surface) !important;
    color: var(--text-muted) !important;
}

/* Celdas de tablas con fondo propio (páginas con CSS heredado) */
html[data-theme="dark"] .table-container table tbody td:not([class]),
html[data-theme="dark"] .table-wrapper table tbody td:not([class]),
html[data-theme="dark"] .table-wrapper--premium table tbody td:not([class]) {
    background-color: var(--table-row-bg) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .table-container table tbody tr:nth-child(even) td:not([class]),
html[data-theme="dark"] .table-wrapper table tbody tr:nth-child(even) td:not([class]),
html[data-theme="dark"] .table-wrapper--premium table tbody tr:nth-child(even) td:not([class]) {
    background-color: var(--bg-surface-2) !important;
}

html[data-theme="dark"] .table-container table tbody tr:hover td:not([class]),
html[data-theme="dark"] .table-wrapper table tbody tr:hover td:not([class]),
html[data-theme="dark"] .table-wrapper--premium table tbody tr:hover td:not([class]) {
    background-color: var(--table-row-hover) !important;
}

/* ---------- Alertas y mensajes ---------- */
html[data-theme="dark"] .alert,
html[data-theme="dark"] .alert-success,
html[data-theme="dark"] .success-message,
html[data-theme="dark"] .alert-box--success,
html[data-theme="dark"] .ep-alert-success {
    background-color: var(--success-bg) !important;
    color: var(--success-text) !important;
    border-color: rgba(74, 222, 128, 0.35) !important;
}

html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .alert-error,
html[data-theme="dark"] .error-message,
html[data-theme="dark"] .error-list,
html[data-theme="dark"] .alert-box--error,
html[data-theme="dark"] .ep-alert-error,
html[data-theme="dark"] .ep-errors {
    background-color: var(--danger-bg) !important;
    color: var(--danger-text) !important;
    border-color: rgba(248, 113, 113, 0.35) !important;
}

html[data-theme="dark"] .alert-warning,
html[data-theme="dark"] .alert-box--warning,
html[data-theme="dark"] .password-notice,
html[data-theme="dark"] .verify-email-notice {
    background-color: var(--warning-bg) !important;
    color: var(--warning-text) !important;
    border-color: rgba(251, 191, 36, 0.35) !important;
}

html[data-theme="dark"] .alert-info,
html[data-theme="dark"] .alert-box--info {
    background-color: var(--info-bg) !important;
    color: var(--info-text) !important;
    border-color: rgba(96, 165, 250, 0.35) !important;
}

html[data-theme="dark"] .password-notice__title {
    color: var(--warning-text) !important;
}

html[data-theme="dark"] .password-notice__text {
    color: var(--text-secondary) !important;
}

/* ---------- Botones sólidos: el texto debe seguir siendo blanco ---------- */
html[data-theme="dark"] .filters-container .btn-filter,
html[data-theme="dark"] .change-password-page .submit-btn,
html[data-theme="dark"] .edit-profile-page .submit-btn,
html[data-theme="dark"] #historySection .history-pagination-link.is-active,
html[data-theme="dark"] .logout-button {
    color: #ffffff !important;
}

/* ---------- Paginación ---------- */
html[data-theme="dark"] .pagination-container {
    background-color: var(--bg-surface) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .pagination a,
html[data-theme="dark"] .pagination span,
html[data-theme="dark"] .page-link,
html[data-theme="dark"] .history-pagination-link,
html[data-theme="dark"] .ep-pagination a,
html[data-theme="dark"] .ep-pagination span,
html[data-theme="dark"] .assign-pagination__btn {
    background-color: var(--bg-surface) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

html[data-theme="dark"] .pagination a:hover,
html[data-theme="dark"] .page-link:hover,
html[data-theme="dark"] .history-pagination-link:hover,
html[data-theme="dark"] .ep-pagination a:hover,
html[data-theme="dark"] .assign-pagination__btn:hover {
    background-color: var(--hover-bg) !important;
    color: var(--accent-text) !important;
}

/* ---------- Scrollbars ---------- */
html[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--scrollbar-track) !important;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb) !important;
    border-color: var(--scrollbar-track) !important;
}

html[data-theme="dark"] * {
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ---------- Seguridad para estilos inline heredados ---------- */
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background-color: white"],
html[data-theme="dark"] [style*="background-color:white"],
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background-color:#fff"],
html[data-theme="dark"] [style*="background-color: #ffffff"],
html[data-theme="dark"] [style*="background-color:#ffffff"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background-color: #f8fafc"],
html[data-theme="dark"] [style*="background-color:#f8fafc"],
html[data-theme="dark"] [style*="background: #f1f5f9"],
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background-color: #f1f5f9"],
html[data-theme="dark"] [style*="background-color:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f9fafb"],
html[data-theme="dark"] [style*="background:#f9fafb"],
html[data-theme="dark"] [style*="background-color: #f9fafb"],
html[data-theme="dark"] [style*="background-color:#f9fafb"],
html[data-theme="dark"] [style*="background: #f7fafc"],
html[data-theme="dark"] [style*="background:#f7fafc"],
html[data-theme="dark"] [style*="background-color: #f7fafc"],
html[data-theme="dark"] [style*="background-color:#f7fafc"],
html[data-theme="dark"] [style*="background: #f7f9fc"],
html[data-theme="dark"] [style*="background:#f7f9fc"],
html[data-theme="dark"] [style*="background: #fafafa"],
html[data-theme="dark"] [style*="background:#fafafa"],
html[data-theme="dark"] [style*="background: #f5f7f9"],
html[data-theme="dark"] [style*="background:#f5f7f9"],
html[data-theme="dark"] [style*="background: #eef2f7"],
html[data-theme="dark"] [style*="background:#eef2f7"],
html[data-theme="dark"] [style*="background-color: #39A900"],
html[data-theme="dark"] [style*="background-color:#39A900"],
html[data-theme="dark"] [style*="background: #39A900"],
html[data-theme="dark"] [style*="background:#39A900"],
html[data-theme="dark"] [style*="background-color: #39a900"],
html[data-theme="dark"] [style*="background-color:#39a900"],
html[data-theme="dark"] [style*="background: #39a900"],
html[data-theme="dark"] [style*="background:#39a900"] {
    background-color: var(--bg-surface) !important;
}

html[data-theme="dark"] [style*="background-color: #39A900"],
html[data-theme="dark"] [style*="background-color:#39A900"],
html[data-theme="dark"] [style*="background: #39A900"],
html[data-theme="dark"] [style*="background:#39A900"],
html[data-theme="dark"] [style*="background-color: #39a900"],
html[data-theme="dark"] [style*="background-color:#39a900"],
html[data-theme="dark"] [style*="background: #39a900"],
html[data-theme="dark"] [style*="background:#39a900"] {
    background-color: #2f7a00 !important;
    color: #ffffff !important;
}

html[data-theme="dark"] [style*="color: #333"],
html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color: #2c3e50"],
html[data-theme="dark"] [style*="color:#2c3e50"],
html[data-theme="dark"] [style*="color: #1f2937"],
html[data-theme="dark"] [style*="color:#1f2937"],
html[data-theme="dark"] [style*="color: #374151"],
html[data-theme="dark"] [style*="color:#374151"],
html[data-theme="dark"] [style*="color: #4b5563"],
html[data-theme="dark"] [style*="color:#4b5563"],
html[data-theme="dark"] [style*="color: #6b7280"],
html[data-theme="dark"] [style*="color:#6b7280"],
html[data-theme="dark"] [style*="color: #64748b"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #718096"],
html[data-theme="dark"] [style*="color:#718096"],
html[data-theme="dark"] [style*="color: #2d3748"],
html[data-theme="dark"] [style*="color:#2d3748"],
html[data-theme="dark"] [style*="color: #1e293b"],
html[data-theme="dark"] [style*="color:#1e293b"],
html[data-theme="dark"] [style*="color: #1a202c"],
html[data-theme="dark"] [style*="color:#1a202c"],
html[data-theme="dark"] [style*="color: #24323d"],
html[data-theme="dark"] [style*="color:#24323d"],
html[data-theme="dark"] [style*="color: #334155"],
html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color: #306291"],
html[data-theme="dark"] [style*="color:#306291"],
html[data-theme="dark"] [style*="color: #1e4b7a"],
html[data-theme="dark"] [style*="color:#1e4b7a"],
html[data-theme="dark"] [style*="color: #475569"],
html[data-theme="dark"] [style*="color:#475569"],
html[data-theme="dark"] [style*="color: #000"],
html[data-theme="dark"] [style*="color:#000"],
html[data-theme="dark"] [style*="color: black"],
html[data-theme="dark"] [style*="color:black"] {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] [style*="color: #999"],
html[data-theme="dark"] [style*="color:#999"],
html[data-theme="dark"] [style*="color: #777"],
html[data-theme="dark"] [style*="color:#777"],
html[data-theme="dark"] [style*="color: #666"],
html[data-theme="dark"] [style*="color:#666"],
html[data-theme="dark"] [style*="color: #888"],
html[data-theme="dark"] [style*="color:#888"] {
    color: var(--text-muted) !important;
}

/* Impresión y PDF: siempre en claro */
@media print {
    html,
    html[data-theme="dark"],
    html[data-theme="dark"] body {
        background: #ffffff !important;
        color: #000000 !important;
        color-scheme: light !important;
    }

    .theme-toggle,
    .sidebar,
    .header {
        display: none !important;
    }
}
