/* ============================================================
   app.css — Estilos personalizados · Sistema de Gestión de Stock
   Refuerza contraste en el sidebar (AdminLTE 4) y mejora la
   estética general de paneles, tarjetas y encabezados.
   Mantiene Bootstrap 5 + AdminLTE 4 (sin reemplazarlos).
   ============================================================ */

/* --------- Variables de marca --------- */
:root {
    --stock-sidebar-bg: #1f2937;          /* gris-azulado oscuro, más limpio que #212529 */
    --stock-sidebar-bg-alt: #172033;      /* submenús / hover más oscuro */
    --stock-sidebar-link: #d6dee8;        /* texto de menú (alto contraste) */
    --stock-sidebar-link-muted: #9aa7b8;  /* íconos / encabezados */
    --stock-sidebar-accent: #3b82f6;      /* azul de marca (selección) */
    --stock-sidebar-hover: rgba(255, 255, 255, 0.06);
    --stock-sidebar-active: rgba(59, 130, 246, 0.18);
    --stock-content-bg: #f4f6f9;
}

/* --------- Fondo general del contenido --------- */
.app-content {
    background-color: var(--stock-content-bg);
}

/* ============================================================
   HEADER (navbar superior)
   ============================================================ */
.app-header.navbar {
    background: linear-gradient(90deg, #0d6efd 0%, #0a58ca 100%) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.app-header .navbar-brand,
.app-header .nav-link {
    color: #fff !important;
}

.app-header .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.12);
    border-radius: 0.375rem;
}

.app-header .navbar-badge {
    font-size: 0.65rem;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
    background-color: var(--stock-sidebar-bg) !important;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-height: 100vh;
}

.sidebar-brand {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Scroll del sidebar */
.sidebar-wrapper {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding-bottom: 3rem;
}

.sidebar-brand .brand-text {
    letter-spacing: 0.05em;
    font-size: 1.15rem;
}

/* Enlaces de menú: alto contraste (texto claro sobre fondo oscuro) */
.sidebar-menu .nav-link {
    color: var(--stock-sidebar-link) !important;
    border-radius: 0.375rem;
    margin: 2px 8px;
    padding: 0.55rem 0.9rem;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-menu .nav-link:hover {
    background-color: var(--stock-sidebar-hover);
    color: #fff !important;
}

.sidebar-menu .nav-link .nav-icon {
    color: var(--stock-sidebar-link-muted);
    transition: color 0.15s ease;
}

.sidebar-menu .nav-link:hover .nav-icon {
    color: #fff;
}

/* Item activo / menú abierto */
.sidebar-menu .nav-link.active,
.sidebar-menu .menu-open > .nav-link {
    background-color: var(--stock-sidebar-active);
    color: #fff !important;
    box-shadow: inset 3px 0 0 var(--stock-sidebar-accent);
}

.sidebar-menu .nav-link.active .nav-icon,
.sidebar-menu .menu-open > .nav-link .nav-icon {
    color: #fff;
}

/* Encabezados de sección (GESTIÓN, MOVIMIENTOS...) más visibles */
.sidebar-menu .nav-header {
    color: var(--stock-sidebar-link-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 1rem 1.1rem 0.35rem;
    margin-top: 0.25rem;
}

.sidebar-menu .nav-header:first-child {
    padding-top: 0.35rem;
}

/* Submenús (nav-treeview) */
.sidebar-menu .nav-treeview {
    background-color: var(--stock-sidebar-bg-alt);
    border-radius: 0.375rem;
    margin: 0 8px;
    padding: 0.25rem 0;
}

.sidebar-menu .nav-treeview .nav-link {
    color: var(--stock-sidebar-link) !important;
    margin: 1px 4px;
    padding: 0.4rem 0.9rem 0.4rem 2rem;
    font-size: 0.9rem;
}

.sidebar-menu .nav-treeview .nav-link:hover {
    background-color: var(--stock-sidebar-hover);
    color: #fff !important;
}

.sidebar-menu .nav-treeview .nav-icon {
    font-size: 0.5rem;
    color: var(--stock-sidebar-link-muted);
}

/* Flecha del treeview */
.sidebar-menu .nav-arrow {
    color: var(--stock-sidebar-link-muted);
}

.sidebar-menu .menu-open > .nav-link .nav-arrow {
    color: #fff;
    transform: rotate(90deg);
}

/* Scroll del sidebar: permite navegar en pantallas chicas */
.sidebar-wrapper {
    overflow-y: auto !important;
    overflow-x: hidden;
    height: calc(100vh - 3.5rem); /* altura total menos el header */
}

.sidebar-wrapper::-webkit-scrollbar {
    width: 8px;
}

.sidebar-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}

.sidebar-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   TARJETAS (cards)
   ============================================================ */
.card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.6rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.25rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: calc(0.6rem - 1px) calc(0.6rem - 1px) 0 0 !important;
    padding: 0.8rem 1rem;
}

.card-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 1rem;
}

.card-header h5,
.card-header h6 {
    font-weight: 600;
    color: #1f2937;
    font-size: 1rem;
}

.card-footer {
    background-color: #f8fafc;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* ============================================================
   SMALL-BOX (tarjetas de métricas del dashboard)
   ============================================================ */
.small-box {
    border-radius: 0.6rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.small-box .inner {
    padding: 1.1rem 1.25rem;
}

.small-box h3 {
    font-weight: 700;
    font-size: 2rem;
}

.small-box .icon {
    opacity: 0.22;
    font-size: 4.5rem;
}

.small-box-footer {
    background-color: rgba(0, 0, 0, 0.18) !important;
    color: rgba(255, 255, 255, 0.92) !important;
    padding: 0.5rem 1.25rem;
}

.small-box-footer:hover {
    background-color: rgba(0, 0, 0, 0.28) !important;
    color: #fff !important;
}

/* ============================================================
   TABLAS
   ============================================================ */
.table > :not(caption) > * > * {
    padding: 0.7rem 1rem;
}

.table thead th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e2e8f0;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: #f9fafb;
}

.table-hover > tbody > tr:hover > * {
    background-color: #eef4ff;
}

/* ============================================================
   BOTONES (sutiles mejoras)
   ============================================================ */
.btn {
    border-radius: 0.4rem;
}

.btn-primary {
    box-shadow: 0 1px 2px rgba(13, 110, 253, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.35);
}

/* ============================================================
   PIE DE PÁGINA
   ============================================================ */
.app-footer {
    background-color: #fff;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    color: #64748b;
    padding: 0.8rem 1rem;
}

.app-footer strong {
    color: #334155;
}

/* ============================================================
   BREADCRUMB + títulos
   ============================================================ */
.app-content-header h3 {
    font-weight: 700;
    color: #0f172a;
}

.breadcrumb {
    font-size: 0.85rem;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-control:focus,
.form-select:focus {
    border-color: var(--stock-sidebar-accent);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.18);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-page .card {
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    border-radius: 0.75rem;
}

/* ============================================================
   Utilidades existentes (scanner, tablas, badges, timeline)
   ============================================================ */
.scanner-input {
    font-size: 2rem;
    font-family: monospace;
    text-align: center;
    letter-spacing: 0.2em;
}

.table-responsive {
    overflow-x: auto;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.badge-estado {
    font-size: 0.8rem;
}

.timeline-transferencia {
    list-style: none;
    padding: 0;
}

.timeline-transferencia li {
    padding: 0.5rem 0;
    border-left: 2px solid #dee2e6;
    padding-left: 1rem;
    position: relative;
}

.timeline-transferencia li.completed {
    border-left-color: #198754;
}

.preview-table {
    max-height: 400px;
    overflow-y: auto;
}

.preview-table td.error {
    background-color: #f8d7da;
}

/* ============================================================
   FILTROS DE COLUMNA (reporte ventas)
   ============================================================ */
.col-filter-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.col-filter-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    color: #6b7280;
    cursor: pointer;
    font-size: 0.65rem;
    padding: 1px 5px;
    line-height: 1;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.col-filter-btn:hover {
    background: #e5e7eb;
    color: #374151;
    border-color: #9ca3af;
}

.col-filter-btn.active {
    background: var(--stock-sidebar-accent);
    color: #fff;
    border-color: var(--stock-sidebar-accent);
}

.btn-clear-filters {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
}

.filter-dropdown {
    position: absolute;
    z-index: 1050;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.45rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.4rem 0;
}

.filter-dropdown .filter-search {
    width: calc(100% - 1rem);
    margin: 0.3rem 0.5rem 0.4rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
    border: 1px solid #d1d5db;
    border-radius: 0.3rem;
}

.filter-dropdown .filter-search:focus {
    outline: none;
    border-color: var(--stock-sidebar-accent);
    box-shadow: 0 0 0 0.15rem rgba(59, 130, 246, 0.15);
}

.filter-dropdown .filter-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #374151;
    transition: background 0.1s;
}

.filter-dropdown .filter-option:hover {
    background: #f3f4f6;
}

.filter-dropdown .filter-option input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

.filter-dropdown .filter-option label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-dropdown .filter-option-unavailable {
    color: #9ca3af;
}

.filter-dropdown .filter-option-unavailable label {
    color: #9ca3af !important;
}

.filter-option-unavailable:hover {
    background-color: #f3f4f6;
}

.filter-option-unavailable input[type="checkbox"] {
    opacity: 0.5;
}

.filter-section-separator {
    padding: 4px 10px;
    font-size: 11px;
    color: #9ca3af;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    font-style: italic;
}

.filter-dropdown .filter-actions {
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0.5rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 0.2rem;
}

.filter-dropdown .filter-actions .btn {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
}

.filter-dropdown .filter-count {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-left: auto;
    align-self: center;
}

/* ============================================================
   PREVISUALIZADOR DE BOLETAS (boleta_preview.js)
   Imagen: zoom + pan con mouse/touch.
   PDF: visor nativo en iframe.
   ============================================================ */
.boleta-preview {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.boleta-preview-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.45rem 0.6rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.boleta-preview-file {
    font-size: 0.8rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 40%;
    margin-right: auto;
}

.boleta-preview-zoom {
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
    min-width: 3rem;
    text-align: center;
}

.boleta-preview-btn {
    line-height: 1;
    padding: 0.2rem 0.45rem;
}

.boleta-preview-hint {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-left: auto;
}

.boleta-preview-viewport {
    position: relative;
    overflow: hidden;
    height: 420px;
    background: #212529 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect width='24' height='24' fill='%232b3036'/%3E%3Crect x='12' y='0' width='12' height='12' fill='%23333840'/%3E%3Crect x='0' y='12' width='12' height='12' fill='%23333840'/%3E%3C/svg%3E");
    touch-action: none;
    cursor: grab;
}

.boleta-preview-viewport:active {
    cursor: grabbing;
}

.boleta-preview-viewport-pdf {
    background: #212529 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect width='24' height='24' fill='%232b3036'/%3E%3Crect x='12' y='0' width='12' height='12' fill='%23333840'/%3E%3Crect x='0' y='12' width='12' height='12' fill='%23333840'/%3E%3C/svg%3E");
    overflow: auto;
    touch-action: pan-x pan-y;
    cursor: grab;
}

.boleta-preview-viewport-pdf.boleta-preview-viewport-iframe {
    background: #dee2e6;
    overflow: hidden;
}

.boleta-preview-documento {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 16px;
    width: max-content;
    min-width: 100%;
}

.boleta-preview-pagina-item {
    margin: 0;
    padding: 0;
    background: #fff;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
    text-align: center;
    line-height: 0;
}

.boleta-preview-pagina-img {
    display: block;
    max-width: none;
    height: auto;
    background: #fff;
    user-select: none;
    -webkit-user-drag: none;
}

.boleta-preview-pagina-caption {
    line-height: 1.4;
    font-size: 0.7rem;
    color: #6c757d;
    padding: 4px 0;
}

.boleta-preview-pagina-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: #495057;
    min-width: 3.4rem;
    text-align: center;
}

.boleta-preview-cargando {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 220px;
    color: #adb5bd;
    font-size: 0.9rem;
}

.boleta-preview-img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
    background: #fff;
}

.boleta-preview-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.boleta-preview-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    color: #6c757d;
    background: #f8f9fa;
}
