<?php
require_once dirname(__DIR__) . '/config/config.php';
require_once dirname(__DIR__) . '/classes/SMSPoolAPI.php';
requireLogin();

$auth = new Auth();
$userModel = new User();
$currentBalance = $auth->refreshBalance($_SESSION['user_id']);
$pdo = getDBConnection();

$error = '';
$success = '';
$activeOrder = null;

// Get active SMS countries - USA first, then common countries, then rest alphabetically
$countries = $pdo->query("SELECT * FROM sms_countries WHERE status = 'active' 
    ORDER BY 
        CASE 
            WHEN name = 'United States' OR name = 'USA' OR short_name = 'US' THEN 0
            WHEN name = 'United Kingdom' OR name = 'UK' OR short_name = 'UK' THEN 1
            WHEN name = 'Canada' OR short_name = 'CA' THEN 2
            WHEN name = 'Germany' OR short_name = 'DE' THEN 3
            WHEN name = 'France' OR short_name = 'FR' THEN 4
            WHEN name = 'Netherlands' OR short_name = 'NL' THEN 5
            WHEN name = 'Russia' OR short_name = 'RU' THEN 6
            WHEN name = 'India' OR short_name = 'IN' THEN 7
            WHEN name = 'China' OR short_name = 'CN' THEN 8
            WHEN name = 'Brazil' OR short_name = 'BR' THEN 9
            WHEN name = 'Australia' OR short_name = 'AU' THEN 10
            ELSE 100
        END,
        name ASC
")->fetchAll();
$services = $pdo->query("SELECT * FROM sms_services WHERE status = 'active' ORDER BY custom_name ASC")->fetchAll();

// Get user's active SMS orders
$stmt = $pdo->prepare("SELECT * FROM sms_orders WHERE user_id = ? AND status IN ('pending', 'waiting') ORDER BY created_at DESC LIMIT 1");
$stmt->execute([$_SESSION['user_id']]);
$activeOrder = $stmt->fetch();

$api = new SMSPoolAPI();

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST' && verifyCSRFToken($_POST['csrf_token'] ?? '')) {
    $action = $_POST['action'] ?? '';
    
    if ($action === 'order') {
        $countryId = intval($_POST['country_id'] ?? 0);
        $serviceId = intval($_POST['service_id'] ?? 0);
        
        $stmt = $pdo->prepare("SELECT * FROM sms_countries WHERE id = ? AND status = 'active'");
        $stmt->execute([$countryId]);
        $country = $stmt->fetch();
        
        $stmt = $pdo->prepare("SELECT * FROM sms_services WHERE id = ? AND status = 'active'");
        $stmt->execute([$serviceId]);
        $service = $stmt->fetch();
        
        // Get price from sms_pricing table
        $stmt = $pdo->prepare("SELECT * FROM sms_pricing WHERE country_id = ? AND service_id = ? AND status = 'active'");
        $stmt->execute([$countryId, $serviceId]);
        $pricing = $stmt->fetch();
        
        if (!$country || !$service) {
            $error = 'Invalid country or service selected';
        } elseif (!$pricing) {
            $error = 'Price not available for this combination';
        } else {
            $price = $pricing['custom_price'];
            
            if ($currentBalance < $price) {
                $error = 'Insufficient balance. Please add funds.';
            } elseif (!$api->hasApiKey()) {
                $error = 'SMS API not configured. Please contact admin.';
            } else {
                // Call SMSPool API to order number
                $result = $api->orderSMS($country['api_country_id'], $service['api_service_id']);
                
                // Check for success (can be int 1 or string "1")
                $isSuccess = (isset($result['success']) && ($result['success'] == 1 || $result['success'] === '1' || $result['success'] === true)) 
                            || isset($result['order_id']) 
                            || isset($result['number']);
                
                if ($isSuccess) {
                    // Deduct balance
                    $userModel->updateBalance($_SESSION['user_id'], $price, 'subtract');
                    $currentBalance = $auth->refreshBalance($_SESSION['user_id']);
                    
                    // Calculate expiry from API response or default 15 minutes
                    $expiresIn = intval($result['expires_in'] ?? 900); // seconds
                    $expiresAt = date('Y-m-d H:i:s', time() + $expiresIn);
                    
                    // Save order
                    $stmt = $pdo->prepare("INSERT INTO sms_orders (user_id, country_id, service_id, api_order_id, phone_number, charge, status, expires_at, created_at) VALUES (?, ?, ?, ?, ?, ?, 'pending', ?, NOW())");
                    $stmt->execute([
                        $_SESSION['user_id'],
                        $countryId,
                        $serviceId,
                        $result['order_id'] ?? '',
                        $result['number'] ?? '',
                        $price,
                        $expiresAt
                    ]);
                    
                    $success = 'Number ordered successfully! Phone: ' . ($result['number'] ?? 'Loading...');
                    
                    // Redirect to order view page
                    $newOrderId = $pdo->lastInsertId();
                    header('Location: sms-order.php?id=' . $newOrderId);
                    exit;
                } else {
                    // Show all possible error messages from API
                    $errorMsg = $result['message'] ?? $result['error'] ?? $result['msg'] ?? '';
                    if (empty($errorMsg) && isset($result['success']) && $result['success'] == 0) {
                        $errorMsg = 'SMSPool error - Full response: ' . json_encode(array_diff_key($result, ['_debug' => 1]));
                    }
                    if (empty($errorMsg)) {
                        $errorMsg = 'Unknown error - Raw: ' . json_encode($result);
                    }
                    $error = 'Order failed: ' . $errorMsg;
                }
            }
        }
    } elseif ($action === 'cancel') {
        $orderId = intval($_POST['order_id'] ?? 0);
        $stmt = $pdo->prepare("SELECT * FROM sms_orders WHERE id = ? AND user_id = ? AND status IN ('pending', 'waiting')");
        $stmt->execute([$orderId, $_SESSION['user_id']]);
        $order = $stmt->fetch();
        
        if ($order) {
            // Call API to cancel
            if ($order['api_order_id']) {
                $api->cancelSMS($order['api_order_id']);
            }
            
            // Refund
            $userModel->updateBalance($_SESSION['user_id'], $order['charge'], 'add');
            $stmt = $pdo->prepare("UPDATE sms_orders SET status = 'cancelled' WHERE id = ?");
            $stmt->execute([$orderId]);
            $currentBalance = $auth->refreshBalance($_SESSION['user_id']);
            $success = 'Order cancelled and refunded';
            $activeOrder = null;
        }
    } elseif ($action === 'check_sms') {
        $orderId = intval($_POST['order_id'] ?? 0);
        $stmt = $pdo->prepare("SELECT * FROM sms_orders WHERE id = ? AND user_id = ?");
        $stmt->execute([$orderId, $_SESSION['user_id']]);
        $order = $stmt->fetch();
        
        if ($order && $order['api_order_id']) {
            $result = $api->checkSMS($order['api_order_id']);
            
            $code = $result['sms'] ?? $result['full_code'] ?? $result['code'] ?? '';
            if ($code && $code !== '0') {
                $stmt = $pdo->prepare("UPDATE sms_orders SET sms_code = ?, status = 'received' WHERE id = ?");
                $stmt->execute([$code, $orderId]);
                $success = 'Code received: ' . $code;
                $activeOrder = null;
            } else {
                $success = 'Still waiting for SMS...';
            }
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SMS Service - <?php echo SITE_NAME; ?></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'Segoe UI', sans-serif; background: #0A1628; color: #fff; min-height: 100vh; }
        .header { background: #0F2744; padding: 1rem; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; }
        .header-logo { display: flex; align-items: center; gap: 0.5rem; color: #F5A623; font-weight: 700; }
        .header-logo img { width: 48px; height: 48px; min-width: 48px; min-height: 48px; object-fit: contain; }
        .header-balance { background: #F5A623; color: #0A1628; padding: 0.5rem 1rem; border-radius: 20px; font-weight: 600; }
        .hamburger { background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
        .menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 200; display: none; }
        .menu-overlay.active { display: block; }
        .side-menu { position: fixed; top: 0; left: -280px; width: 280px; height: 100%; background: #0F2744; z-index: 300; transition: left 0.3s; padding: 1.5rem 0; overflow-y: auto; }
        .side-menu.active { left: 0; }
        .menu-header { display: flex; justify-content: space-between; align-items: center; padding: 0 1.5rem 1.5rem; border-bottom: 1px solid #1E3A5F; }
        .menu-close { background: none; border: none; color: #9CA3AF; font-size: 1.5rem; cursor: pointer; }
        .menu-items { padding: 1rem 0; }
        .menu-item { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.5rem; color: #E5E7EB; text-decoration: none; }
        .menu-item:hover, .menu-item.active { background: #1E3A5F; color: #F5A623; }
        .menu-item i { width: 20px; text-align: center; }
        .menu-divider { height: 1px; background: #1E3A5F; margin: 0.5rem 1.5rem; }
        .content { padding: 1rem; max-width: 800px; margin: 0 auto; }
        .page-title { font-size: 1.25rem; margin-bottom: 1rem; }
        .page-title i { color: #F5A623; }
        .card { background: #0F2744; border-radius: 12px; padding: 1.5rem; margin-bottom: 1rem; }
        .card-title { font-size: 1rem; color: #F5A623; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
        .form-group { margin-bottom: 1rem; }
        .form-label { display: block; color: #E5E7EB; margin-bottom: 0.5rem; font-size: 0.9rem; }
        .form-control { width: 100%; padding: 0.75rem 1rem; background: #0A1628; border: 1px solid #1E3A5F; border-radius: 8px; color: #fff; font-size: 1rem; }
        .form-control:focus { outline: none; border-color: #F5A623; }
        
        /* Searchable Select Dropdown */
        .search-select-wrapper { position: relative; }
        .search-input { cursor: text; }
        .search-input.selected { color: #F5A623; font-weight: 600; }
        .search-dropdown { 
            position: absolute; 
            top: 100%; 
            left: 0; 
            right: 0; 
            background: #0F2744; 
            border: 1px solid #1E3A5F; 
            border-radius: 8px; 
            max-height: 250px; 
            overflow-y: auto; 
            z-index: 50; 
            display: none;
            margin-top: 4px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        }
        .search-dropdown.show { display: block; }
        .search-option { 
            padding: 0.75rem 1rem; 
            cursor: pointer; 
            border-bottom: 1px solid #1E3A5F;
            transition: background 0.2s;
        }
        .search-option:last-child { border-bottom: none; }
        .search-option:hover, .search-option.highlighted { background: #1E3A5F; color: #F5A623; }
        .search-option.hidden { display: none; }
        .no-results { padding: 1rem; text-align: center; color: #9CA3AF; }
        
        .btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; }
        .btn-gold { background: #F5A623; color: #0A1628; width: 100%; justify-content: center; }
        .btn-danger { background: #EF4444; color: #fff; }
        .btn-navy { background: #1E3A5F; color: #fff; }
        .alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
        .alert-success { background: rgba(16,185,129,0.2); border: 1px solid #10B981; color: #10B981; }
        .alert-danger { background: rgba(239,68,68,0.2); border: 1px solid #EF4444; color: #EF4444; }
        .active-order { border: 2px solid #F5A623; }
        .phone-number { font-size: 1.5rem; font-weight: 700; text-align: center; padding: 1rem; background: #0A1628; border-radius: 8px; margin-bottom: 1rem; color: #10B981; font-family: monospace; }
        .sms-code { font-size: 2rem; font-weight: 700; text-align: center; color: #F5A623; padding: 1rem; background: rgba(245,166,35,0.1); border-radius: 8px; margin-bottom: 1rem; font-family: monospace; }
        .waiting { text-align: center; padding: 1rem; color: #9CA3AF; }
        .waiting i { animation: spin 1s linear infinite; margin-right: 0.5rem; }
        @keyframes spin { 100% { transform: rotate(360deg); } }
        .order-actions { display: flex; gap: 0.5rem; justify-content: center; }
        .order-actions form { flex: 1; }
        .order-actions .btn { width: 100%; }
        .price-display { background: rgba(245,166,35,0.1); padding: 1rem; border-radius: 8px; text-align: center; margin-bottom: 1rem; font-size: 1.25rem; color: #F5A623; font-weight: 700; }
        .order-item { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid #1E3A5F; }
        .order-info { flex: 1; }
        .order-service { font-weight: 600; color: #F5A623; }
        .order-details { font-size: 0.8rem; color: #9CA3AF; }
        .order-status { padding: 0.25rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
        .status-pending, .status-waiting { background: rgba(245,166,35,0.2); color: #F5A623; }
        .status-received { background: rgba(16,185,129,0.2); color: #10B981; }
        .status-cancelled, .status-expired { background: rgba(239,68,68,0.2); color: #EF4444; }
        .empty { text-align: center; padding: 2rem; color: #9CA3AF; }
        .empty i { font-size: 2rem; color: #1E3A5F; display: block; margin-bottom: 0.5rem; }
        .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #0F2744; display: flex; justify-content: space-around; padding: 0.75rem 0; border-top: 1px solid #1E3A5F; z-index: 100; }
        .bottom-nav a { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #9CA3AF; font-size: 0.7rem; gap: 0.25rem; }
        .bottom-nav a i { font-size: 1.25rem; }
        .bottom-nav a.active { color: #F5A623; }
        .content { padding-bottom: 80px; }
        .loading { display: none; text-align: center; padding: 0.5rem; color: #9CA3AF; }
        .loading.show { display: block; }
        .loading i { animation: spin 1s linear infinite; }
    </style>
    <link rel="stylesheet" href="/assets/css/premium-dark.css">
</head>
<body>
    <header class="header">
        <button class="hamburger" onclick="toggleMenu()"><i class="fas fa-bars"></i></button>
        <div class="header-logo"><img src="/assets/images/logo.png" alt="<?php echo SITE_NAME; ?>"></div>
        <div class="header-balance"><?php echo formatCurrency($currentBalance); ?></div>
    </header>
    <div class="menu-overlay" id="menuOverlay" onclick="toggleMenu()"></div>
    <nav class="side-menu" id="sideMenu">
        <div class="menu-header">
            <div class="header-logo"><img src="/assets/images/logo.png" alt="<?php echo SITE_NAME; ?>"></div>
            <button class="menu-close" onclick="toggleMenu()"><i class="fas fa-times"></i></button>
        </div>
        <div class="menu-items">
            <a href="dashboard.php" class="menu-item"><i class="fas fa-home"></i> Dashboard</a>
            <a href="sms.php" class="menu-item active"><i class="fas fa-sms"></i> SMS Service</a>
            <a href="smm.php" class="menu-item"><i class="fas fa-rocket"></i> SMM Service</a>
            <a href="banner.php" class="menu-item"><i class="fas fa-ad"></i> Banner Service</a>
            <a href="orders.php" class="menu-item"><i class="fas fa-history"></i> Orders</a>
            <a href="add-funds.php" class="menu-item"><i class="fas fa-wallet"></i> Add Funds</a>
            <a href="transactions.php" class="menu-item"><i class="fas fa-exchange-alt"></i> Transactions</a>
            <a href="profile.php" class="menu-item"><i class="fas fa-user"></i> Profile</a>
            <div class="menu-divider"></div>
            <a href="<?php echo SITE_URL; ?>/logout.php" class="menu-item"><i class="fas fa-sign-out-alt"></i> Log Out</a>
        </div>
    </nav>
    <main class="content">
        <h1 class="page-title"><i class="fas fa-sms"></i> SMS Verification Service</h1>
        
        <?php if ($error): ?><div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div><?php endif; ?>
        <?php if ($success): ?><div class="alert alert-success"><?php echo htmlspecialchars($success); ?></div><?php endif; ?>
        
        <div class="card">
            <h3 class="card-title"><i class="fas fa-mobile-alt"></i> Order New Number</h3>
            <form method="POST" id="orderForm">
                <?php echo csrfTokenField(); ?>
                <input type="hidden" name="action" value="order">
                
                <div class="form-group">
                    <label class="form-label">Select Service</label>
                    <div class="search-select-wrapper">
                        <input type="text" class="form-control search-input" id="serviceSearch" placeholder="Search service (e.g. WhatsApp, Telegram)..." autocomplete="off">
                        <div class="search-dropdown" id="serviceDropdown">
                            <?php foreach ($services as $service): ?>
                            <div class="search-option" data-value="<?php echo $service['id']; ?>"><?php echo htmlspecialchars($service['custom_name']); ?></div>
                            <?php endforeach; ?>
                        </div>
                    </div>
                    <input type="hidden" name="service_id" id="serviceSelect" required>
                </div>
                
                <div class="form-group">
                    <label class="form-label">Select Country</label>
                    <div class="search-select-wrapper">
                        <input type="text" class="form-control search-input" id="countrySearch" placeholder="Search country (e.g. USA, UK)..." autocomplete="off">
                        <div class="search-dropdown" id="countryDropdown">
                            <?php foreach ($countries as $country): ?>
                            <div class="search-option" data-value="<?php echo $country['id']; ?>"><?php echo htmlspecialchars($country['name']); ?><?php if($country['short_name']): ?> (<?php echo htmlspecialchars($country['short_name']); ?>)<?php endif; ?></div>
                            <?php endforeach; ?>
                        </div>
                    </div>
                    <input type="hidden" name="country_id" id="countrySelect" required>
                </div>
                
                <div class="loading" id="priceLoading"><i class="fas fa-spinner"></i> Getting price...</div>
                <div class="price-display" id="priceDisplay" style="display:none;">Select service & country</div>
                
                <button type="submit" class="btn btn-gold" id="orderBtn" disabled><i class="fas fa-shopping-cart"></i> Order Number</button>
            </form>
        </div>
        
    </main>
    <nav class="bottom-nav">
        <a href="dashboard.php"><i class="fas fa-home"></i> Home</a>
        <a href="sms.php" class="active"><i class="fas fa-sms"></i> SMS</a>
        <a href="smm.php"><i class="fas fa-rocket"></i> SMM</a>
        <a href="orders.php"><i class="fas fa-history"></i> Orders</a>
        <a href="profile.php"><i class="fas fa-user"></i> Profile</a>
    </nav>
    <script>
        function toggleMenu() { document.getElementById('sideMenu').classList.toggle('active'); document.getElementById('menuOverlay').classList.toggle('active'); }
        
        var userBalance = <?php echo $currentBalance; ?>;
        
        // Searchable Dropdown Handler
        function initSearchableSelect(searchId, dropdownId, hiddenId) {
            var searchInput = document.getElementById(searchId);
            var dropdown = document.getElementById(dropdownId);
            var hiddenInput = document.getElementById(hiddenId);
            var options = dropdown.querySelectorAll('.search-option');
            var highlightedIndex = -1;
            
            // Show dropdown on focus
            searchInput.addEventListener('focus', function() {
                dropdown.classList.add('show');
                filterOptions('');
            });
            
            // Filter on input
            searchInput.addEventListener('input', function() {
                dropdown.classList.add('show');
                filterOptions(this.value);
                hiddenInput.value = '';
                searchInput.classList.remove('selected');
                highlightedIndex = -1;
            });
            
            // Keyboard navigation
            searchInput.addEventListener('keydown', function(e) {
                var visibleOptions = Array.from(options).filter(function(opt) {
                    return !opt.classList.contains('hidden');
                });
                
                if (e.key === 'ArrowDown') {
                    e.preventDefault();
                    highlightedIndex = Math.min(highlightedIndex + 1, visibleOptions.length - 1);
                    updateHighlight(visibleOptions);
                } else if (e.key === 'ArrowUp') {
                    e.preventDefault();
                    highlightedIndex = Math.max(highlightedIndex - 1, 0);
                    updateHighlight(visibleOptions);
                } else if (e.key === 'Enter') {
                    e.preventDefault();
                    if (highlightedIndex >= 0 && visibleOptions[highlightedIndex]) {
                        selectOption(visibleOptions[highlightedIndex]);
                    }
                } else if (e.key === 'Escape') {
                    dropdown.classList.remove('show');
                }
            });
            
            function updateHighlight(visibleOptions) {
                options.forEach(function(opt) { opt.classList.remove('highlighted'); });
                if (visibleOptions[highlightedIndex]) {
                    visibleOptions[highlightedIndex].classList.add('highlighted');
                    visibleOptions[highlightedIndex].scrollIntoView({ block: 'nearest' });
                }
            }
            
            // Filter options
            function filterOptions(query) {
                var hasResults = false;
                query = query.toLowerCase();
                options.forEach(function(opt) {
                    var text = opt.textContent.toLowerCase();
                    if (text.includes(query)) {
                        opt.classList.remove('hidden');
                        hasResults = true;
                    } else {
                        opt.classList.add('hidden');
                    }
                });
                
                // Show "no results" message
                var noResults = dropdown.querySelector('.no-results');
                if (!hasResults) {
                    if (!noResults) {
                        noResults = document.createElement('div');
                        noResults.className = 'no-results';
                        noResults.textContent = 'No results found';
                        dropdown.appendChild(noResults);
                    }
                    noResults.style.display = 'block';
                } else if (noResults) {
                    noResults.style.display = 'none';
                }
            }
            
            // Select option
            function selectOption(opt) {
                hiddenInput.value = opt.dataset.value;
                searchInput.value = opt.textContent;
                searchInput.classList.add('selected');
                dropdown.classList.remove('show');
                highlightedIndex = -1;
                getPrice();
            }
            
            // Click on option
            options.forEach(function(opt) {
                opt.addEventListener('click', function() {
                    selectOption(this);
                });
            });
            
            // Close dropdown when clicking outside
            document.addEventListener('click', function(e) {
                if (!searchInput.contains(e.target) && !dropdown.contains(e.target)) {
                    dropdown.classList.remove('show');
                }
            });
        }
        
        // Initialize searchable selects
        initSearchableSelect('serviceSearch', 'serviceDropdown', 'serviceSelect');
        initSearchableSelect('countrySearch', 'countryDropdown', 'countrySelect');
        
        function getPrice() {
            var countryId = document.getElementById('countrySelect').value;
            var serviceId = document.getElementById('serviceSelect').value;
            var priceDisplay = document.getElementById('priceDisplay');
            var orderBtn = document.getElementById('orderBtn');
            var loading = document.getElementById('priceLoading');
            
            priceDisplay.style.display = 'none';
            orderBtn.disabled = true;
            
            if (!countryId || !serviceId) {
                return;
            }
            
            loading.classList.add('show');
            
            var xhr = new XMLHttpRequest();
            xhr.open('GET', '<?php echo SITE_URL; ?>/api/sms-price.php?country_id=' + countryId + '&service_id=' + serviceId, true);
            xhr.onload = function() {
                loading.classList.remove('show');
                if (xhr.status === 200) {
                    try {
                        var data = JSON.parse(xhr.responseText);
                        if (data.success && data.custom_price) {
                            var price = parseFloat(data.custom_price);
                            priceDisplay.textContent = '$' + price.toFixed(2);
                            priceDisplay.style.display = 'block';
                            orderBtn.disabled = price > userBalance;
                        } else {
                            priceDisplay.textContent = 'Price not available';
                            priceDisplay.style.display = 'block';
                        }
                    } catch(e) {
                        priceDisplay.textContent = 'Error getting price';
                        priceDisplay.style.display = 'block';
                    }
                }
            };
            xhr.send();
        }
    </script>
</body>
</html>