<?php
/**
 * views/wisatawan/payment_success.php
 * Halaman Sukses Pembayaran
 */
$activeMenu = 'riwayatPesanan';
$pageTitle = 'Pembayaran Berhasil - Wisatawan';
include __DIR__ . '/../layouts/header.php';

// Data dari controller
$pesanan = $pesanan ?? [];
$orderId = $_GET['order_id'] ?? '';

if (empty($pesanan)) {
    ?>
    <div class="alert alert-danger">
        <i class="fas fa-exclamation-circle"></i>
        Data pesanan tidak ditemukan.
    </div>
    <a href="?page=wisatawan&action=pesananSaya" class="btn btn-primary">← Kembali ke Pesanan Saya</a>
    <?php
    include __DIR__ . '/../layouts/footer.php';
    exit;
}
?>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">

<div class="dashboard-wrapper">
    <?php include __DIR__ . '/../layouts/sidebar_wisatawan.php'; ?>

    <main class="main-content">
        <div class="success-container">
            <!-- ICON SUKSES -->
            <div class="success-icon">
                <i class="fas fa-check-circle"></i>
            </div>

            <h1 class="success-title">✅ Pembayaran Berhasil!</h1>
            <p class="success-subtitle">Terima kasih, pembayaran Anda telah berhasil diproses.</p>

            <!-- DETAIL PESANAN -->
            <div class="success-card">
                <div class="success-card-header">
                    <i class="fas fa-file-invoice"></i>
                    <span>Detail Pesanan</span>
                </div>
                <div class="success-card-body">
                    <div class="detail-row">
                        <span class="detail-label">Kode Pesanan</span>
                        <span class="detail-value"><strong><?= htmlspecialchars($pesanan['kode_pesanan']) ?></strong></span>
                    </div>
                    <div class="detail-row">
                        <span class="detail-label">Kapal</span>
                        <span class="detail-value"><?= htmlspecialchars($pesanan['nama_kapal'] ?? '-') ?></span>
                    </div>
                    <div class="detail-row">
                        <span class="detail-label">Tanggal Berangkat</span>
                        <span class="detail-value"><?= date('d/m/Y', strtotime($pesanan['tanggal_berangkat'])) ?></span>
                    </div>
                    <div class="detail-row">
                        <span class="detail-label">Jumlah Penumpang</span>
                        <span class="detail-value"><?= $pesanan['jumlah_tiket'] ?? 1 ?> orang</span>
                    </div>
                    <div class="detail-row total">
                        <span class="detail-label">Total Dibayar</span>
                        <span class="detail-value harga">Rp <?= number_format($pesanan['total_harga'], 0, ',', '.') ?></span>
                    </div>
                    <div class="detail-row">
                        <span class="detail-label">Status</span>
                        <span class="detail-value">
                            <span class="badge badge-success">
                                <i class="fas fa-check-circle"></i> LUNAS
                            </span>
                        </span>
                    </div>
                </div>
            </div>

            <!-- INFORMASI SELANJUTNYA -->
            <div class="info-box">
                <div class="info-box-icon">
                    <i class="fas fa-info-circle"></i>
                </div>
                <div class="info-box-content">
                    <h4>📌 Apa Selanjutnya?</h4>
                    <ul>
                        <li>Pemilik kapal akan <strong>mengkonfirmasi</strong> pesanan Anda.</li>
                        <li>Anda akan mendapat <strong>notifikasi WhatsApp</strong> setelah dikonfirmasi.</li>
                        <li>Silakan hubungi pemilik kapal jika ada pertanyaan.</li>
                    </ul>
                </div>
            </div>

            <!-- TOMBOL AKSI -->
            <div class="action-buttons">
                <a href="?page=wisatawan&action=detailPesanan&id=<?= $pesanan['id'] ?>" class="btn btn-primary btn-lg">
                    <i class="fas fa-eye"></i> Lihat Detail Pesanan
                </a>
                <a href="?page=wisatawan&action=pesananSaya" class="btn btn-secondary btn-lg">
                    <i class="fas fa-list"></i> Daftar Pesanan
                </a>
            </div>
        </div>
    </main>
</div>

<style>
.dashboard-wrapper {
    display: flex;
    gap: 24px;
    max-width: 1200px;
    margin: 1.5rem auto 0;
    padding: 0 20px;
    width: 100%;
    flex: 1;
    align-items: flex-start;
}

.main-content {
    flex: 1;
    min-width: 0;
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
}

/* ============================================
   SUCCESS CONTAINER
   ============================================ */
.success-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.success-icon {
    font-size: 5rem;
    color: #22c55e;
    margin-bottom: 1rem;
    animation: bounceIn 0.8s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.success-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #065f46;
    margin-bottom: 0.3rem;
}

.success-subtitle {
    font-size: 1rem;
    color: #4a5568;
    margin-bottom: 1.5rem;
}

/* ============================================
   SUCCESS CARD
   ============================================ */
.success-card {
    background: #f7fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    margin-bottom: 1.5rem;
    text-align: left;
}

.success-card-header {
    background: #edf2f7;
    padding: 0.8rem 1.2rem;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.success-card-body {
    padding: 1rem 1.2rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid #edf2f7;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row.total {
    border-top: 2px solid #e2e8f0;
    padding-top: 0.6rem;
    margin-top: 0.2rem;
}

.detail-label {
    color: #718096;
    font-size: 0.85rem;
}

.detail-value {
    font-size: 0.85rem;
    color: #1a202c;
}

.detail-value.harga {
    font-weight: 700;
    color: #2b6cb0;
    font-size: 1.1rem;
}

/* ============================================
   BADGE
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

/* ============================================
   INFO BOX
   ============================================ */
.info-box {
    display: flex;
    gap: 1rem;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 12px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.info-box-icon {
    font-size: 1.5rem;
    color: #1e40af;
    flex-shrink: 0;
}

.info-box-content h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e40af;
    margin: 0 0 0.3rem;
}

.info-box-content ul {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.85rem;
    color: #1e40af;
}

.info-box-content ul li {
    margin-bottom: 0.2rem;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.btn-primary {
    background: #2b6cb0;
    color: #fff;
}

.btn-primary:hover {
    background: #1a4a7a;
    color: #fff;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
    color: #1a202c;
}

.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .dashboard-wrapper {
        flex-direction: column;
        padding: 0 12px;
        margin-top: 1rem;
    }
    .main-content {
        padding: 1rem;
    }
    .success-icon {
        font-size: 3.5rem;
    }
    .success-title {
        font-size: 1.4rem;
    }
    .action-buttons {
        flex-direction: column;
    }
    .action-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
    }
    .info-box {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 0.8rem;
    }
    .success-card-body {
        padding: 0.8rem 1rem;
    }
}
</style>

<?php include __DIR__ . '/../layouts/footer.php'; ?>