<?php require_once __DIR__ . '/../layout.php'; ?>

<div style="margin-bottom: 2rem;">
    <a href="/superadmin/smtp" style="color: var(--superadmin-color); text-decoration: none; display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 500; font-size: 0.9rem; margin-bottom: 1rem;">
        <i class="ph ph-arrow-left" style="font-weight: bold;"></i> Back to SMTP settings
    </a>
    <h3 style="margin: 0; color: white;"><?php echo htmlspecialchars($title); ?></h3>
</div>

<div class="card" style="max-width: 650px;">
    <form action="<?php echo $actionUrl; ?>" method="POST">
        <div class="two-col-grid" style="display: grid; grid-template-columns: 2fr 1fr; gap: 1rem;">
            <div class="input-group">
                <label for="smtp_host">SMTP Host</label>
                <input type="text" id="smtp_host" name="smtp_host" value="<?php echo htmlspecialchars($record['smtp_host'] ?? ''); ?>" placeholder="e.g. mail.smtp.com" required style="width: 100%; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(15,23,42,0.6); color: white; outline: none;">
            </div>

            <div class="input-group">
                <label for="smtp_port">SMTP Port</label>
                <input type="number" id="smtp_port" name="smtp_port" value="<?php echo htmlspecialchars($record['smtp_port'] ?? ''); ?>" placeholder="e.g. 465" required style="width: 100%; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(15,23,42,0.6); color: white; outline: none;">
            </div>
        </div>

        <div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;">
            <div class="input-group">
                <label for="smtp_username">SMTP Username</label>
                <input type="text" id="smtp_username" name="smtp_username" value="<?php echo htmlspecialchars($record['smtp_username'] ?? ''); ?>" placeholder="username / email" required style="width: 100%; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(15,23,42,0.6); color: white; outline: none;">
            </div>

            <div class="input-group">
                <label for="smtp_password">SMTP Password</label>
                <input type="password" id="smtp_password" name="smtp_password" value="<?php echo htmlspecialchars($record['smtp_password'] ?? ''); ?>" placeholder="••••••••" required style="width: 100%; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(15,23,42,0.6); color: white; outline: none;">
            </div>
        </div>

        <div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;">
            <div class="input-group">
                <label for="from_name">From Name</label>
                <input type="text" id="from_name" name="from_name" value="<?php echo htmlspecialchars($record['from_name'] ?? ''); ?>" placeholder="e.g. SHSApperal" required style="width: 100%; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(15,23,42,0.6); color: white; outline: none;">
            </div>

            <div class="input-group">
                <label for="from_email">From Email (Optional)</label>
                <input type="email" id="from_email" name="from_email" value="<?php echo htmlspecialchars($record['from_email'] ?? ''); ?>" placeholder="defaults to username" style="width: 100%; padding: 0.75rem 1rem; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(15,23,42,0.6); color: white; outline: none;">
            </div>
        </div>

        <div style="margin-top: 2rem; display: flex; gap: 1rem;">
            <button type="submit" class="btn-gold">Save SMTP configuration</button>
            <a href="/superadmin/smtp" class="btn-outline-gold" style="display: inline-flex; align-items: center; justify-content: center;">Cancel</a>
        </div>
    </form>
</div>

</div> <!-- main-content -->
</div> <!-- dashboard-layout -->
</body>
</html>
