use leptos::prelude::*;

#[component]
pub fn KmsPage() -> impl IntoView {
    view! {
        <div class="kms-page" style="padding: 20px;">
            <h1 style="font-size: 2rem; margin-bottom: 20px; color: #333;">
                "🔐 Key Management Service (KMS)"
            </h1>

            <div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 20px;">
                <h2 style="margin: 0 0 15px 0; font-size: 1.3rem; color: #333;">
                    "KMS Status"
                </h2>
                <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px;">
                    <div style="padding: 15px; background: #f9fafb; border-radius: 6px;">
                        <div style="color: #666; font-size: 0.85rem; margin-bottom: 5px;">"Service Status"</div>
                        <div style="font-size: 1.2rem; color: #10b981; font-weight: 600;">"✅ Running"</div>
                    </div>
                    <div style="padding: 15px; background: #f9fafb; border-radius: 6px;">
                        <div style="color: #666; font-size: 0.85rem; margin-bottom: 5px;">"Endpoint"</div>
                        <div style="font-size: 1rem; color: #333; font-family: monospace;">"http://kms:9998"</div>
                    </div>
                    <div style="padding: 15px; background: #f9fafb; border-radius: 6px;">
                        <div style="color: #666; font-size: 0.85rem; margin-bottom: 5px;">"Mode"</div>
                        <div style="font-size: 1rem; color: #333;">"Solo (Local SQLite)"</div>
                    </div>
                </div>
            </div>

            <div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 20px;">
                <h2 style="margin: 0 0 15px 0; font-size: 1.3rem; color: #333;">
                    "Secret Management"
                </h2>
                <div style="color: #666; margin-bottom: 15px;">
                    "Manage encryption keys, certificates, and secrets securely."
                </div>
                <div style="display: flex; gap: 10px; flex-wrap: wrap;">
                    <button style="padding: 10px 20px; background: #3b82f6; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 500;">
                        "Create Key"
                    </button>
                    <button style="padding: 10px 20px; background: #10b981; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 500;">
                        "Import Certificate"
                    </button>
                    <button style="padding: 10px 20px; background: #8b5cf6; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 500;">
                        "View Secrets"
                    </button>
                </div>
            </div>

            <div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
                <h2 style="margin: 0 0 15px 0; font-size: 1.3rem; color: #333;">
                    "Recent Keys"
                </h2>
                <table style="width: 100%; border-collapse: collapse;">
                    <thead>
                        <tr style="border-bottom: 2px solid #e5e7eb;">
                            <th style="text-align: left; padding: 12px; color: #666; font-size: 0.9rem; font-weight: 600;">"Key ID"</th>
                            <th style="text-align: left; padding: 12px; color: #666; font-size: 0.9rem; font-weight: 600;">"Type"</th>
                            <th style="text-align: left; padding: 12px; color: #666; font-size: 0.9rem; font-weight: 600;">"Purpose"</th>
                            <th style="text-align: left; padding: 12px; color: #666; font-size: 0.9rem; font-weight: 600;">"Created"</th>
                            <th style="text-align: left; padding: 12px; color: #666; font-size: 0.9rem; font-weight: 600;">"Status"</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr style="border-bottom: 1px solid #e5e7eb;">
                            <td style="padding: 12px; font-family: monospace; font-size: 0.85rem; color: #333;">"key-001"</td>
                            <td style="padding: 12px; color: #666;">"AES-256"</td>
                            <td style="padding: 12px; color: #666;">"Data Encryption"</td>
                            <td style="padding: 12px; color: #666;">"2025-10-07"</td>
                            <td style="padding: 12px;"><span style="background: #dcfce7; color: #166534; padding: 4px 8px; border-radius: 4px; font-size: 0.85rem;">"Active"</span></td>
                        </tr>
                        <tr style="border-bottom: 1px solid #e5e7eb;">
                            <td style="padding: 12px; font-family: monospace; font-size: 0.85rem; color: #333;">"cert-tls-001"</td>
                            <td style="padding: 12px; color: #666;">"TLS Certificate"</td>
                            <td style="padding: 12px; color: #666;">"HTTPS"</td>
                            <td style="padding: 12px; color: #666;">"2025-10-06"</td>
                            <td style="padding: 12px;"><span style="background: #dcfce7; color: #166534; padding: 4px 8px; border-radius: 4px; font-size: 0.85rem;">"Active"</span></td>
                        </tr>
                        <tr>
                            <td style="padding: 12px; font-family: monospace; font-size: 0.85rem; color: #333;">"ssh-key-prod"</td>
                            <td style="padding: 12px; color: #666;">"SSH Key"</td>
                            <td style="padding: 12px; color: #666;">"Server Access"</td>
                            <td style="padding: 12px; color: #666;">"2025-10-05"</td>
                            <td style="padding: 12px;"><span style="background: #dcfce7; color: #166534; padding: 4px 8px; border-radius: 4px; font-size: 0.85rem;">"Active"</span></td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    }
}
