                    <div class="dbm-content-header">
                        <div class="dbm-breadcrumb">
                            <a href="<?php echo Config::get('URL'); ?>database/index">Databases</a>
                        </div>
                        <div class="dbm-title">
                            <h1>All Databases</h1>
                            <span class="badge"><?php echo count($this->databases); ?> total</span>
                        </div>
                        <div class="dbm-actions">
                            <button type="button" class="dbm-btn dbm-btn-success" onclick="document.getElementById('create-db-modal').style.display='flex'">
                                <i data-lucide="plus"></i>
                                Create Database
                            </button>
                        </div>
                    </div>

                    <div class="dbm-content-body">
                        <div class="dbm-stats">
                            <div class="dbm-stat">
                                <div class="dbm-stat-value"><?php echo count($this->databases); ?></div>
                                <div class="dbm-stat-label">Databases</div>
                            </div>
                            <div class="dbm-stat">
                                <div class="dbm-stat-value"><?php echo htmlspecialchars($this->current_db); ?></div>
                                <div class="dbm-stat-label">Current Database</div>
                            </div>
                        </div>

                        <div class="dbm-table-wrapper">
                            <table class="dbm-table">
                                <thead>
                                    <tr>
                                        <th>Database Name</th>
                                        <th>Tables</th>
                                        <th style="width: 200px;">Actions</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach ($this->databases as $db):
                                        $tables = DatabaseModel::getTablesInDatabase($db);
                                    ?>
                                        <tr>
                                            <td>
                                                <a href="<?php echo Config::get('URL'); ?>database/show/<?php echo urlencode($db); ?>" style="color: var(--accent-blue); text-decoration: none;">
                                                    <?php echo htmlspecialchars($db); ?>
                                                </a>
                                                <?php if ($db === $this->current_db): ?>
                                                    <span style="margin-left: 8px; font-size: 10px; padding: 2px 6px; background: var(--accent-green); color: #fff; border-radius: 3px;">ACTIVE</span>
                                                <?php endif; ?>
                                            </td>
                                            <td><?php echo count($tables); ?></td>
                                            <td>
                                                <a href="<?php echo Config::get('URL'); ?>database/show/<?php echo urlencode($db); ?>" class="dbm-btn dbm-btn-sm dbm-btn-secondary">Browse</a>
                                                <?php if ($db !== $this->current_db): ?>
                                                    <a href="<?php echo Config::get('URL'); ?>database/delete/<?php echo urlencode($db); ?>"
                                                       class="dbm-btn dbm-btn-sm dbm-btn-danger"
                                                       data-confirm="Delete database '<?php echo htmlspecialchars($db); ?>'? This cannot be undone!">Drop</a>
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                    <?php endforeach; ?>
                                </tbody>
                            </table>
                        </div>
                    </div>

<!-- Create Database Modal -->
<div id="create-db-modal" style="display:none; position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.8); z-index:1000; align-items:center; justify-content:center;">
    <div class="dbm-card" style="width: 400px; max-width: 90%;">
        <div class="dbm-card-header">
            <h3>Create New Database</h3>
        </div>
        <div class="dbm-card-body">
            <form method="post" action="<?php echo Config::get('URL'); ?>database/create" data-ajax-form>
                <div class="dbm-form-group">
                    <label class="dbm-form-label">Database Name</label>
                    <input type="text" name="database_name" class="dbm-form-input" required pattern="[a-zA-Z0-9_]+" placeholder="my_database" style="width:100%;max-width:100%;">
                </div>
                <div style="display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px;">
                    <button type="button" class="dbm-btn dbm-btn-secondary" onclick="document.getElementById('create-db-modal').style.display='none'">Cancel</button>
                    <button type="submit" class="dbm-btn dbm-btn-success">Create</button>
                </div>
            </form>
        </div>
    </div>
</div>
