<div class="container-fluid">
    <div class="row align-items-center justify-content-center">
        <div class="col-md-8">
            <div class="card my-4">
                <div class="card-header bg-danger text-white">
                    <h3><i class="fas fa-money-bill-wave"></i> Retiro de Caja</h3>
                </div>
                <div class="card-body">
                    <!-- Spinner de carga -->
                    <div class="mt-4 text-center" ng-if="loading">
                        <div class="spinner-border text-primary" role="status">
                            <span class="sr-only">Cargando...</span>
                        </div>
                        <p class="mt-2">Procesando...</p>
                    </div>
                    
                    <!-- Formulario de retiro -->
                    <div ng-if="!loading && caja">
                        <div class="alert alert-info mb-4">
                            <div class="row">
                                <div class="col-md-6">
                                    <p class="mb-0"><strong>ID Caja:</strong> {{ caja.id }}</p>
                                    <p class="mb-0"><strong>Fecha Apertura:</strong> {{ caja.fecha_apertura | date:'dd/MM/yyyy HH:mm' }}</p>
                                </div>
                                <div class="col-md-6 text-right">
                                    <h4 class="text-success mb-0">Saldo Actual: $ {{ caja.saldo | number:2 }}</h4>
                                </div>
                            </div>
                        </div>
                        
                        <form ng-submit="submit()">
                            <div class="form-group">
                                <label>Monto a Retirar:</label>
                                <div class="input-group">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">$</span>
                                    </div>
                                    <input type="number" class="form-control" ng-model="form.monto" required min="1" max="{{ caja.saldo }}" step="0.01">
                                </div>
                                <small class="form-text text-muted">El monto máximo a retirar es $ {{ caja.saldo | number:2 }}</small>
                            </div>
                            
                            <div class="form-group">
                                <label>Concepto:</label>
                                <input type="text" class="form-control" ng-model="form.concepto" required maxlength="200">
                            </div>
                            
                            <div class="form-group">
                                <label>Observaciones:</label>
                                <textarea class="form-control" ng-model="form.observaciones" rows="3"></textarea>
                            </div>
                            
                            <div class="row mt-4">
                                <div class="col-md-6">
                                    <button type="button" class="btn btn-secondary btn-block" ng-click="cancelar()">
                                        <i class="fas fa-times"></i> Cancelar
                                    </button>
                                </div>
                                <div class="col-md-6">
                                    <button type="submit" class="btn btn-primary btn-block" ng-disabled="!form.monto || !form.concepto">
                                        <i class="fas fa-save"></i> Realizar Retiro
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>