/* ================================================= */
/* MODERNIZACIÓN ÁREA DE VENTAS Y CARRITO - 2026     */
/* ================================================= */

:root {
    /* 1. COLORES DE IDENTIDAD (Basados en el logo) */
    --primary: #32b1be;         /* Turquesa principal para destacar */
    --primary-hover: #268d98;   /* Turquesa un poco más oscuro al pasar el ratón */
    --secondary: #64748b;       /* Gris pizarra (tomado del triángulo gris del logo) */
    --secondary-light: #f8fafc; /* Gris/azulado ultra claro para no cansar la vista */
    --accent: #475569;          /* Gris oscuro para contrastes y textos fuertes */
    
    /* 2. COLORES DE ACCIÓN (Corregidos para el carrito) */
    --success: #10b981;         /* Verde esmeralda suave para "Vender/Guardar" */
    --success-hover: #059669;   /* Verde oscuro para el hover */
    --danger: #ef4444;          /* Rojo suave para "Cancelar/Eliminar" */
    --danger-hover: #dc2626;    
    
    /* 3. COLORES ESTRUCTURALES (Confort Visual) */
    --bg-main: #f1f5f9;         /* Fondo de la app (un gris ligerísimo, quita el brillo del blanco puro) */
    --bg-surface: #ffffff;      /* Fondo de los formularios y tablas (Blanco limpio) */
    --text-main: #334155;       /* Texto oscuro (más suave que el negro absoluto) */
    --text-muted: #94a3b8;      /* Texto secundario (etiquetas, placeholders) */
    --border-color: #cbd5e1;    /* Bordes suaves que no compiten por la atención */
    
    /* 4. SOMBRAS Y BORDES (Mantenemos tu diseño redondeado) */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
}


/* EFECTO HOVER Y TOQUE (MÓVIL) PARA FILAS DEL CARRITO */
.tabla-items tbody tr {
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent; /* Quita el cuadro azul feo por defecto en móviles Android/iOS */
}

/* :hover para computadoras con ratón | :active para toques en celulares y tablets */
.tabla-items tbody tr:hover td,
.tabla-items tbody tr:active td {
    background-color: #dbeafe !important; /* Un azul claro, fresco y notorio */
    cursor: pointer;
}

/* ==============================================
   BOTONES PRINCIPALES DE ACCIÓN
============================================== */
.btnGuardarVenta, .btnGuardarCompra, .btnGuardarNC, .btnGuardarND, .btnGuardarGuia {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-hover) 100%) !important;
    color: white !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    border: none !important;
    padding: 15px 25px !important;
    border-radius: var(--radius-md) !important;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin: 4px !important;
}

.btnGuardarVenta:hover, .btnGuardarCompra:hover, .btnGuardarNC:hover, .btnGuardarND:hover, .btnGuardarGuia:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.4) !important;
    filter: brightness(1.05);
}

.btnEliminarCarro {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-hover) 100%) !important;
    color: white !important;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
    border: none !important;
    padding: 15px 25px !important;
    border-radius: var(--radius-md) !important;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3) !important;
    transition: all 0.3s ease !important;
    margin: 4px !important;
}

.btnEliminarCarro:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.4) !important;
}

.btnGuardarVenta i, .btnGuardarCompra i, .btnGuardarNC i, .btnGuardarND i, .btnGuardarGuia i, .btnEliminarCarro i {
    font-size: 1.5em !important;
    color: white !important;
    vertical-align: middle;
    margin-right: 8px;
}

/* BOTON DE PRODUCTO MANUAL */
.btn-AgregaManual {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
    transition: all 0.3s ease;
}

.btn-AgregaManual:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.4);
}

@media (max-width: 768px) {
    .btn-AgregaManual { width: 100%; font-size: 16px; padding: 15px; margin-top: 10px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .btn-AgregaManual { font-size: 16px; padding: 14px 20px; }
}

/* ==============================================
   TABLAS DE ITEMS Y TOTALES
============================================== */
.items-c {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--bg-surface);
}

.tabla-items {
    table-layout: auto;
    margin: 0;
    border-collapse: collapse;
    width: 100%;
    background-color: var(--bg-surface);
}

.tabla-items thead tr {
    border: none !important;
}

.tabla-items thead tr th {
    /* Aplicamos el gradiente directamente a la celda para sobreescribir plantilla.css */
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%) !important;
    color: #ffffff !important; /* Forzamos el texto blanco */
    text-align: center;
    text-transform: uppercase;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 12px 10px;
    border: none !important;
}

.tabla-totales {
    table-layout: auto;
    margin: 15px 0 0 0;
    border-collapse: collapse;
    width: 100%;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tabla-totales tbody tr td {
    padding: 12px 15px !important;
}

.tabla-totales tbody tr td:nth-child(1) {
    width: 60% !important;
    text-align: right !important;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.tabla-totales tbody tr td:nth-child(2) {
    width: 40% !important;
    text-align: left !important;
    font-size: 1.25em;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border-color);
}

/* ==============================================
   FORMULARIOS DE VENTAS Y COMPRAS
============================================== */
.formVenta input, .formCompra input,
.formVenta select, .formCompra select,
#formGuia select, #formGuia input {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border-color) !important;
    letter-spacing: 0.5px !important;
    font-weight: 500 !important;
    padding: 8px 12px;
    background-color: var(--bg-surface);
    color: var(--text-main);
    transition: all 0.3s ease;
    outline: none !important;
}

.formVenta input:focus, .formCompra input:focus,
.formVenta select:focus, .formCompra select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
}

.formVenta span, .formCompra span {
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
    border-right: none !important;
    background-color: var(--bg-main);
    color: var(--text-muted);
    font-weight: 500;
}

.formVenta #serie, .formVenta #fechaDoc, .formVenta #fechaVence,
.formVenta #descuentoGlobal, .formVenta #descuentoGlobalP, .formVenta #email, .formVenta select,
.formCompra #serieDoc, .formCompra #fechaDoc, .formCompra #serieModificar, 
.formCompra #correlativoModificar, .formCompra #fechaModificar, .formCompra #fechaVence,
.formCompra #descuentoGlobal, .formCompra #descuentoGlobalP, .formCompra #email,
.formCompra #correlativoDoc, .formCompra select,
#formGuia #tipocomp, #formGuia #tipoDoc, #formGuia #serie, #formGuia #fechaEmision {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
}

.formVenta select, .formCompra select { cursor: pointer !important; }
.formVenta select option, .formCompra select option { padding: 8px !important; font-size: 1em !important; }

.formVenta #docIdentidad, .formVenta #serieNumero,
.formCompra #docIdentidad, #formGuia #docIdentidad, #formGuia #docTransporte {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important;
}

/* Spans (Botones de búsqueda al lado de inputs) */
.formVenta #docIdentidad ~ span, .formVenta #serieNumero ~ span,
.formCompra #docIdentidad ~ span, #formGuia #docIdentidad ~ span,
#formGuia #docTransporte ~ span, .formCompra #serieDoc ~ span,
.formCompra #serieModificar ~ span {
    background: var(--primary) !important;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
    border: 1px solid var(--primary) !important;
    color: white !important;
    cursor: pointer;
    transition: background 0.3s;
}

.formVenta #docIdentidad ~ span:hover, .formCompra #docIdentidad ~ span:hover {
    background: var(--primary-hover) !important;
}

.formVenta #serieNumero, .formCompra #serieDoc, .formCompra #serieModificar {
    text-transform: uppercase !important;
}
.formVenta #serie { background-color: var(--bg-surface); }

/* Botón Eliminar fila del carrito (La "X" roja) */
.tabla-items button {
    position: relative !important;
    border-radius: 50% !important;
    padding: 0 !important;
    width: 28px !important;
    height: 28px !important;
    background-color: #fee2e2 !important;
    color: var(--danger) !important;
    border: 1px solid #fca5a5 !important;
    outline: 0 !important;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tabla-items button:hover {
    background-color: var(--danger) !important;
    color: white !important;
}

/* Botón Agregar al Carrito (dentro de listados) */
.btn-agregar-carrito {
    position: relative !important;
    border-radius: var(--radius-sm) !important;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white !important;
    border: none !important;
    outline: 0 !important;
    margin-bottom: 3px !important;
    padding: 6px 12px !important;
    font-size: 0.85em !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
    transition: transform 0.2s;
}

.btn-agregar-carrito:hover { transform: translateY(-1px); }

/* ==============================================
   MISCELÁNEA DEL CARRITO
============================================== */
#reloadC, #reloadCG {
    position: absolute; display: none; width: 40px; height: 40px; 
    left: 50%; top: -30px; z-index: 100000;
    border-radius: 50% !important; background-color: transparent !important;
}
#reloadC img, #reloadCG img {
    position: relative; width: 40px; height: 40px;
    border-radius: 50% !important; box-shadow: var(--shadow-sm);
}

#rucActivo {
    position: absolute; top: 12px; right: 45px;
    padding: 4px 8px; z-index: 999;
    color: var(--primary); background: #e0e7ff;
    letter-spacing: 0.5px; font-size: 0.7em; font-weight: 600;
    border-radius: 4px; border: 1px solid #c7d2fe;
}

.btnsuccess {
    background-color: var(--success) !important;
    border-radius: var(--radius-sm) !important;
    padding: 8px 15px !important;    
    color: white !important;
    text-transform: uppercase !important;
    font-size: 0.85em !important;
    font-weight: 600 !important;
    margin-bottom: 3px !important;
    border: none !important;
}

.contenedor-btns-carrito {
    display: flex !important;
    flex-flow: row wrap !important;
    justify-content: center !important;
    gap: 10px;
    margin-top: 15px;
}

/* ==============================================
   MODAL PRODUCTOS VENTA
============================================== */
#modalProductosVenta .modal-content { border-radius: var(--radius-lg) !important; border: none; overflow: hidden; }
#modalProductosVenta .modal-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%) !important;
    color: white !important;
    padding: 20px 25px !important;
    border-bottom: none !important;
}
#modalProductosVenta .modal-header h5 { font-size: 1.25em !important; font-weight: 600; margin: 0 !important; }

#modalProductosVenta .body-productos-ventas .btn-primary {
    outline: 0 !important; border: none !important; border-radius: var(--radius-sm) !important;
    background: var(--primary) !important; color: white !important;
    font-size: 0.9em !important; letter-spacing: 0.5px !important; font-weight: 600;
}
#modalProductosVenta .body-productos-ventas .btn-close {
    background: var(--bg-main) !important; color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
}

/* ==============================================
   SWITCH TIPO DESCUENTO (S/ o %) - Estilo iOS
============================================== */
.contenedor-tipo-descuento {
    position: relative;
    width: 80px;
    height: 32px;
    background: var(--bg-main);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.contenedor-tipo-descuento input { display: none; }

.contenedor-tipo-descuento label {
    position: absolute;
    width: 36px;
    height: 26px;
    top: 2px;
    padding: 4px 0;
    font-size: 0.8em;
    font-weight: 600;
    border-radius: 18px;
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: transparent;
}

.contenedor-tipo-descuento #sol { left: 2px; }
.contenedor-tipo-descuento #por { left: 40px; }

/* Estados Activos del Switch */
.on { background-color: var(--success) !important; color: white !important; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.on-por { background-color: var(--primary) !important; color: white !important; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.off { background-color: transparent !important; color: var(--text-muted) !important; }
.table-condensed .off { background-color: transparent !important; }

/* ==============================================
   BOTONES IMPRIMIR (A4, TICKET)
============================================== */
.contenedor-print {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}

.contenedor-print #printA4, .contenedor-print #printT {
    position: relative;
    padding: 10px;
    width: 50px;
    height: 50px;
    border-radius: 50% !important;
    background-color: var(--bg-surface);
    cursor: pointer;
    outline: 0 !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: all 0.2s ease;
}

.contenedor-print #printA4:hover, .contenedor-print #printT:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md) !important;
    border-color: var(--primary) !important;
}

#a4, #tk { display: none; }
.contenedor-print #printA4 { background-image: url('../img/svg/pdf_cpe.svg') !important; background-size: 24px !important; background-position: center !important; background-repeat: no-repeat !important; }
.contenedor-print #printT { background-image: url('../img/svg/ticket_cpe.svg') !important; background-size: 24px !important; background-position: center !important; background-repeat: no-repeat !important; }

/* ==============================================
   TABLAS GENERALES (VENTAS, GUIAS, COTIZACIONES)
============================================== */
.tablaVentas thead, .tablaGuias thead, .tablaCotizaciones thead {
    background: #1e293b !important; /* Gris Pizarra elegante */
}

.tablaVentas thead tr th, .tablaGuias thead tr th, .tablaCotizaciones thead tr th {
    text-transform: uppercase !important;
    border: none !important;
    text-align: center;
    color: #f8fafc !important;
    font-weight: 600;
    font-size: 0.85em;
    padding: 12px 10px;
}

.tablaVentas tbody tr td, .tablaGuias tbody tr td, .tablaCotizaciones tbody tr td {
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
    vertical-align: middle;
}

/* ==============================================
   OTROS COMPONENTES
============================================== */
.dia {
    padding: 1px !important; width: 25px !important; height: 25px !important; margin-right: 0 !important;
    border-radius: 50% !important; background-image: url('../img/svg/sun.svg');
    background-size: 20px !important; background-position: center !important; background-repeat: no-repeat !important;
}
.noche {
    padding: 1px !important; width: 25px !important; height: 25px !important; margin-left: 0 !important;
    background-color: var(--text-main) !important; border-radius: 50% !important; background-image: url('../img/svg/luna.svg');
    background-size: 18px !important; background-position: center !important; background-repeat: no-repeat !important;
}

textarea {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important;
    border: 1px solid var(--border-color) !important;
    padding: 10px !important;
    outline: none !important;
}
textarea:focus { border-color: var(--primary) !important; }

/* Toggles / Modos Generales */
.modo-contenedor-selva { width: 180px; display: flex; flex-flow: column; justify-content: center; align-items: center; margin: 0px; }
@media (max-width: 430px) { .contenedor-selva { flex-flow: column; } .modo-contenedor-selva { width: 100%; } }

.modo-contenedor-selva .btn-success, .modo-contenedor-selva .btn-danger { border-style: none !important; border-radius: var(--radius-sm); }
.toggle-group .btn-success { background-color: var(--primary) !important; text-align: center !important; font-size: 0.9em !important; font-weight: 600; }
.toggle-group .btn-danger { background-color: var(--danger) !important; text-align: center !important; font-size: 0.9em !important; font-weight: 600; }
.toggle-handle.btn-default { border: none !important; width: 35px !important; border-radius: 0 !important; background-color: var(--bg-main) !important; }

.morris-hover-point { color: var(--text-main) !important; font-weight: 500; }
.btn-stock { border: none !important; outline: none !important; width: 100% !important; font-size: 0.9em !important; font-weight: 600 !important; }

/* Alerta de Acceso Restringido */
.alert-dangers.text-center {
    position: relative !important; width: 100% !important; height: 100% !important;
    display: flex; flex-flow: column; justify-content: center; align-items: center;
    color: var(--text-muted); padding: 40px; text-align: center;
}
.alert-dangers .img-restringido {
    width: 200px; height: 200px; border-radius: 50%;
    background-image: url('../img/ojos.png'); background-size: cover;
    background-position: center; background-repeat: no-repeat;
    box-shadow: var(--shadow-md); margin-bottom: 20px;
}
.alert-dangers h3 { font-weight: 600; color: var(--text-main); font-size: 1.5em; margin-top: 20px; }

@media (max-width: 430px){ .alert-dangers .img-restringido { width: 150px; height: 150px; } }