/* e-gym - Dark mode overrides
 * Los tokens de app-tokens.css manejan la mayoría del dark mode automáticamente.
 * Este archivo solo cubre overrides para componentes que no usan tokens directamente.
 */

/* Logo switching */
.logo-brand { position: relative; display: inline-flex; align-items: center; }
.logo-brand .logo-dark { display: none; }
.logo-brand .logo-light { display: inline; }
html.theme-dark .logo-brand .logo-light,
html[data-theme="dark"] .logo-brand .logo-light { display: none; }
html.theme-dark .logo-brand .logo-dark,
html[data-theme="dark"] .logo-brand .logo-dark { display: inline; }

/* Legacy variable bridge */
html.theme-dark,
html[data-theme="dark"] {
    --primary-color: var(--egym-primary);
    --secondary-color: var(--egym-text-muted);
    --light-gray: var(--egym-bg);
    --dark-gray: var(--egym-text);
    --bg-card: var(--egym-surface-elevated);
    --bg-elevated: var(--egym-surface-hover);
    --border-dark: var(--egym-border);
    --admin-content-bg: var(--egym-bg);
    --admin-card-bg: var(--egym-surface);
    --admin-border: var(--egym-border);
    --admin-text-muted: var(--egym-text-muted);
}

/* Body */
html.theme-dark body,
html[data-theme="dark"] body { background-color: var(--egym-bg); color: var(--egym-text); }

/* Text overrides for Bootstrap utility classes */
html.theme-dark a.text-dark,
html.theme-dark .text-dark { color: var(--egym-text) !important; }
html.theme-dark .text-muted { color: var(--egym-text-muted) !important; }

/* ===== Buttons ===== */
html.theme-dark .btn-primary,
html[data-theme="dark"] .btn-primary {
    background: var(--egym-gradient) !important;
    border: none !important;
    color: #fff !important;
    box-shadow: var(--egym-shadow-glow);
}
html.theme-dark .btn-primary:hover,
html[data-theme="dark"] .btn-primary:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4) !important;
}

html.theme-dark .btn-success,
html[data-theme="dark"] .btn-success {
    background: linear-gradient(135deg, #34d399 0%, #059669 100%) !important;
    border: none !important; color: #fff !important;
}

html.theme-dark .btn-outline-secondary {
    border-color: var(--egym-border);
    color: var(--egym-text-muted);
}
html.theme-dark .btn-outline-secondary:hover {
    background: var(--egym-surface-hover);
    border-color: var(--egym-border-hover);
    color: var(--egym-text);
}

html.theme-dark .btn-outline-primary { border-color: var(--egym-primary); color: var(--egym-primary); }
html.theme-dark .btn-outline-primary:hover { background: #0d9488; border-color: #0d9488; color: #fff; }
html.theme-dark .btn-outline-danger { border-color: var(--egym-danger); color: var(--egym-danger); }
html.theme-dark .btn-outline-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }

html.theme-dark .btn-outline-secondary.btn-icon {
    border-color: var(--egym-border-hover);
    color: var(--egym-text-muted);
}
html.theme-dark .btn-outline-secondary.btn-icon:hover:not(:disabled) {
    background: var(--egym-surface-hover);
    color: var(--egym-text);
}

html.theme-dark .admin .btn-secondary,
html[data-theme="dark"] .admin .btn-secondary {
    background: var(--egym-surface-hover) !important;
    border-color: var(--egym-border) !important;
    color: var(--egym-text) !important;
}
html.theme-dark .admin .btn-secondary:hover,
html[data-theme="dark"] .admin .btn-secondary:hover {
    background: var(--egym-border-hover) !important;
    color: #fff !important;
}

/* ===== Day buttons ===== */
html.theme-dark .day-btn {
    border-color: var(--egym-border);
    background: var(--egym-surface);
    color: var(--egym-text-muted);
}
html.theme-dark .day-btn.active {
    background: var(--egym-gradient);
    color: #fff;
    border-color: transparent;
}

html.theme-dark .running-btn { background: var(--egym-gradient) !important; border-color: transparent !important; }
html.theme-dark .exercise-btn { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important; border-color: transparent !important; }

/* ===== Dropdowns ===== */
html.theme-dark .dropdown-menu {
    background: var(--egym-surface);
    border-color: var(--egym-border);
    box-shadow: var(--egym-shadow-lg);
}
html.theme-dark .dropdown-item { color: var(--egym-text); }
html.theme-dark .dropdown-item:hover { background: var(--egym-surface-hover); color: #fff; }
html.theme-dark .dropdown-divider { border-color: var(--egym-border); }
html.theme-dark .dropdown-header,
html[data-theme="dark"] .dropdown-header { color: var(--egym-text-muted) !important; background: transparent !important; }
html.theme-dark .dropdown-header .btn-link,
html[data-theme="dark"] .dropdown-header .btn-link { color: var(--egym-primary) !important; text-decoration: none; }

/* ===== Notifications ===== */
html.theme-dark .notif-unread,
html[data-theme="dark"] .notif-unread { background: var(--egym-surface-elevated) !important; color: var(--egym-text) !important; border-left: 3px solid var(--egym-primary); }
html.theme-dark .notif-unread:hover,
html[data-theme="dark"] .notif-unread:hover { background: var(--egym-surface-hover) !important; }

/* ===== Exercise items ===== */
html.theme-dark .exercise-item {
    background: var(--egym-surface);
    border-color: var(--egym-border);
}
html.theme-dark .exercise-item:hover {
    border-color: var(--egym-border-hover);
    background: var(--egym-surface) !important;
}
html.theme-dark .exercise-thumbnail-fallback {
    background: linear-gradient(135deg, var(--egym-surface-elevated) 0%, var(--egym-border-hover) 100%);
}
html.theme-dark .exercise-name,
html[data-theme="dark"] .exercise-name { color: var(--egym-text) !important; }
html.theme-dark .exercise-name:hover { color: var(--egym-primary) !important; }
html.theme-dark .exercise-weight-input {
    border-color: var(--egym-border);
    background: var(--egym-bg);
    color: var(--egym-text);
}
html.theme-dark .exercise-weight-input:focus {
    border-color: var(--egym-primary);
    box-shadow: 0 0 0 3px var(--egym-primary-muted);
}
html.theme-dark .exercise-item-add { border-color: var(--egym-border); background: transparent; }
html.theme-dark .exercise-card { background: var(--egym-surface); }

/* ===== Forms ===== */
html.theme-dark .form-control,
html.theme-dark .form-select {
    background: var(--egym-bg);
    border-color: var(--egym-border);
    color: var(--egym-text);
}
html.theme-dark .form-control:focus,
html.theme-dark .form-select:focus {
    background: var(--egym-surface);
    border-color: var(--egym-primary);
    box-shadow: 0 0 0 3px var(--egym-primary-muted);
    color: var(--egym-text);
}
html.theme-dark .form-control::placeholder { color: var(--egym-text-muted); }
html.theme-dark .form-select option { background: var(--egym-bg); color: var(--egym-text); }

/* ===== Cards ===== */
html.theme-dark .card { background: var(--egym-surface); border-color: var(--egym-border); }
html.theme-dark .card-header { background: var(--egym-surface-elevated); border-color: var(--egym-border); color: var(--egym-text); }
html.theme-dark .card-body { color: var(--egym-text); }

/* ===== Tables ===== */
html.theme-dark .table,
html[data-theme="dark"] .table {
    --bs-table-bg: transparent !important;
    --bs-table-border-color: var(--egym-border) !important;
    color: var(--egym-text) !important;
}
html.theme-dark .table thead th,
html[data-theme="dark"] .table thead th {
    background: var(--egym-surface-elevated) !important;
    color: var(--egym-text-muted) !important;
    border-color: var(--egym-border) !important;
}
html.theme-dark .table tbody td,
html[data-theme="dark"] .table tbody td {
    background: var(--egym-surface) !important;
    color: var(--egym-text) !important;
    border-color: var(--egym-border) !important;
}
html.theme-dark .table tbody tr:nth-of-type(even) td,
html[data-theme="dark"] .table tbody tr:nth-of-type(even) td { background: var(--egym-surface-elevated) !important; }
html.theme-dark .table-hover tbody tr:hover td,
html[data-theme="dark"] .table-hover tbody tr:hover td { background: var(--egym-surface-hover) !important; }

/* ===== Modals ===== */
html.theme-dark .modal-content { background: var(--egym-surface); border-color: var(--egym-border); }
html.theme-dark .modal-header { border-color: var(--egym-border); color: var(--egym-text-heading); }
html.theme-dark .modal-header .btn-close,
html.theme-dark .modal .btn-close,
html[data-theme="dark"] .modal .btn-close { filter: invert(1); }
html.theme-dark .modal-body { color: var(--egym-text); }
html.theme-dark .modal-footer { border-color: var(--egym-border); }
html.theme-dark .modal .form-label,
html[data-theme="dark"] .modal .form-label { color: var(--egym-text) !important; }

/* ===== Borders ===== */
html.theme-dark .border,
html.theme-dark .border-top,
html.theme-dark .border-bottom { border-color: var(--egym-border) !important; }

/* ===== Toast ===== */
html.theme-dark .toast { background: var(--egym-surface); border-color: var(--egym-border); }
html.theme-dark .toast-body { color: var(--egym-text); }

/* ===== Tabs ===== */
html.theme-dark .nav-tabs .nav-link { color: var(--egym-text-muted); border-color: transparent; }
html.theme-dark .nav-tabs .nav-link.active {
    background: transparent;
    border-bottom-color: var(--egym-primary);
    color: var(--egym-primary);
}
html.theme-dark .nav-tabs { border-color: var(--egym-border); }

/* ===== Nav btn ===== */
html.theme-dark .nav-btn:disabled { background: var(--egym-border-hover); color: var(--egym-text-muted); box-shadow: none; }

/* ===== Add ejercicio ===== */
html.theme-dark .add-ejercicio-row {
    background: var(--egym-surface-elevated);
    border-color: var(--egym-border);
}

/* ===== Peso corporal ===== */
html.theme-dark #screenPesoCorporal .card,
html.theme-dark #screenPesoCorporal .card-body { background: var(--egym-surface) !important; color: var(--egym-text) !important; }
html.theme-dark #screenPesoCorporal .card-header { background: var(--egym-surface-elevated) !important; border-color: var(--egym-border) !important; }

/* ===== Login ===== */
html.theme-dark body.login-page { background: var(--egym-bg); color: var(--egym-text); }
html.theme-dark .login-card { background: var(--egym-surface); border-color: var(--egym-border); box-shadow: var(--egym-shadow-lg); }
html.theme-dark .login-body { background: var(--egym-surface); color: var(--egym-text); }
html.theme-dark .login-body .form-label { color: var(--egym-text-muted); }
html.theme-dark .login-body .alert-danger { background: var(--egym-danger-muted); border-color: var(--egym-danger); color: var(--egym-danger); }

/* ===== Nutrition / Running ===== */
html.theme-dark .nutrition-content { background: var(--egym-surface); border-color: var(--egym-border); }
html.theme-dark .nutrition-meal { background: var(--egym-surface-elevated); border-color: var(--egym-border); }
html.theme-dark .nutrition-highlight { background: var(--egym-success-muted); border-color: var(--egym-success); }
html.theme-dark .nutrition-avoid { background: var(--egym-danger-muted); border-color: var(--egym-danger); }
html.theme-dark .nutrition-include { background: var(--egym-primary-muted); border-color: var(--egym-primary); }
html.theme-dark .nutrition-tip { background: var(--egym-warning-muted); }
html.theme-dark .nutrition-note { background: var(--egym-primary-muted); }
html.theme-dark .running-view .nutrition-meal.running-stage-active {
    background: var(--egym-primary-muted);
    border-color: var(--egym-primary);
    box-shadow: 0 0 0 1px var(--egym-primary);
}

/* ===== Admin / Profesor dark ===== */
html.theme-dark body.admin,
html[data-theme="dark"] body.admin { background: var(--egym-bg) !important; color: var(--egym-text) !important; }
html.theme-dark .admin-content,
html[data-theme="dark"] .admin-content { background: var(--egym-bg) !important; }
html.theme-dark .admin-page-header h4,
html[data-theme="dark"] .admin-page-header h4 { color: var(--egym-text-heading) !important; }
html.theme-dark .admin-card,
html[data-theme="dark"] .admin-card { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin-card .card-header,
html[data-theme="dark"] .admin-card .card-header { background: var(--egym-surface-elevated) !important; border-color: var(--egym-border) !important; color: var(--egym-text) !important; }
html.theme-dark .admin-card .card-body,
html[data-theme="dark"] .admin-card .card-body { background: var(--egym-surface) !important; color: var(--egym-text) !important; }

/* Admin tables dark */
html.theme-dark .admin-table th,
html[data-theme="dark"] .admin-table th { background: var(--egym-surface-elevated) !important; color: var(--egym-text-muted) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin-table td,
html[data-theme="dark"] .admin-table td { color: var(--egym-text) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin-table tbody tr:hover,
html[data-theme="dark"] .admin-table tbody tr:hover { background: var(--egym-surface-hover) !important; }
html.theme-dark .admin-table tbody tr,
html[data-theme="dark"] .admin-table tbody tr { background: var(--egym-surface) !important; }
html.theme-dark .admin-table tbody tr:nth-of-type(even),
html[data-theme="dark"] .admin-table tbody tr:nth-of-type(even) { background: var(--egym-surface-elevated) !important; }

/* Admin forms dark */
html.theme-dark .admin-search,
html.theme-dark .admin .form-control,
html.theme-dark .admin .form-select,
html[data-theme="dark"] .admin-search,
html[data-theme="dark"] .admin .form-control,
html[data-theme="dark"] .admin .form-select { background: var(--egym-bg) !important; border-color: var(--egym-border) !important; color: var(--egym-text) !important; }
html.theme-dark .admin-search::placeholder,
html.theme-dark .admin .form-control::placeholder,
html[data-theme="dark"] .admin .form-control::placeholder { color: var(--egym-text-muted) !important; }
html.theme-dark .admin-results-count,
html[data-theme="dark"] .admin-results-count { color: var(--egym-text-muted) !important; }

/* Admin modals dark */
html.theme-dark .admin .modal-content,
html[data-theme="dark"] .admin .modal-content { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin .modal-header,
html[data-theme="dark"] .admin .modal-header { background: var(--egym-surface-elevated) !important; border-color: var(--egym-border) !important; color: var(--egym-text-heading) !important; }
html.theme-dark .admin .modal-body,
html[data-theme="dark"] .admin .modal-body { background: var(--egym-surface) !important; color: var(--egym-text) !important; }
html.theme-dark .admin .modal-footer,
html[data-theme="dark"] .admin .modal-footer { background: var(--egym-surface-elevated) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin .form-label,
html[data-theme="dark"] .admin .form-label { color: var(--egym-text) !important; }

/* Admin detail dark */
html.theme-dark .admin-user-detail .detail-label,
html[data-theme="dark"] .admin-user-detail .detail-label { color: var(--egym-text-muted) !important; }
html.theme-dark .admin-user-detail .detail-value,
html[data-theme="dark"] .admin-user-detail .detail-value { color: var(--egym-text) !important; }
html.theme-dark .admin-user-detail .detail-row,
html[data-theme="dark"] .admin-user-detail .detail-row { border-color: var(--egym-border) !important; }

/* Admin day columns dark */
html.theme-dark .admin-day-col,
html[data-theme="dark"] .admin-day-col { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin-exercise-item,
html[data-theme="dark"] .admin-exercise-item { background: var(--egym-surface-elevated) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin-exercise-name,
html[data-theme="dark"] .admin-exercise-name { color: var(--egym-text) !important; }
html.theme-dark .admin-exercise-meta,
html[data-theme="dark"] .admin-exercise-meta { color: var(--egym-text-muted) !important; }
html.theme-dark .admin-day-empty,
html[data-theme="dark"] .admin-day-empty { color: var(--egym-text-muted) !important; }

/* Admin evolucion dark */
html.theme-dark .admin-evolucion-ejercicio,
html[data-theme="dark"] .admin-evolucion-ejercicio { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin-evolucion-ejercicio .card-header,
html[data-theme="dark"] .admin-evolucion-ejercicio .card-header { background: var(--egym-surface-elevated) !important; color: var(--egym-text) !important; }
html.theme-dark .admin-evolucion-accordion-item .accordion-button,
html[data-theme="dark"] .admin-evolucion-accordion-item .accordion-button { background: var(--egym-surface-elevated) !important; color: var(--egym-text) !important; border-color: var(--egym-border) !important; }
html.theme-dark .admin-evolucion-accordion-item .accordion-button:not(.collapsed),
html[data-theme="dark"] .admin-evolucion-accordion-item .accordion-button:not(.collapsed) { background: var(--egym-primary-muted) !important; color: var(--egym-primary) !important; }
html.theme-dark .admin-evolucion-accordion-item .accordion-body,
html[data-theme="dark"] .admin-evolucion-accordion-item .accordion-body { background: var(--egym-surface) !important; color: var(--egym-text) !important; }

html.theme-dark .admin-empty-state,
html[data-theme="dark"] .admin-empty-state { color: var(--egym-text-muted) !important; }

html.theme-dark .admin .input-group-text,
html[data-theme="dark"] .admin .input-group-text { background: var(--egym-surface-elevated) !important; border-color: var(--egym-border) !important; color: var(--egym-text) !important; }

/* Input group dark */
html.theme-dark .input-group .form-control,
html[data-theme="dark"] .input-group .form-control { background: var(--egym-bg) !important; border-color: var(--egym-border) !important; color: var(--egym-text) !important; }

/* Activar cuenta dark */
html.theme-dark body:not(.login-page) .login-card { background: var(--egym-surface) !important; }
html.theme-dark .login-card .form-control:disabled { background: var(--egym-surface-elevated) !important; color: var(--egym-text-muted) !important; }

/* App cards dark */
html.theme-dark .app-card,
html[data-theme="dark"] .app-card { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; }
html.theme-dark .app-card .card-header,
html[data-theme="dark"] .app-card .card-header { background: var(--egym-surface-elevated) !important; color: var(--egym-text) !important; }

/* Skeleton dark */
html.theme-dark .skeleton,
html[data-theme="dark"] .skeleton,
html.theme-dark .skel-bar,
html[data-theme="dark"] .skel-bar,
html.theme-dark .skel-circle,
html[data-theme="dark"] .skel-circle {
    background: linear-gradient(90deg, var(--egym-surface-elevated) 25%, var(--egym-border-hover) 50%, var(--egym-surface-elevated) 75%) !important;
    background-size: 200% 100% !important;
}

/* Running step row */
html.theme-dark .running-step-row,
html[data-theme="dark"] .running-step-row { background: var(--egym-surface-elevated) !important; border-color: var(--egym-border) !important; }
html.theme-dark .running-step-row .form-control,
html[data-theme="dark"] .running-step-row .form-control { background: var(--egym-bg) !important; border-color: var(--egym-border) !important; color: var(--egym-text) !important; }

/* Misc dark */
html.theme-dark .badge.bg-secondary,
html[data-theme="dark"] .badge.bg-secondary { background: var(--egym-surface-hover) !important; color: var(--egym-text) !important; }
html.theme-dark .accordion-item,
html[data-theme="dark"] .accordion-item { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; }
html.theme-dark .list-group-item,
html[data-theme="dark"] .list-group-item { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; color: var(--egym-text) !important; }
html.theme-dark .list-group-item:hover,
html[data-theme="dark"] .list-group-item:hover { background: var(--egym-surface-hover) !important; }
html.theme-dark .progress,
html[data-theme="dark"] .progress { background: var(--egym-surface-elevated) !important; }

/* Stat cards dark */
html.theme-dark .admin-stat-card,
html[data-theme="dark"] .admin-stat-card { border-color: transparent !important; }
html.theme-dark .admin-stat-card .stat-value,
html.theme-dark .admin-stat-card .stat-label,
html[data-theme="dark"] .admin-stat-card .stat-value,
html[data-theme="dark"] .admin-stat-card .stat-label { color: #fff !important; }

/* Chart cards dark */
html.theme-dark .dashboard-chart-card,
html[data-theme="dark"] .dashboard-chart-card { background: var(--egym-surface) !important; border-color: var(--egym-border) !important; }
html.theme-dark .dashboard-chart-card .chart-title,
html[data-theme="dark"] .dashboard-chart-card .chart-title { color: var(--egym-text-muted) !important; }
html.theme-dark .admin-chart-container,
html.theme-dark .progreso-chart-container,
html[data-theme="dark"] .admin-chart-container,
html[data-theme="dark"] .progreso-chart-container { background: var(--egym-surface) !important; }

/* Profesor sidebar dark */
html.theme-dark body:has(.admin-sidebar),
html[data-theme="dark"] body:has(.admin-sidebar) { background: var(--egym-bg) !important; }

/* Table responsive scrollbar dark */
html.theme-dark .admin-table-wrap::-webkit-scrollbar-thumb,
html[data-theme="dark"] .admin-table-wrap::-webkit-scrollbar-thumb { background: var(--egym-border-hover); }

/* Install modal - ya usa variables, no necesita overrides */
