/* ========================================
   Select2 CSS Compatible con DashLite
   ======================================== */

/* Container principal */
.select2-container {
    box-sizing: border-box;
    display: inline-block;
    margin: 0;
    position: relative;
    vertical-align: middle;
}

.select2-container .select2-selection--single {
    box-sizing: border-box;
    cursor: pointer;
    display: block;
    height: calc(2.125rem + 2px); /* Altura consistente con form-control */
    user-select: none;
    -webkit-user-select: none;
}

/* Selección single - EXACTO de DashLite */
.select2-container--bootstrap-5 .select2-selection--single {
    display: block;
    width: 100%;
    padding: 0.4375rem 1rem; /* Padding exacto DashLite */
    font-size: 0.8125rem; /* Font size exacto DashLite */
    font-weight: 400; /* Font weight exacto DashLite */
    line-height: 1.25rem; /* Line height exacto DashLite */
    color: #3c4d62; /* Color exacto DashLite */
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #dbdfea; /* Border exacto DashLite */
    appearance: none;
    border-radius: 4px; /* Border radius exacto DashLite */
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; /* Transition exacto DashLite */
    height: calc(2.125rem + 2px); /* Altura consistente con form-control */
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* Focus state - EXACTO de DashLite */
.select2-container--bootstrap-5 .select2-selection--single:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection--single {
    color: #3c4d62;
    background-color: #fff;
    border-color: #854fff; /* Color focus exacto DashLite */
    outline: 0;
    box-shadow: 0 0 0 3px rgba(133, 79, 255, 0.1); /* Box shadow exacto DashLite */
}

/* Arrow/dropdown indicator */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: calc(2.125rem);
    position: absolute;
    top: 0;
    right: 0.75rem;
    width: 20px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow b {
    border-color: #8094ae transparent transparent transparent; /* Color de la flecha DashLite */
    border-style: solid;
    border-width: 5px 4px 0 4px;
    height: 0;
    left: 50%;
    margin-left: -4px;
    margin-top: -2px;
    position: absolute;
    top: 50%;
    width: 0;
}

/* Arrow cuando está abierto */
.select2-container--bootstrap-5.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #8094ae transparent;
    border-width: 0 4px 5px 4px;
}

/* Placeholder */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
    color: #8094ae; /* Color placeholder DashLite */
    cursor: text;
}

/* Texto seleccionado */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: #3c4d62;
    line-height: 1.25rem;
    padding-left: 0;
    padding-right: 20px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Clear button */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear {
    background-color: transparent;
    border: none;
    color: #8094ae;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    margin-right: 10px;
    padding: 0;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__clear:hover {
    color: #526484;
}

/* Dropdown container */
.select2-container--bootstrap-5 .select2-dropdown {
    background-color: #fff;
    border: 1px solid #dbdfea;
    border-radius: 4px;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); /* Box shadow DashLite */
    color: #3c4d62;
    font-size: 0.8125rem;
    margin-top: 2px;
}

/* Search input en dropdown - EXACTO de DashLite */
.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    display: block;
    width: calc(100% - 1rem);
    padding: 0.4375rem 1rem; /* Padding exacto DashLite */
    font-size: 0.8125rem; /* Font size exacto DashLite */
    font-weight: 400; /* Font weight exacto DashLite */
    line-height: 1.25rem; /* Line height exacto DashLite */
    color: #3c4d62; /* Color exacto DashLite */
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #dbdfea; /* Border exacto DashLite */
    appearance: none;
    border-radius: 4px; /* Border radius exacto DashLite */
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out; /* Transition exacto DashLite */
    margin: 0.5rem;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus {
    color: #3c4d62;
    background-color: #fff;
    border-color: #854fff; /* Color focus exacto DashLite */
    outline: 0;
    box-shadow: 0 0 0 3px rgba(133, 79, 255, 0.1); /* Box shadow exacto DashLite */
}

/* Resultados */
.select2-container--bootstrap-5 .select2-results > .select2-results__options {
    max-height: 200px;
    overflow-y: auto;
    padding: 0;
}

.select2-container--bootstrap-5 .select2-results__option {
    background-color: #fff;
    color: #3c4d62;
    cursor: pointer;
    display: block;
    padding: 0.5rem 1rem;
    user-select: none;
    -webkit-user-select: none;
}

/* Hover en opciones */
.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: #f8f9fa; /* Background hover DashLite */
    color: #526484;
}

/* Opción seleccionada */
.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"] {
    background-color: #e3ebf6; /* Background selected DashLite */
    color: #526484;
}

/* Estados especiales */
.select2-container--bootstrap-5 .select2-results__option--loading,
.select2-container--bootstrap-5 .select2-results__option--searching {
    color: #8094ae;
    cursor: default;
    font-style: italic;
}

/* Selección múltiple */
.select2-container--bootstrap-5 .select2-selection--multiple {
    background-color: #fff;
    border: 1px solid #dbdfea;
    border-radius: 4px;
    color: #3c4d62;
    cursor: text;
    font-size: 0.8125rem;
    min-height: calc(2.125rem + 2px);
    padding: 0.25rem 0.5rem;
    position: relative;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Focus para selección múltiple - EXACTO de DashLite */
.select2-container--bootstrap-5 .select2-selection--multiple:focus,
.select2-container--bootstrap-5.select2-container--focus .select2-selection--multiple {
    color: #3c4d62;
    background-color: #fff;
    border-color: #854fff; /* Color focus exacto DashLite */
    outline: 0;
    box-shadow: 0 0 0 3px rgba(133, 79, 255, 0.1); /* Box shadow exacto DashLite */
}

/* Tags en selección múltiple */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: #526484; /* Color primary DashLite */
    border: 1px solid #526484;
    border-radius: 3px;
    box-sizing: border-box;
    color: #fff;
    cursor: default;
    display: inline-block;
    font-size: 0.75rem;
    margin: 0.125rem 0.25rem 0.125rem 0;
    padding: 0.25rem 0.5rem;
    user-select: none;
    -webkit-user-select: none;
}

/* Remove button en tags */
.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
    background-color: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: inline-block;
    font-size: 0.75rem;
    font-weight: bold;
    margin-left: 0.25rem;
    margin-right: -0.25rem;
    padding: 0;
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #fff;
}

/* Input de búsqueda en múltiple */
.select2-container--bootstrap-5 .select2-search--inline .select2-search__field {
    background: transparent;
    border: none;
    color: #3c4d62;
    font-size: 0.8125rem;
    margin: 0;
    max-width: 100%;
    outline: 0;
    padding: 0;
}

/* Estados disabled */
.select2-container--bootstrap-5.select2-container--disabled .select2-selection {
    background-color: #ebeef2; /* Background disabled DashLite */
    border-color: #dbdfea;
    color: #8094ae;
    cursor: not-allowed;
}

.select2-container--bootstrap-5.select2-container--disabled .select2-selection--single .select2-selection__arrow b {
    border-color: #8094ae transparent transparent transparent;
}

/* Mensajes especiales */
.select2-results__message {
    color: #8094ae;
    cursor: default;
    font-style: italic;
    padding: 0.5rem 1rem;
}

/* Loader */
.select2-results__option--loading-results {
    color: #8094ae;
    cursor: default;
    font-style: italic;
    padding: 0.5rem 1rem;
}

/* Ajustes para elementos pequeños */
.form-control-sm ~ .select2-container--bootstrap-5 .select2-selection--single {
    height: calc(1.75rem + 2px);
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
}

.form-control-sm ~ .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: calc(1.75rem);
    right: 0.5rem;
}

/* Ajustes para elementos grandes */
.form-control-lg ~ .select2-container--bootstrap-5 .select2-selection--single {
    height: calc(2.625rem + 2px);
    font-size: 0.9375rem;
    padding: 0.6875rem 1.25rem;
}

.form-control-lg ~ .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: calc(2.625rem);
    right: 1rem;
}

/* Integración con form-group */
.form-group .select2-container {
    width: 100% !important;
}

/* Fix para z-index en modales */
.modal .select2-container {
    z-index: 1051;
}

.modal .select2-dropdown {
    z-index: 1052;
}

.sales-lines-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border: 1px solid #dbdfea;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    font-size: 0.8125rem;
    color: #526484;
}

/* Container de línea de producto */
.product-line-enhanced {
    border: 1px solid #dbdfea;
    border-top: none;
    background-color: #fff;
    transition: all 0.2s ease;
}

.product-line-enhanced:hover {
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.product-line-enhanced:last-child {
    border-radius: 0 0 6px 6px;
}

/* Formulario interno */
.line-form {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin: 0;
}

/* Columnas flexibles */
.line-col {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
}

.line-col .form-group {
    margin-bottom: 0;
    width: 100%;
}

/* Tamaños de columnas */
.col-description {
    flex: 3; /* Más ancha para descripción */
    position: relative;
}

.col-quantity {
    flex: 1;
    min-width: 80px;
}

.col-price {
    flex: 1.2;
    min-width: 100px;
}

.col-discount {
    flex: 1;
    min-width: 80px;
}

.col-total {
    flex: 1.2;
    min-width: 100px;
}

.col-actions {
    flex: 0 0 100px;
    justify-content: center;
}

/* Número de línea */
.line-number {
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    background: #526484;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 2;
}

/* Inputs personalizados */
.line-col .form-control {
    border: 1px solid transparent;
    background-color: transparent;
    transition: all 0.2s ease;
}

.line-col .form-control:focus {
    border-color: #854fff;
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(133, 79, 255, 0.1);
}

.line-col .form-control:hover:not(:disabled) {
    border-color: #dbdfea;
    background-color: #fff;
}

/* Text hints para moneda y porcentaje */
.form-text-hint {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #8094ae;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 3;
}

.form-text-hint-right {
    left: auto;
    right: 0.75rem;
}

.form-text-hint + input {
    padding-left: 1.5rem;
}

.form-text-hint-right + input {
    padding-right: 1.5rem;
}

/* Display de cantidad/total */
.amount-display {
    text-align: center;
    padding: 0.25rem;
}

.amount-value {
    font-weight: 600;
    color: #526484;
    font-size: 0.875rem;
}

/* Botones de acción */
.col-actions .btn-group {
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.col-actions .btn {
    border-radius: 0;
    border-right: 1px solid #dbdfea;
}

.col-actions .btn:last-child {
    border-right: none;
}

/* Responsive */
@media (max-width: 768px) {
    .sales-lines-header {
        display: none;
    }
    
    .line-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .line-col {
        flex: none;
        padding: 0;
    }
    
    .line-col::before {
        content: attr(data-label);
        font-weight: 600;
        color: #526484;
        font-size: 0.75rem;
        display: block;
        margin-bottom: 0.25rem;
    }
    
    .col-description::before { content: "Descripción:"; }
    .col-quantity::before { content: "Cantidad:"; }
    .col-price::before { content: "Precio Unit.:"; }
    .col-discount::before { content: "Descuento:"; }
    .col-total::before { content: "Total:"; }
    .col-actions::before { content: "Acciones:"; }
}

/* Fix para que el contenido no quede oculto bajo el header fijo */
.nk-content {
    padding-top: 6rem;
}

/* Ajustar según dispositivo */
@media (max-width: 991px) {
    .nk-content {
        padding-top: 5.5rem;
    }
}

@media (max-width: 767px) {
    .nk-content {
        padding-top: 5rem;
    }
}

/* Dark mode */
.dark-mode .nk-content {
    padding-top: 6rem;
}