<!-- PaperclipChain Staking Interface -->
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">
                    <h2>Staking & Delegation
                        <small>Earn rewards by staking your CLIPS</small>
                    </h2>
                </div>
                <div class="card-body">
                    <!-- Staking Overview -->
                    <div class="row mb-4">
                        <div class="col-md-3">
                            <div class="info-box bg-clips">
                                <div class="info-box-icon">
                                    <i class="fas fa-coins"></i>
                                </div>
                                <div class="info-box-content">
                                    <span class="info-box-text">Total Staked</span>
                                    <span class="info-box-number" id="totalStakedAmount">0 CLIPS</span>
                                    <div class="progress">
                                        <div class="progress-bar" style="width: 0%" id="totalStakedProgress"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="info-box bg-success">
                                <div class="info-box-icon">
                                    <i class="fas fa-trophy"></i>
                                </div>
                                <div class="info-box-content">
                                    <span class="info-box-text">Pending Rewards</span>
                                    <span class="info-box-number" id="pendingRewards">0 CLIPS</span>
                                    <div class="progress">
                                        <div class="progress-bar bg-success" style="width: 0%" id="rewardsProgress"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="info-box bg-warning">
                                <div class="info-box-icon">
                                    <i class="fas fa-users"></i>
                                </div>
                                <div class="info-box-content">
                                    <span class="info-box-text">Active Validators</span>
                                    <span class="info-box-number" id="activeValidators">0</span>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="info-box bg-info">
                                <div class="info-box-icon">
                                    <i class="fas fa-percentage"></i>
                                </div>
                                <div class="info-box-content">
                                    <span class="info-box-text">Network APY</span>
                                    <span class="info-box-number" id="networkAPY">~8%</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Quick Actions -->
                    <div class="row mb-4">
                        <div class="col-md-12">
                            <div class="card">
                                <div class="card-header">
                                    <h3 class="card-title">Quick Actions</h3>
                                </div>
                                <div class="card-body">
                                    <div class="btn-group" role="group">
                                        <button type="button" class="btn btn-clips" id="btnDelegate">
                                            <i class="fas fa-arrow-up"></i> Delegate
                                        </button>
                                        <button type="button" class="btn btn-warning" id="btnUndelegate">
                                            <i class="fas fa-arrow-down"></i> Undelegate
                                        </button>
                                        <button type="button" class="btn btn-success" id="btnClaimRewards">
                                            <i class="fas fa-gift"></i> Claim Rewards
                                        </button>
                                        <button type="button" class="btn btn-info" id="btnCreateValidator">
                                            <i class="fas fa-plus"></i> Become Validator
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Validators List -->
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card">
                                <div class="card-header">
                                    <h3 class="card-title">Validators</h3>
                                    <div class="card-tools">
                                        <button type="button" class="btn btn-tool" id="btnRefreshValidators" data-toggle="tooltip" title="Refresh">
                                            <i class="fas fa-sync"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered" id="validatorsTable">
                                            <thead>
                                                <tr>
                                                    <th>Validator</th>
                                                    <th>Status</th>
                                                    <th>Self Stake</th>
                                                    <th>Delegated</th>
                                                    <th>Commission</th>
                                                    <th>APY</th>
                                                    <th>Your Stake</th>
                                                    <th>Actions</th>
                                                </tr>
                                            </thead>
                                            <tbody id="validatorsTableBody">
                                                <!-- Validators will be populated here -->
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Delegate Modal -->
<div id="dlgDelegate" class="modalDialog" data-izimodal-title="Delegate to Validator" data-izimodal-subtitle="Stake your CLIPS to earn rewards" data-izimodal-icon="icon-home">
    <div class="modalBody">
        <div class="form-group">
            <label for="delegateValidator">Select Validator:</label>
            <select class="form-control" id="delegateValidator">
                <option value="">Select a validator...</option>
            </select>
        </div>
        <div class="form-group">
            <label for="delegateAmount">Amount to Delegate (CLIPS):</label>
            <input type="number" class="form-control" id="delegateAmount" placeholder="Minimum 100 CLIPS" min="100" step="0.000001">
            <small class="form-text text-muted">Available balance: <span id="availableBalance">0 CLIPS</span></small>
        </div>
        <div class="form-group">
            <label for="delegateWallet">From Wallet:</label>
            <select class="form-control" id="delegateWallet">
                <!-- Wallets will be populated here -->
            </select>
        </div>
        <button type="button" class="btn btn-secondary btn-dialog-cancel" id="btnDelegateCancel">Cancel</button>
        <button type="button" class="btn btn-clips btn-dialog-confirm" id="btnDelegateConfirm">Delegate</button>
    </div>
</div>

<!-- Undelegate Modal -->
<div id="dlgUndelegate" class="modalDialog" data-izimodal-title="Undelegate from Validator" data-izimodal-subtitle="Withdraw your staked CLIPS" data-izimodal-icon="icon-home">
    <div class="modalBody">
        <div class="form-group">
            <label for="undelegateValidator">Validator:</label>
            <select class="form-control" id="undelegateValidator">
                <option value="">Select a validator...</option>
            </select>
        </div>
        <div class="form-group">
            <label for="undelegateAmount">Amount to Undelegate (CLIPS):</label>
            <input type="number" class="form-control" id="undelegateAmount" placeholder="Enter amount" min="0.000001" step="0.000001">
            <small class="form-text text-muted">Your stake: <span id="yourStakeAmount">0 CLIPS</span></small>
        </div>
        <div class="form-group">
            <label for="undelegateWallet">To Wallet:</label>
            <select class="form-control" id="undelegateWallet">
                <!-- Wallets will be populated here -->
            </select>
        </div>
        <div class="alert alert-warning">
            <i class="fas fa-exclamation-triangle"></i>
            <strong>Note:</strong> Undelegated funds may have a cooldown period before they become available.
        </div>
        <button type="button" class="btn btn-secondary btn-dialog-cancel" id="btnUndelegateCancel">Cancel</button>
        <button type="button" class="btn btn-warning btn-dialog-confirm" id="btnUndelegateConfirm">Undelegate</button>
    </div>
</div>

<!-- Create Validator Modal -->
<div id="dlgCreateValidator" class="modalDialog" data-izimodal-title="Become a Validator" data-izimodal-subtitle="Create a new validator node" data-izimodal-icon="icon-home">
    <div class="modalBody">
        <div class="alert alert-info">
            <i class="fas fa-info-circle"></i>
            <strong>Requirements:</strong> Minimum 10,000 CLIPS stake required to create a validator.
        </div>
        <div class="form-group">
            <label for="validatorStake">Initial Stake (CLIPS):</label>
            <input type="number" class="form-control" id="validatorStake" placeholder="Minimum 10,000 CLIPS" min="10000" step="0.000001">
        </div>
        <div class="form-group">
            <label for="validatorCommission">Commission Rate (%):</label>
            <input type="number" class="form-control" id="validatorCommission" placeholder="0-50%" min="0" max="50" step="0.01" value="5">
            <small class="form-text text-muted">Percentage of rewards you'll keep as commission</small>
        </div>
        <div class="form-group">
            <label for="validatorWallet">Validator Wallet:</label>
            <select class="form-control" id="validatorWallet">
                <!-- Wallets will be populated here -->
            </select>
        </div>
        <button type="button" class="btn btn-secondary btn-dialog-cancel" id="btnCreateValidatorCancel">Cancel</button>
        <button type="button" class="btn btn-info btn-dialog-confirm" id="btnCreateValidatorConfirm">Create Validator</button>
    </div>
</div>