<style>
/* Modern Transaction View Modal Styles */
.modern-transaction-modal .modal-body {
    padding: 0;
    background: white;
    border-radius: 16px;
    overflow: hidden;
}

.transaction-modal-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    padding: 25px 30px;
    color: white;
    position: relative;
    overflow: hidden;
}

.transaction-modal-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal-title-custom {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 2;
}

.modal-title-custom i {
    margin-right: 10px;
    font-size: 24px;
}

.transaction-details {
    padding: 30px;
}

.detail-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 25px;
}

.detail-item {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #4facfe;
    transition: all 0.3s ease;
}

.detail-item:hover {
    background: #e6fffa;
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.1);
}

.detail-label {
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.detail-value {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    word-break: break-all;
}

.detail-value.transaction-id {
    font-family: 'Courier New', monospace;
    background: #4facfe;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-block;
}

.detail-value.amount {
    font-size: 20px;
    color: #059669;
    font-weight: 700;
}

.status-badge-modal {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.status-completed-modal {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.status-pending-modal {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.status-cancelled-modal {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.status-processing-modal {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.file-preview {
    margin: 25px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.file-preview iframe {
    border: none;
    width: 100%;
    height: 400px;
    object-fit: contain;
}

.modal-actions {
    background: #f8fafc;
    padding: 25px 30px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.action-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn-complete {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-pending {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.btn-initiate {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-cancel {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.btn-close {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .transaction-modal-header {
        padding: 20px;
    }
    
    .modal-title-custom {
        font-size: 18px;
    }
    
    .modal-title-custom i {
        font-size: 20px;
    }
    
    .transaction-details {
        padding: 20px;
    }
    
    .detail-grid {
        gap: 15px;
    }
    
    .detail-item {
        padding: 15px;
    }
    
    .detail-value {
        font-size: 14px;
    }
    
    .detail-value.amount {
        font-size: 18px;
    }
    
    .file-preview iframe {
        height: 300px;
    }
    
    .modal-actions {
        padding: 20px;
        gap: 8px;
    }
    
    .action-btn {
        padding: 8px 16px;
        font-size: 12px;
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .transaction-modal-header {
        padding: 15px;
    }
    
    .modal-title-custom {
        font-size: 16px;
    }
    
    .transaction-details {
        padding: 15px;
    }
    
    .detail-item {
        padding: 12px;
    }
    
    .detail-value {
        font-size: 13px;
    }
    
    .detail-value.amount {
        font-size: 16px;
    }
    
    .file-preview iframe {
        height: 250px;
    }
    
    .modal-actions {
        padding: 15px;
        flex-direction: column;
    }
    
    .action-btn {
        width: 100%;
        min-width: auto;
    }
}
</style>

<?= view('layouts/common/modal/modal_top'); ?>

<div class="modal-body modern-transaction-modal">
    <div class="transaction-modal-header">
        <h4 class="modal-title-custom">
            <i class="fas fa-receipt"></i>
            Transaction Details
        </h4>
    </div>
    
    <div class="transaction-details">
        <div class="detail-grid">
            <div class="detail-item">
                <div class="detail-label">Transaction ID</div>
                <div class="detail-value transaction-id"><?= @$item->transaction_id ?: 'N/A' ?></div>
            </div>
            
            <div class="detail-item">
                <div class="detail-label">Customer Name</div>
                <div class="detail-value"><?= @get_value($item->params, 'cus_name') ?: 'N/A' ?></div>
            </div>
            
            <div class="detail-item">
                <div class="detail-label">Customer Email</div>
                <div class="detail-value"><?= @get_value($item->params, 'cus_email') ?: 'N/A' ?></div>
            </div>
            
            <div class="detail-item">
                <div class="detail-label">Amount</div>
                <div class="detail-value amount"><?= @currency_format($item->amount) ?: 'N/A' ?></div>
            </div>
            
            <div class="detail-item">
                <div class="detail-label">Status</div>
                <div class="detail-value">
                    <span class="status-badge-modal <?php 
                        switch($item->status) {
                            case 2: echo 'status-completed-modal'; break;
                            case 1: echo 'status-processing-modal'; break;
                            case 3: echo 'status-cancelled-modal'; break;
                            default: echo 'status-pending-modal';
                        }
                    ?>">
                        <?php 
                        switch($item->status) {
                            case 2: echo 'Completed'; break;
                            case 1: echo 'Processing'; break;
                            case 3: echo 'Cancelled'; break;
                            default: echo 'Pending';
                        }
                        ?>
                    </span>
                </div>
            </div>
            
            <div class="detail-item">
                <div class="detail-label">Transaction Message</div>
                <div class="detail-value"><?= @$item->message ?: 'No message available' ?></div>
            </div>
        </div>
        
        <?php if (!empty($item->files)) : ?>
            <div class="file-preview">
                <iframe src="<?= getenv('PAYMENT_URL') . ($item->files) ?>"></iframe>
            </div>
        <?php endif; ?>
    </div>
    
    <div class="modal-actions">
        <?= form_open('', ['class' => 'form actionForm', 'style' => 'display: contents;']); ?>
        <input type="hidden" name="type" value="<?= (!empty($item->files)) ? 'bank' : 'manual'; ?>">
        <input type="hidden" name="k_status" value="">
        
        <?php if ($item->status != 2) : ?>
            <button type="submit" onclick="this.form.k_status.value=this.value" 
                    class="action-btn btn-complete" value="2">
                <i class="fas fa-check"></i> Complete
            </button>
        <?php endif; ?>
        
        <?php if ($item->status != 0) : ?>
            <button type="submit" onclick="this.form.k_status.value=this.value" 
                    class="action-btn btn-pending" value="0">
                <i class="fas fa-clock"></i> Pending
            </button>
        <?php endif; ?>
        
        <?php if ($item->status != 1) : ?>
            <button type="submit" onclick="this.form.k_status.value=this.value" 
                    class="action-btn btn-initiate" value="1">
                <i class="fas fa-play"></i> Initiate
            </button>
        <?php endif; ?>
        
        <?php if ($item->status != 3) : ?>
            <button type="submit" onclick="this.form.k_status.value=this.value" 
                    class="action-btn btn-cancel" value="3">
                <i class="fas fa-times"></i> Cancel
            </button>
        <?php endif; ?>
        
        <button type="button" class="action-btn btn-close" data-bs-dismiss="modal">
            <i class="fas fa-arrow-left"></i> Close
        </button>
        
        <?= form_close(); ?>
    </div>
</div>

<?= view('layouts/common/modal/modal_bottom'); ?>