/* Utilidad para forzar alineación a la izquierda en tablas */
.alinear-izquierda {
    text-align: left !important;
}
/* ==========================================================================
   1. VARIABLES Y BASE
   ========================================================================== */
:root {
    --primary-color: #0d6efd;
    --sidebar-bg: #212529;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f8f9fa;
    font-size: 0.9rem;
    color: #333;
    margin: 0;
    padding: 0;
}

.fw-black { font-weight: 900; }

/* ==========================================================================
   2. LAYOUT Y OFFCANVAS (Menú Lateral)
   ========================================================================== */
.main-content {
    /* padding: 20px; */
    min-height: 100vh;
    width: 100%;
}

.offcanvas {
    background-color: var(--sidebar-bg) !important;
    color: #fff !important;
}

.offcanvas .nav-link {
    color: #fff !important;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 5px;
    transition: 0.2s;
}

.offcanvas .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.offcanvas .nav-link.active {
    background-color: var(--primary-color) !important;
}

/* Sidebar grouping and active state polish */
#sidebarMenu .nav-item.text-uppercase {
    margin-top: 0.9rem !important;
    margin-bottom: 0.4rem !important;
    letter-spacing: 0.06em;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    color: #8bd6ff !important;
}

#sidebarMenu .nav-link {
    border-left: 3px solid transparent;
}

#sidebarMenu .nav-link:hover {
    background: rgba(255, 255, 255, 0.14);
    border-left-color: rgba(255, 255, 255, 0.55);
}

#sidebarMenu .nav-link.active {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%) !important;
    border-left-color: #7fc2ff;
    box-shadow: 0 4px 14px rgba(13, 110, 253, 0.35);
}

#sidebarMenu .sidebar-accordion .accordion-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#sidebarMenu .sidebar-accordion-btn {
    background: transparent;
    color: #9fdcff;
    border-radius: 10px;
    padding: 0.72rem 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: none;
}

#sidebarMenu .sidebar-accordion-btn:not(.collapsed) {
    color: #ffffff;
    background: rgba(13, 110, 253, 0.22);
}

#sidebarMenu .sidebar-accordion-btn::after {
    filter: invert(1) brightness(2);
    opacity: 0.85;
}

#sidebarMenu .sidebar-accordion .accordion-body {
    padding-top: 0.35rem !important;
    padding-bottom: 0.55rem !important;
}

.navbar { z-index: 1040; }
.navbar-brand { font-weight: 900; letter-spacing: -1px; }
.navbar-brand .brand-logo-admin.brand-logo-wrap {
    min-height: 36px;
}

.navbar-brand .brand-logo-admin .brand-logo-img,
.navbar-brand .brand-logo-img.brand-logo-admin,
.navbar-brand .brand-logo-img {
    max-height: 40px;
}

/* ==========================================================================
   3. COMPONENTES (Glassmorphism & UI)
   ========================================================================== */
.glass-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
    height: 100%;
}

.glass-card:hover {
    transform: translateY(-5px);
}

.brand-rs { color: #ffffff; font-weight: 900; }
.brand-trunk { color: var(--primary-color); font-weight: 900; }

.brand-logo-wrap {
    display: inline-flex;
    align-items: center;
}

.brand-logo-img {
    height: 34px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.brand-logo-text {
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #ffffff;
    background: linear-gradient(90deg, #ffffff 0%, #8ec5ff 60%, #6be2c8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Gestión de Imágenes */
.image-upload-container { position: relative; width: 140px; height: 140px; margin: 0 auto 20px; }
.image-preview-wrapper { 
    width: 100%; height: 100%; border-radius: 20px; border: 3px solid var(--primary-color);
    background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.image-preview-wrapper img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }

.camera-icon-badge {
    position: absolute; bottom: -5px; right: -5px; background: var(--primary-color);
    color: white; width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; border: 3px solid #fff;
}

.img-pala { width: 45px; height: 45px; object-fit: contain; background: #fff; border: 1px solid #dee2e6; border-radius: 8px; }
.img-pala.product-preview-trigger { cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.img-pala.product-preview-trigger:hover { transform: scale(1.08); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12); }
.fila-discontinuo { opacity: 0.5; filter: grayscale(100%); }
input[type="file"]#foto-editar, input[type="file"]#foto-nuevo { display: none; }

/* Vista de producto */
.product-preview-modal {
    border: 0;
    border-radius: 24px;
    overflow: hidden;
    background: linear-gradient(180deg, #fdfdfd 0%, #f7f7f7 100%);
}

.preview-image-wrap {
    background: linear-gradient(160deg, #f3efe9 0%, #ebe7e1 100%);
    border-radius: 18px;
    padding: 10px;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-image-wrap img {
    max-width: 100%;
    max-height: 260px;
    object-fit: contain;
}

.preview-image-gallery {
    width: 100%;
}

.preview-gallery-main {
    position: relative;
}

.preview-video-player {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 8px;
}

.preview-video-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.preview-gallery-thumbnails {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
}

.preview-gallery-thumbnails img {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    border: 2px solid #d0d7de;
    cursor: pointer;
    object-fit: cover;
    transition: border-color 0.2s ease;
    flex: 0 0 auto;
}

.preview-gallery-thumbnails img.active {
    border-color: #198754;
}

.preview-gallery-thumbnails img:hover {
    border-color: #0d6efd;
}

.preview-gallery-thumb-video {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    border: 2px solid #d0d7de;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #101828;
    color: #fff;
    transition: border-color 0.2s ease;
    font-size: 1rem;
    flex: 0 0 auto;
}

.preview-gallery-thumb-video.active {
    border-color: #198754;
}

.preview-gallery-thumb-video:hover {
    border-color: #0d6efd;
}

.preview-category {
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #6f6f6f;
    font-weight: 500;
}

.preview-title {
    font-size: 2rem;
    line-height: 1.05;
    letter-spacing: 1px;
    color: #2b2b2b;
    font-weight: 300;
}

.preview-brand {
    color: #3d3d3d;
    font-weight: 600;
    text-transform: uppercase;
}

.preview-prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.preview-prices small {
    color: #767676;
    display: block;
}

.preview-prices h4 {
    margin: 0;
    font-size: 1.7rem;
    font-weight: 700;
    color: #101010;
}

.preview-chip {
    border: 1px solid #d7d7d7;
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-chip span {
    color: #707070;
    font-size: 0.85rem;
}

.preview-chip strong {
    font-size: 1rem;
    color: #232323;
}

.preview-status-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge-etiqueta-comercial {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    letter-spacing: 0.2px;
    font-weight: 700;
    line-height: 1;
}

.badge-etiqueta-icon {
    width: 1.2rem;
    height: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.72rem;
}

.badge-etiqueta-text {
    display: inline-block;
}

.badge-etiqueta-modal {
    font-size: 0.85rem;
}

.ahorro-label {
    display: inline-block;
    font-weight: 700;
}

.ahorro-label-destacado {
    color: #0f5132;
    background: linear-gradient(135deg, rgba(25, 135, 84, 0.18), rgba(255, 193, 7, 0.22));
    border: 1px solid rgba(25, 135, 84, 0.28);
    border-radius: 999px;
    padding: 0.18rem 0.6rem;
    box-shadow: 0 4px 10px rgba(25, 135, 84, 0.2);
}

.rs-modal-feedback {
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
}

.rs-modal-feedback.alert-success {
    color: #d1f7e0;
    background: rgba(25, 135, 84, 0.28);
    border-color: rgba(141, 240, 187, 0.45);
}

.rs-modal-feedback.alert-danger {
    color: #ffe0e0;
    background: rgba(220, 53, 69, 0.3);
    border-color: rgba(255, 167, 176, 0.52);
}

.rs-modal-feedback.alert-warning {
    color: #fff0cc;
    background: rgba(255, 193, 7, 0.24);
    border-color: rgba(255, 224, 138, 0.45);
}

.badge-etiqueta-animada {
    animation: badgePulse 2.2s ease-in-out infinite;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

@keyframes badgePulse {
    0%, 100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
    }
    50% {
        transform: translateY(-1px) scale(1.04);
        box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
    }
}

@media (max-width: 768px) {
    .preview-title { font-size: 1.8rem; }
}

/* ==========================================================================
   4. RESPONSIVE
   ========================================================================== */
@media (max-width: 576px) {
    .form-control, .form-select { font-size: 16px !important; padding: 12px; }
    .btn-agregar-text { display: none; }
}

/* form usuarios */

.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Modales alta/edición de usuario-cliente (estilo profesional claro)
   ========================================================================== */
.rs-user-modal .modal-dialog {
    max-width: 620px;
}

.rs-user-modal.modal.show .modal-dialog {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}

.rs-user-modal .modal-content {
    background: #ffffff !important;
    border: 0 !important;
    border-radius: 18px !important;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
}

.rs-user-modal .rs-user-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    color: #fff !important;
    background: linear-gradient(135deg, #111827 0%, #26364f 100%) !important;
    border-bottom: 0 !important;
}

.rs-user-modal .rs-user-modal-header .modal-title,
.rs-user-modal .rs-user-modal-header .rs-modal-title-text {
    color: #fff !important;
}

.rs-user-modal .rs-user-modal-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.14);
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}

.rs-user-modal .modal-body {
    padding: 1.5rem;
    background: #ffffff !important;
    color: #1f2937;
    overflow-y: auto;
}

.rs-user-modal .form-label {
    color: #475569 !important;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.rs-user-modal .form-control,
.rs-user-modal .form-select {
    min-height: 44px;
    color: #1f2937 !important;
    background: #f8fafc !important;
    border: 1px solid #dbe3ee !important;
    border-radius: 10px !important;
}

.rs-user-modal .form-control:focus,
.rs-user-modal .form-select:focus {
    background: #fff !important;
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.12) !important;
}

.rs-user-modal .form-control::placeholder {
    color: #94a3b8;
}

.rs-user-modal .form-text {
    color: #64748b !important;
    font-size: 0.78rem;
}

.rs-user-modal .input-group-text {
    color: #64748b !important;
    background: #f8fafc !important;
    border: 1px solid #dbe3ee !important;
}

.rs-user-modal .input-group > .input-group-text:first-child {
    border-radius: 10px 0 0 10px !important;
}

.rs-user-modal .input-group > .input-group-text:last-child {
    border-radius: 0 10px 10px 0 !important;
}

.rs-user-modal .input-group .form-control {
    border-left: 0 !important;
    border-radius: 0 10px 10px 0 !important;
}

.rs-user-modal .input-group:has(> .input-group-text:last-child) .form-control {
    border-right: 0 !important;
    border-radius: 0 !important;
}

.rs-user-modal .rs-toggle-password {
    cursor: pointer;
    user-select: none;
    border: 1px solid #dbe3ee !important;
    box-shadow: none;
}

.rs-user-modal .rs-toggle-password:hover {
    color: #0d6efd !important;
    background: #eef4ff !important;
}

.rs-user-modal .rs-toggle-password:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.12);
    z-index: 3;
}

.rs-user-modal .modal-footer {
    padding: 1rem 1.5rem 1.35rem;
    background: #f8fafc !important;
    border-top: 1px solid #edf1f6 !important;
}

.rs-user-modal .rs-modal-feedback {
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
}

.rs-user-modal .rs-modal-feedback.alert-success {
    color: #0f5132 !important;
    background: #d1e7dd !important;
    border: 1px solid #badbcc !important;
}

.rs-user-modal .rs-modal-feedback.alert-danger {
    color: #842029 !important;
    background: #f8d7da !important;
    border: 1px solid #f5c2c7 !important;
}

.rs-user-modal .rs-modal-feedback.alert-warning {
    color: #664d03 !important;
    background: #fff3cd !important;
    border: 1px solid #ffecb5 !important;
}

@media (max-height: 768px) {
    .rs-user-modal.modal.show .modal-dialog {
        align-items: flex-start;
        margin-top: 0.75rem;
        margin-bottom: 0.75rem;
        min-height: calc(100% - 1.5rem);
    }

    .rs-user-modal .modal-content {
        max-height: calc(100vh - 1.5rem);
    }

    .rs-user-modal .rs-user-modal-header {
        padding: 0.9rem 1.15rem;
    }

    .rs-user-modal .modal-body {
        padding: 1rem 1.15rem;
    }

    .rs-user-modal .modal-footer {
        padding: 0.85rem 1.15rem;
    }

    .rs-user-modal .form-label {
        margin-bottom: 0.25rem;
    }

    .rs-user-modal .form-control,
    .rs-user-modal .form-select {
        min-height: 40px;
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    .rs-user-modal .input-group-text {
        padding: 0.4rem 0.65rem;
    }
}

@media (max-width: 575.98px) {
    .rs-user-modal .modal-dialog {
        margin: 0.75rem;
    }

    .rs-user-modal .modal-body {
        padding: 1.15rem;
    }

    .rs-user-modal .modal-footer {
        padding: 1rem 1.15rem;
    }
}

/* Dashboard administrador */
.dashboard-quick {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-quick:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

/* Historial de ventas: mismo aspecto que tabla de productos en ventas.php */
#tablaHistorial_wrapper .dataTable thead > tr > th,
#tablaHistorial_wrapper .dataTable tbody > tr > td,
#tablaHistorial.dataTable thead > tr > th,
#tablaHistorial.dataTable tbody > tr > td {
    padding: 0.5rem 0.5rem !important;
    vertical-align: middle !important;
}

#tablaHistorial_wrapper .dataTable .badge,
#tablaHistorial.dataTable .badge {
    padding: 0.35em 0.65em !important;
}