<?php
// Filename: submit_suggestion.php
require 'config.php';
requireLogin();

$msg = '';
$msg_type = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $subject = trim($_POST['subject']);
    $message = trim($_POST['message']);

    if (!empty($subject) && !empty($message)) {
        try {
            $stmt = $pdo->prepare("INSERT INTO system_suggestions (user_id, subject, message) VALUES (?, ?, ?)");
            $stmt->execute([$_SESSION['user_id'], $subject, $message]);
            $msg = "Thank you! Your suggestion has been sent.";
            $msg_type = "success";
        } catch (Exception $e) {
            $msg = "Error sending suggestion: " . $e->getMessage();
            $msg_type = "danger";
        }
    } else {
        $msg = "Please fill in all fields.";
        $msg_type = "warning";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Submit Suggestion</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">

    <style>
        :root { --primary-grad: <?= getHeaderTheme() ?>; ... }
        body { font-family: 'Plus Jakarta Sans', sans-serif; background-color: var(--bg-color); padding-bottom: 100px; }

        /* HEADER */
        .app-header {
            background: var(--primary-grad);
            padding: 30px 20px 100px 20px; /* Extra padding for overlap */
            border-radius: 0 0 35px 35px;
            color: white;
            text-align: center;
        }

        /* FLOATING CARD */
        .floating-card {
            background: white; margin: -80px 20px 20px 20px;
            border-radius: 24px; padding: 25px;
            box-shadow: 0 15px 35px rgba(0,0,0,0.08);
            position: relative; z-index: 10;
        }

        /* FORM ELEMENTS */
        .form-label { font-size: 0.75rem; font-weight: 700; color: var(--text-gray); text-transform: uppercase; letter-spacing: 0.5px; }
        .form-control, .form-select { 
            border-radius: 12px; padding: 12px; border: 1px solid #e2e8f0; background-color: #f8fafc; font-size: 0.95rem;
        }
        .form-control:focus, .form-select:focus { 
            background-color: white; border-color: #8B5CF6; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1); 
        }

        /* ICON DECORATION */
        .icon-box {
            width: 60px; height: 60px; background: rgba(255,255,255,0.2); 
            border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
            font-size: 1.8rem; margin-bottom: 15px; border: 1px solid rgba(255,255,255,0.3);
        }

        /* BOTTOM NAV 
        .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: white; padding: 10px 30px 25px 30px; display: flex; justify-content: space-between; border-radius: 30px 30px 0 0; box-shadow: 0 -5px 20px rgba(0,0,0,0.05); z-index: 100; }
        .nav-btn { display: flex; flex-direction: column; align-items: center; color: #94a3b8; text-decoration: none; font-size: 0.7rem; font-weight: 600; }
        .nav-btn.active { color: #8B5CF6; }
        .nav-btn i { font-size: 1.4rem; margin-bottom: 4px; }   */
    </style>
</head>
<body>

    <div class="app-header">
        <div class="d-flex justify-content-between align-items-center mb-4">
            <a href="dashboard.php" class="text-white"><i class="bi bi-arrow-left fs-4"></i></a>
            <div class="fw-bold fs-5">Feedback</div>
            <div style="width: 24px;"></div>
        </div>
        
        <div class="icon-box">
            <i class="bi bi-lightbulb-fill"></i>
        </div>
        <h3 class="fw-bold mb-1">Help Us Improve</h3>
        <p class="text-white-50 small mb-0">Share ideas, report bugs, or give feedback.</p>
    </div>

    <div class="floating-card">
        
        <?php if($msg): ?>
            <div class="alert alert-<?= $msg_type ?> border-0 shadow-sm rounded-3 text-center small mb-4">
                <?= $msg ?>
            </div>
        <?php endif; ?>

        <form method="POST">
            <div class="mb-3">
                <label class="form-label">Subject</label>
                <select name="subject" class="form-select" required>
                    <option value="" disabled selected>Select a topic...</option>
                    <option value="Feature Request">✨ Feature Request</option>
                    <option value="Bug Report">🐛 Bug Report</option>
                    <option value="General Feedback">💬 General Feedback</option>
                    <option value="Other">📝 Other</option>
                </select>
            </div>
            
            <div class="mb-4">
                <label class="form-label">Your Message</label>
                <textarea name="message" class="form-control" rows="6" placeholder="Describe your idea or issue in detail..." required></textarea>
            </div>

            <button type="submit" class="btn btn-primary w-100 rounded-pill py-3 fw-bold shadow-sm" style="background: var(--primary-grad); border:none;">
                Send Feedback <i class="bi bi-send-fill ms-2"></i>
            </button>
        </form>
    </div>

    <div class="text-center text-muted small px-4">
        <p class="opacity-75">Your feedback is sent directly to the admin team.<br>Thank you for contributing!</p>
    </div>

    <?php include 'menu.php'; ?>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>