/**
 * POS Premium Design System - Dark Mode Support
 * Scoped specifically to .dark-mode class on body
 */

/* Transition for smooth theme switching */
body, .card, .card-header, .card-body, .nav-link, .form-control, .form-select, .input-group-text, h3, h5, h6, strong, small {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Dark Mode Variables & Styles */
body.dark-mode {
    background-color: #121417 !important;
    color: #e2e8f0 !important;
    font-family: 'Outfit', 'Segoe UI', sans-serif !important;
}

body.dark-mode .card {
    background-color: #1e2126 !important;
    border-color: #333 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

body.dark-mode .card-header {
    background-color: rgba(255, 255, 255, 0.03) !important;
    border-bottom: 1px solid #333 !important;
    color: #ffffff !important;
}

body.dark-mode h1, 
body.dark-mode h2, 
body.dark-mode h3, 
body.dark-mode h4, 
body.dark-mode h5, 
body.dark-mode h6, 
body.dark-mode strong,
body.dark-mode .card-title,
body.dark-mode .fw-bold {
    color: #ffffff !important;
}

/* Mejora de visibilidad para etiquetas y textos secundarios */
body.dark-mode .form-label, 
body.dark-mode label,
body.dark-mode .text-muted, 
body.dark-mode small.text-muted,
body.dark-mode .text-secondary {
    color: #b0b0b0 !important;
}

/* Azul optimizado para fondos oscuros (más brillo) */
body.dark-mode .text-primary {
    color: #4dabf7 !important;
}

body.dark-mode .bg-primary {
    background-color: #3b82f6 !important;
}

/* Inputs & Form Elements */
body.dark-mode .form-control,
body.dark-mode .form-select {
    background-color: #2b2b2b !important;
    border-color: #444 !important;
    color: #ffffff !important;
}

body.dark-mode .form-control::placeholder {
    color: #7a7a7a !important;
}

body.dark-mode .form-control::-webkit-input-placeholder {
    color: #7a7a7a !important;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
    background-color: #2b2b2b !important;
    border-color: #4dabf7 !important;
    box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.25) !important;
}

body.dark-mode .input-group-text {
    background-color: #2b2b2b !important;
    border-color: #444 !important;
    color: #b0b0b0 !important;
}

/* Tabs */
body.dark-mode .nav-tabs {
    border-bottom-color: #333 !important;
}

body.dark-mode .nav-tabs .nav-link {
    color: #b0b0b0 !important;
}

body.dark-mode .nav-tabs .nav-link.active {
    background-color: #1e2126 !important;
    border-color: #333 #333 #1e2126 !important;
    color: #4dabf7 !important;
}

/* Product Cards & Search Results */
body.dark-mode .producto-card {
    background-color: #2b2b2b !important;
    border-color: #444 !important;
}

body.dark-mode .producto-card .badge.bg-light {
    background-color: #3d3d3d !important;
    color: #e0e0e0 !important;
}

body.dark-mode #resultados-busqueda {
    background-color: #1e1e1e !important;
    border-color: #333 !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .resultado-item:hover {
    background-color: #2b2b2b !important;
}

/* Footer & Nav */
body.dark-mode footer {
    background-color: #121417 !important;
    border-top-color: #333 !important;
}

body.dark-mode footer a {
    color: #4dabf7 !important;
}

body.dark-mode .navbar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Caja & Table specific adjustments */
body.dark-mode .table {
    border-color: #333 !important;
    color: #e2e8f0 !important;
}

body.dark-mode .table > :not(caption) > * > * {
    background-color: transparent !important;
    color: inherit !important;
    border-color: #333 !important;
}

body.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02) !important;
    color: inherit !important;
}

body.dark-mode .table-hover > tbody > tr:hover > * {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

body.dark-mode .table-light {
    --bs-table-bg: #2d3748 !important;
    --bs-table-color: #f8fafc !important;
    border-color: #444 !important;
}

body.dark-mode .table-primary {
    --bs-table-bg: #1e3a8a !important;
    --bs-table-color: #ffffff !important;
    border-color: #2563eb !important;
}

body.dark-mode tr.table-primary td {
    background-color: #1e3a8a !important;
    color: #ffffff !important;
}

/* Fix for hardcoded bg-light/bg-white and text-dark in forms/containers */
body.dark-mode .bg-light {
    background-color: #2b2b2b !important;
}

body.dark-mode .bg-white {
    background-color: #1e2126 !important;
    color: #f8fafc !important;
}

body.dark-mode .text-dark,
body.dark-mode .text-black {
    color: #f8fafc !important;
}

body.dark-mode .card.text-dark,
body.dark-mode .card .text-dark,
body.dark-mode .card.text-black,
body.dark-mode .card .text-black {
    color: #f8fafc !important;
}

body.dark-mode .border {
    border-color: #333 !important;
}

/* DataTables & pagination */
body.dark-mode .dataTables_wrapper .dataTables_length,
body.dark-mode .dataTables_wrapper .dataTables_filter,
body.dark-mode .dataTables_wrapper .dataTables_info,
body.dark-mode .dataTables_wrapper .dataTables_processing,
body.dark-mode .dataTables_wrapper .dataTables_paginate {
    color: #e2e8f0 !important;
}

body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #e2e8f0 !important;
    border-color: #444 !important;
}

body.dark-mode .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #3b82f6 !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
}

body.dark-mode .page-link {
    background-color: #2b2b2b !important;
    border-color: #444 !important;
    color: #4dabf7 !important;
}

body.dark-mode .page-item.active .page-link {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
}

body.dark-mode .list-group-item {
    background-color: #1e2126 !important;
    border-color: #333 !important;
    color: #e2e8f0 !important;
}

body.dark-mode .accordion-item {
    background-color: #1e2126 !important;
    border-color: #333 !important;
}

body.dark-mode .accordion-button {
    background-color: #2d3748 !important;
    color: #ffffff !important;
}

body.dark-mode .accordion-button:not(.collapsed) {
    background-color: #3b82f6 !important;
    color: #ffffff !important;
}

/* Cart & Payments */
body.dark-mode .border-bottom {
    border-bottom-color: #2d3748 !important;
}

body.dark-mode #subtotal,
body.dark-mode #total,
body.dark-mode #vuelto,
body.dark-mode #contador-items {
    color: #ffffff !important;
}

body.dark-mode #total {
    color: #4dabf7 !important; /* El azul brillante que definimos */
}

body.dark-mode .card span {
    color: #e2e8f0;
}

/* Custom classes for theme toggle button */
.theme-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.theme-toggle-btn:hover {
    transform: rotate(15deg);
    background: #e2e8f0;
}

body.dark-mode .theme-toggle-btn {
    background: #2d3748;
    color: #facc15;
    border-color: #4a5568;
}

body.dark-mode .theme-toggle-btn:hover {
    background: #374151;
}

/* Badges adjustments */
body.dark-mode .badge.bg-light {
    background-color: #2d3748 !important;
    color: #e2e8f0 !important;
}

body.dark-mode .badge.bg-success {
    background-color: #065f46 !important;
}

body.dark-mode .badge.bg-danger {
    background-color: #991b1b !important;
}

/* Modals */
body.dark-mode .modal-content {
    background-color: #1e2126;
    color: #e2e8f0;
    border: 1px solid #2d3748;
}

body.dark-mode .modal-header,
body.dark-mode .modal-footer {
    border-color: #2d3748;
}

body.dark-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Login Page Specific Fixes */
body.dark-mode .login-wrapper {
    background-color: #121417 !important;
}

body.dark-mode .login-card {
    background-color: #1e2126 !important;
    border-color: #333 !important;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.4) !important;
}

body.dark-mode .login-header h3 {
    color: #ffffff !important;
}

body.dark-mode .login-header p {
    color: #b0b0b0 !important;
}

body.dark-mode .form-floating > .form-control {
    background-color: #2b2b2b !important;
    border-color: #444 !important;
    color: #ffffff !important;
}

body.dark-mode .form-floating label {
    color: #888 !important;
}

body.dark-mode .form-floating > .form-control:focus ~ label,
body.dark-mode .form-floating > .form-control:not(:placeholder-shown) ~ label {
    color: #4dabf7 !important;
}

/* Specific Section Fixes (Usuarios/Clientes) */
body.dark-mode .badge-rol {
    background: rgba(77, 171, 247, 0.15) !important;
    color: #4dabf7 !important;
    border-color: rgba(77, 171, 247, 0.4) !important;
}

body.dark-mode .breadcrumb-item,
body.dark-mode .breadcrumb-item a {
    color: #b0b0b0 !important;
}

body.dark-mode .breadcrumb-item.active {
    color: #ffffff !important;
}

body.dark-mode .card-usuario {
    background-color: #1e2126 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}
