/* ================================================================
   ESTILOS PARA SOLICITUDES DE GASTO DISTRIBUIDAS
   ================================================================ */

/* ============= Correcciones de Modal ============= */
.modal-lg {
    max-width: 95vw !important;
    width: 1200px !important;
}

.modal-body {
    max-height: 75vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-footer {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

/* Asegurar que los form-groups tengan el ancho correcto */
.form-grid {
    display: grid;
    gap: 16px;
    width: 100%;
}

.form-grid.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.form-grid.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.form-group select,
.form-group input,
.form-group textarea {
    width: 100%;
    box-sizing: border-box;
}

/* ============= Toggle Tipo de Solicitud ============= */
.tipo-solicitud-section {
    margin-bottom: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 2px solid #dee2e6;
}

.tipo-solicitud-toggle {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.radio-card {
    flex: 1;
    max-width: 280px;
    cursor: pointer;
    position: relative;
}

.radio-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: white;
    border: 3px solid #dee2e6;
    border-radius: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.radio-card:hover .radio-card-content {
    border-color: #0066cc;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.15);
    transform: translateY(-2px);
}

.radio-card input[type="radio"]:checked + .radio-card-content {
    background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
    border-color: #0052a3;
    color: white;
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.3);
}

.radio-card-content i {
    font-size: 32px;
    color: #6c757d;
    transition: all 0.3s ease;
}

.radio-card input[type="radio"]:checked + .radio-card-content i {
    color: white;
    transform: scale(1.1);
}

.radio-card-content span {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    color: #495057;
    transition: color 0.3s ease;
}

.radio-card input[type="radio"]:checked + .radio-card-content span {
    color: white;
}

/* ============= Sección Distribuida ============= */
#seccionDistribuida {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============= Líneas de Distribución ============= */
#lineasContainer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.linea-distribucion {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.linea-distribucion:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.linea-distribucion.invalid {
    border-color: #dc3545;
    background: #fff5f5;
}

.linea-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    cursor: pointer;
    user-select: none;
}

.linea-header:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.linea-titulo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
    color: #495057;
}

.linea-titulo i {
    font-size: 18px;
    color: #0066cc;
    transition: transform 0.3s ease;
}

.linea-distribucion.collapsed .linea-titulo i {
    transform: rotate(-90deg);
}

.linea-titulo .badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #0066cc;
    color: white;
}

.linea-actions {
    display: flex;
    gap: 8px;
}

.linea-actions button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    color: #6c757d;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.linea-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.linea-actions .btn-clone {
    color: #17a2b8;
}

.linea-actions .btn-clone:hover {
    background: #17a2b8;
    color: white;
}

.linea-actions .btn-delete {
    color: #dc3545;
}

.linea-actions .btn-delete:hover {
    background: #dc3545;
    color: white;
}

.linea-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.linea-body {
    padding: 20px;
    display: none;
}

.linea-distribucion:not(.collapsed) .linea-body {
    display: block;
}

/* ============= Filtros y Datos de Línea ============= */
.filtros-linea {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.datos-linea {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group label i {
    font-size: 14px;
    color: #6c757d;
}

.form-group select,
.form-group input {
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.form-group select:focus,
.form-group input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-group select:disabled,
.form-group input:disabled {
    background: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ============= Monto Input Group ============= */
.monto-input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.monto-principal {
    display: flex;
    align-items: center;
    gap: 10px;
}

.monto-principal input {
    flex: 1;
    padding: 12px;
    border: 3px solid #dee2e6;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.monto-principal input:focus {
    border-color: #0066cc;
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.1);
}

.porcentaje-badge {
    padding: 8px 14px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 20px;
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(40, 167, 69, 0.3);
}

.btn-group-porcentaje {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-porcentaje {
    flex: 1;
    min-width: 60px;
    padding: 8px 12px;
    border: 2px solid #0066cc;
    background: white;
    color: #0066cc;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-porcentaje:hover {
    background: #0066cc;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.2);
}

.btn-porcentaje:active {
    transform: translateY(0);
}

.info-iva {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #e7f3ff;
    border: 2px solid #b3d9ff;
    border-radius: 6px;
    font-size: 13px;
}

.info-iva .label {
    color: #495057;
    font-weight: 600;
}

.info-iva .valor {
    color: #0066cc;
    font-weight: 700;
    font-size: 15px;
}

/* ============= Resumen de Distribución ============= */
.resumen-distribucion {
    margin-top: 24px;
    padding: 24px;
    background: white;
    border: 3px solid #dee2e6;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.resumen-distribucion h5 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 700;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 10px;
}

.resumen-distribucion h5 i {
    color: #0066cc;
    font-size: 20px;
}

.resumen-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.resumen-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.resumen-item label {
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.resumen-item span {
    font-size: 24px;
    font-weight: 700;
    color: #495057;
}

#spanTotalFactura,
#spanTotalFacturaGasto {
    color: #0066cc;
}

#spanDistribuido,
#spanDistribuidoGasto {
    color: #28a745;
}

#spanFaltante,
#spanFaltanteGasto {
    color: #dc3545;
}

#spanFaltante.completo,
#spanFaltanteGasto.completo {
    color: #28a745;
}

#spanFaltante.excedido,
#spanFaltanteGasto.excedido {
    color: #dc3545;
}

/* ============= Progress Bar ============= */
.progress-bar-container {
    width: 100%;
    height: 32px;
    background: #e9ecef;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    border-radius: 16px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-bar.incompleto {
    background: linear-gradient(90deg, #ffc107 0%, #ff9800 100%);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.progress-bar.excedido {
    background: linear-gradient(90deg, #dc3545 0%, #c82333 100%);
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.3);
}

.resumen-distribucion > span {
    display: block;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: #28a745;
}

.resumen-distribucion > span.incompleto {
    color: #ffc107;
}

.resumen-distribucion > span.excedido {
    color: #dc3545;
}

/* ============= Botón Agregar Línea ============= */
#btnAgregarLinea {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#btnAgregarLinea:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.3);
}

#btnAgregarLinea:active {
    transform: translateY(0);
}

#btnAgregarLinea i {
    font-size: 18px;
}

/* ============= Alertas y Validaciones ============= */
.linea-error {
    padding: 12px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 6px;
    color: #856404;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.linea-error i {
    color: #ffc107;
    font-size: 16px;
}

/* ============= Responsive ============= */
@media (max-width: 768px) {
    .tipo-solicitud-toggle {
        flex-direction: column;
    }
    
    .radio-card {
        max-width: 100%;
    }
    
    .filtros-linea,
    .datos-linea {
        grid-template-columns: 1fr;
    }
    
    .resumen-grid {
        grid-template-columns: 1fr;
    }
    
    .linea-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .linea-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .btn-group-porcentaje {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .monto-principal {
        flex-direction: column;
        align-items: stretch;
    }
    
    .porcentaje-badge {
        text-align: center;
    }
}

/* ============= Animaciones ============= */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.linea-distribucion {
    animation: slideIn 0.3s ease;
}

/* ============= Utilidades ============= */
.text-muted {
    color: #6c757d !important;
    font-size: 12px;
}

.text-success {
    color: #28a745 !important;
}

.text-warning {
    color: #ffc107 !important;
}

.text-danger {
    color: #dc3545 !important;
}

.badge-success {
    background: #28a745 !important;
}

.badge-warning {
    background: #ffc107 !important;
    color: #212529 !important;
}

.badge-danger {
    background: #dc3545 !important;
}
