/* Portal de Vendedores - Estilos personalizados */

/* ===== AJUSTE GLOBAL DE FUENTES ===== */
/* Reducción de tamaños para mejor legibilidad */
.wcsat-portal-container {
    font-size: 0.875rem; /* 14px base en lugar de 16px */
    min-height: 100vh;
    background-color: #f8f9fa;
    padding-top: 20px; /* Altura del navbar fijo */
}

/* Headings ajustados */
.wcsat-portal-container h1,
.wcsat-portal-container .h1 {
    font-size: 1.5rem; /* 24px */
    font-weight: 600;
}

.wcsat-portal-container h2,
.wcsat-portal-container .h2 {
    font-size: 1.175rem; /* 18.8px */
    font-weight: 600;
}

.wcsat-portal-container h3,
.wcsat-portal-container .h3 {
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
}

.wcsat-portal-container h4,
.wcsat-portal-container .h4 {
    font-size: 1.125rem; /* 18px en lugar de ~20px */
    font-weight: 600;
}

.wcsat-portal-container h5,
.wcsat-portal-container .h5 {
    font-size: 1rem; /* 16px en lugar de ~18px */
    font-weight: 600;
}

.wcsat-portal-container h6,
.wcsat-portal-container .h6 {
    font-size: 0.875rem; /* 14px */
    font-weight: 600;
}

/* Tablas más compactas */
.wcsat-portal-container table {
    font-size: 0.8125rem; /* 13px para tablas */
}

.wcsat-portal-container table th {
    font-size: 0.8125rem; /* 13px */
    font-weight: 600;
}

.wcsat-portal-container table td {
    font-size: 0.8125rem; /* 13px */
}

/* Botones: borde gris tenue y sombra leve estilo Bootstrap base */
.wcsat-portal-container .btn {
    font-size: 0.8125rem; /* 13px */
    padding: 0.375rem 0.75rem;
    border-radius: 0.3125rem;
    border: 1px solid #9ca3af;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Respeto al color de borde propio de cada variante Bootstrap */
.wcsat-portal-container .btn-primary      { border-color: #1d4ed8; }
.wcsat-portal-container .btn-secondary    { border-color: #6b7280; }
.wcsat-portal-container .btn-success      { border-color: #15803d; }
.wcsat-portal-container .btn-danger       { border-color: #b91c1c; }
.wcsat-portal-container .btn-warning      { border-color: #b45309; }
.wcsat-portal-container .btn-info         { border-color: #0369a1; }
.wcsat-portal-container .btn-light        { border-color: #9ca3af; }
.wcsat-portal-container .btn-dark         { border-color: #374151; }
.wcsat-portal-container .btn-outline-primary   { border-color: #1d4ed8; }
.wcsat-portal-container .btn-outline-secondary { border-color: #6b7280; }
.wcsat-portal-container .btn-outline-success   { border-color: #15803d; }
.wcsat-portal-container .btn-outline-danger    { border-color: #b91c1c; }
.wcsat-portal-container .btn-outline-warning   { border-color: #b45309; }
.wcsat-portal-container .btn-outline-info      { border-color: #0369a1; }
.wcsat-portal-container .btn-outline-light     { border-color: #d1d5db; }
.wcsat-portal-container .btn-outline-dark      { border-color: #374151; }

/* Botones con solo íconos - padding uniforme para centrado perfecto */
.wcsat-portal-container .btn > i:only-child,
.wcsat-portal-container .btn > .bi:only-child {
    margin: 0;
}

.wcsat-portal-container .btn:has(> i:only-child),
.wcsat-portal-container .btn:has(> .bi:only-child) {
    padding: 0.4375rem 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
}

/*
 * Clase explícita para botones que solo contienen un ícono.
 * Usar: <button class="btn btn-outline-secondary btn-icon">...
 */
.wcsat-portal-container .btn-icon {
    padding: 0.4375rem 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    line-height: 1;
}

.wcsat-portal-container .btn-icon > i,
.wcsat-portal-container .btn-icon > .bi {
    margin: 0;
    font-size: 0.9375rem;
}

.wcsat-portal-container .btn-sm {
    font-size: 0.75rem; /* 12px */
    padding: 0.25rem 0.5rem;
    border-radius: 0.3125rem;
}

/* Botones pequeños con solo íconos */
.wcsat-portal-container .btn-sm:has(> i:only-child),
.wcsat-portal-container .btn-sm:has(> .bi:only-child) {
    padding: 0.3125rem 0.4375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
}

.wcsat-portal-container .btn-sm.btn-icon {
    padding: 0.3125rem 0.4375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    line-height: 1;
}

/* Labels y forms */
.wcsat-portal-container label,
.wcsat-portal-container .form-label {
    font-size: 0.8125rem; /* 13px */
    margin-bottom: 0.25rem;
}

.wcsat-portal-container .form-control,
.wcsat-portal-container .form-select {
    font-size: 0.8125rem; /* 13px */
    padding: 0.375rem 0.75rem;
    border-radius: 0.3125rem; /* 2px - border radius mínimo */
}

/* Badges más pequeños */
.wcsat-portal-container .badge {
    font-size: 0.75rem; /* 12px */
    padding: 0.25em 0.5em;
}

/* Card headers */
.wcsat-portal-container .card-header h5,
.wcsat-portal-container .card-header .h5 {
    font-size: 1rem; /* 16px */
    margin-bottom: 0;
}

/* Modals */
.wcsat-portal-container .modal-title {
    font-size: 1.125rem; /* 18px */
}

.wcsat-portal-container .modal-body {
    font-size: 0.875rem; /* 14px */
}

/* ===== FIN AJUSTE DE FUENTES ===== */

/* SweetAlert2 Customization */
.swal2-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border-radius: 0.5rem;
}

.swal2-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.swal2-html-container {
    font-size: 1rem;
}

.swal2-confirm {
    padding: 0.5rem 2rem;
    font-weight: 500;
}

/* Navbar fijo */
.navbar.fixed-top {
    z-index: 1030;
    border-bottom: 1px solid #dee2e6;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 66px; /* Altura del navbar */
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    overflow-y: auto;
    width: 280px !important; /* Ancho fijo cuando está expandido */
    max-width: 280px !important; /* Sobrescribir clases de Bootstrap */
    flex: 0 0 280px !important; /* Sobrescribir flex de Bootstrap */
    transition: width 0.3s ease, transform 0.3s ease;
    background-color: #f8f9fa;
}

/* Sidebar colapsado */
.sidebar.collapsed {
    width: 80px !important; /* Ancho cuando está colapsado */
    max-width: 80px !important; /* Sobrescribir clases de Bootstrap */
    flex: 0 0 80px !important; /* Sobrescribir flex de Bootstrap */
}

.sidebar.collapsed .text-wrapper {
    display: none; /* Ocultar texto cuando está colapsado */
}

.sidebar.collapsed .nav-link {
    padding: 1rem 0.75rem;
    justify-content: center;
}

.sidebar.collapsed .nav-link .icon-wrapper {
    margin: 0;
}

.sidebar.collapsed .nav-link .icon-wrapper i {
    font-size: 1.2rem;
}

.sidebar.collapsed .nav-link.has-submenu .bi-chevron-down {
    display: none;
}

.sidebar.collapsed .collapse {
    display: none !important; /* Ocultar submenús cuando está colapsado */
}

/* Botón toggle del sidebar */
#sidebar-toggle {
    color: #6c757d;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

#sidebar-toggle:hover {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

#sidebar-toggle:focus {
    box-shadow: none !important;
}

/* Ocultar sidebar en móvil */
@media (max-width: 991.98px) {
    .sidebar {
        display: none;
    }
    
    .wcsat-portal-container {
        padding-top: 66px;
    }
    
    .wcsat-portal-container main {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .wcsat-content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

.sidebar .nav-link {
    font-weight: 500;
    color: #333;
    padding: 1rem 1.5rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
}

.sidebar .nav-link .icon-wrapper {
    display: flex;
    align-items: center;
    min-width: 20px;
}

.sidebar .nav-link .text-wrapper {
    margin-left: 0.5rem;
    white-space: nowrap;
}

.sidebar .nav-link.has-submenu {
    justify-content: space-between;
}

.sidebar .nav-link:hover {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.sidebar .nav-link.active {
    color: #007bff;
    background-color: rgba(0, 123, 255, 0.15);
    border-left: 3px solid #007bff;
}

.sidebar .nav-link i {
    margin-right: 0.5rem;
}

/* Content area - Main container */
/* Sobrescribir clases de Bootstrap Grid para el main */
.wcsat-portal-container main {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* Content wrapper - ajuste según estado del sidebar */
.wcsat-content-wrapper {
    padding-top: 2.5rem;
    padding-bottom: 3rem;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: 280px; /* Margen para sidebar expandido por defecto - debe coincidir con el ancho del sidebar */
    transition: margin-left 0.3s ease, width 0.3s ease;
    width: calc(100% - 280px); /* Asegurar que el contenido no se superponga */
}

/* Ajuste del contenido cuando el sidebar está colapsado */
body.sidebar-collapsed .wcsat-content-wrapper {
    margin-left: 80px; /* Margen para sidebar colapsado - debe coincidir con el ancho del sidebar colapsado */
    width: calc(100% - 80px); /* Ajustar ancho cuando el sidebar está colapsado */
}

/* Asegurar que las tablas y contenido interno también se ajusten */
body.sidebar-collapsed .table-responsive,
body.sidebar-collapsed .card,
body.sidebar-collapsed .container-fluid {
    max-width: 100%;
}

/* Ajuste responsive */
@media (max-width: 991.98px) {
    .wcsat-portal-container main {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .wcsat-content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    body.sidebar-collapsed .wcsat-portal-container main,
    body.sidebar-collapsed .wcsat-content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* Cards */
.card {
    border: none;
    border-radius: 0.3125rem; /* 2px - border radius mínimo */
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}


/* Tables */
.table {
    background-color: white;
    border-radius: 0.3125rem; /* 2px - border radius mínimo */
    overflow: hidden;
}

/* Navbar */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

/* Responsive adjustments */
@media (max-width: 767.98px) {
    .sidebar {
        position: static;
        height: auto;
    }
    
    main {
        padding-top: 1rem;
    }
}

/* Navbar personalizado */
.navbar-brand img {
    max-height: 40px;
    width: auto;
    object-fit: contain;
}

.navbar-light .navbar-brand {
    color: #212529;
    font-weight: 600;
}

.navbar-light .navbar-brand:hover {
    color: #007bff;
}

.navbar-text {
    color: #6c757d !important;
}

/* Menú colapsable en móvil */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: white;
        padding: 1rem;
        margin-top: 0.5rem;
        border-radius: 0.3125rem; /* 2px - border radius mínimo */
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }
}

/* Loading spinner */
.wcsat-loading {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: text-bottom;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Badges */
.badge {
    padding: 0.35em 0.65em;
    font-weight: 600;
}

/* Utility classes */
.text-muted {
    color: #6c757d !important;
}

.border-bottom {
    border-bottom: 1px solid #dee2e6 !important;
}

/* ================== CREACIÓN DE PEDIDOS ================== */

/* Modal de creación de pedidos */
#createOrderModal .modal-xl {
    max-width: 1200px;
}

#createOrderModal .modal-body {
    max-height: calc(100vh - 200px); /* Aumentado 200px más de altura */
    overflow-y: auto;
}

/* Resultados de búsqueda */
#searchResults {
    position: relative;
    z-index: 1050;
    background: white;
    border-radius: 0.3125rem; /* 2px - border radius mínimo */
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

#searchResults .list-group-item {
    cursor: pointer;
    border: 1px solid #dee2e6;
    transition: background-color 0.2s;
}

#searchResults .list-group-item:hover {
    background-color: #f8f9fa;
}

/* Productos frecuentes */
.wcsat-frequent-product {
}

.wcsat-frequent-product:hover {
}

/* Direcciones del cliente */
#billingAddress,
#shippingAddress {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #495057;
}

#billingAddress .spinner-border,
#shippingAddress .spinner-border {
    margin: 0.5rem 0;
}

/* Carrito de compras */
.wcsat-cart-container {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 350px); /* Altura total del contenedor del carrito */
}

.wcsat-cart-container .card-body {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
    max-height: calc(100vh - 500px); /* Altura dinámica para scroll de productos */
}

#cartItems .list-group-item {
    padding: 0.75rem;
    border: none;
    border-bottom: 1px solid #dee2e6;
}

#cartItems .list-group-item:last-child {
    border-bottom: none;
}

#cartItems > p {
    padding: 1rem;
}

.wcsat-cart-quantity {
    max-width: 60px;
}

/* Footer fijo del carrito (totales) */
.wcsat-cart-container .card-footer {
    position: sticky;
    bottom: 0;
    background-color: #f8f9fa;
    z-index: 10;
    border-top: 2px solid #dee2e6;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
}

/* Botones del modal */
#createOrderBtn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wcsat-product-item {
    animation: fadeIn 0.3s ease-in-out;
}

/* Sticky cart */
.card.sticky-top {
    position: sticky;
    top: 20px;
}

/* Scroll suave para el carrito */
#cartItems {
    scrollbar-width: thin;
    scrollbar-color: #6c757d #f1f1f1;
}

#cartItems::-webkit-scrollbar {
    width: 8px;
}

#cartItems::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

#cartItems::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 5px;
}

#cartItems::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

/* Responsive para modal */
@media (max-width: 767.98px) {
    #createOrderModal .modal-xl {
        max-width: 95%;
    }
    
    #createOrderModal .modal-body {
        max-height: calc(100vh - 150px);
    }
    
    .wcsat-cart-container {
        max-height: 500px;
    }
    
    .wcsat-cart-container .card-body {
        max-height: 350px;
    }
    
    .card.sticky-top {
        position: relative;
        top: 0;
    }
}

/* ===== NOTA DE ENTREGA - Oculta en pantalla ===== */
.delivery-note-container {
    display: none;
}

/* ===== INCENTIVOS ESCALONADOS ===== */
/* Filas colapsables de incentivos */
.incentive-month-row {
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

.incentive-month-row:hover {
    background-color: rgba(255, 193, 7, 0.15) !important;
}

.incentive-month-row .incentive-chevron {
    transition: transform 0.2s ease;
    font-size: 0.875rem;
}

.incentive-month-row[aria-expanded="true"] .incentive-chevron {
    transform: rotate(90deg);
}

/* Contenido colapsable del desglose */
.incentive-breakdown {
    background-color: #f8f9fa;
}

.incentive-breakdown > td {
    padding: 0 !important;
    border-top: none !important;
}

.incentive-breakdown .p-3 {
    border-left: 4px solid #ffc107;
}

/* Tabla de desglose */
.incentive-breakdown table {
    font-size: 0.8125rem;
    margin-bottom: 0;
}

.incentive-breakdown table th,
.incentive-breakdown table td {
    padding: 0.5rem 0.75rem;
}

/* Indicadores de tramo alcanzado */
.incentive-breakdown .bi-check-circle-fill {
    color: #198754;
}

.incentive-breakdown .bi-circle {
    color: #adb5bd;
}

/* Badge de total en header */
.card-header .badge.bg-dark {
    font-size: 0.875rem;
    padding: 0.5em 0.75em;
}

/* Animación suave para collapse */
.incentive-breakdown.collapsing {
    transition: height 0.25s ease;
}

/* Responsive para tabla de incentivos */
@media (max-width: 767.98px) {
    .incentive-breakdown .table-responsive {
        font-size: 0.75rem;
    }
    
    .incentive-breakdown table th,
    .incentive-breakdown table td {
        padding: 0.375rem 0.5rem;
    }
}

/* ===== BADGE CLICKEABLE - COBERTURA ===== */
/* Estilos para badges de cobertura que navegan a Customer Coverage Detail */
.badge-link {
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge-link:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
    text-decoration: underline !important;
}

.badge-link:active {
    transform: translateY(0);
}

.badge-link i {
    font-size: 0.75em;
    opacity: 0.8;
}

.badge-link:hover i {
    opacity: 1;
}

/* ===== ESTILOS PARA NOTAS DE CRÉDITO ===== */

/* Fila de factura con nota de crédito */
.invoice-row-with-credit-note {
    background-color: #fff9c4 !important; /* Amarillo claro */
}

.invoice-row-with-credit-note:hover {
    background-color: #fff59d !important; /* Amarillo más intenso al hover */
}

/* Fila de factura completamente anulada */
.invoice-row-voided {
    background-color: #ffebee !important; /* Rojo claro */
    opacity: 0.75;
}

.invoice-row-voided:hover {
    opacity: 0.85;
}

/* Badge de nota de crédito */
.credit-note-badge {
    display: inline-block;
    padding: 3px 8px;
    background: #ff9800;
    color: white;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: help;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.credit-note-badge:hover {
    background: #f57c00;
}

/* Monto tachado (bruto) */
.amount-strikethrough {
    text-decoration: line-through;
    color: #999;
    margin-right: 8px;
    font-size: 0.9em;
}

/* Monto neto (después de NC) */
.net-amount {
    font-weight: bold;
    color: #2e7d32; /* Verde */
}

.invoice-row-voided .net-amount {
    color: #d32f2f; /* Rojo para facturas anuladas */
    text-decoration: line-through;
}

/* Badge de ANULADA */
.voided-badge {
    background: #f44336;
    color: white;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Tooltips de Bootstrap personalizados */
.tooltip-inner {
    max-width: 300px;
    text-align: left;
}

/* Ajustes responsivos */
@media (max-width: 768px) {
    .credit-note-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .voided-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* =========================================================
   Tabla ordenable - Customer Coverage
   ========================================================= */

/* Encabezado de columna con soporte de ordenamiento */
.wcsat-sortable-th {
    white-space: nowrap;
    user-select: none;
}

/* Enlace de ordenamiento */
.wcsat-sortable-th a {
    cursor: pointer;
    transition: color 0.15s ease-in-out;
}

.wcsat-sortable-th a:hover {
    color: #0d6efd !important;
}

/* Columna activamente ordenada */
.wcsat-sort-active a {
    color: #0d6efd !important;
    font-weight: 600;
}
