<?php
/**
 * Account Addresses Page
 * Converted from account-addresses.html
 * User address management page
 */

$pageTitle = 'Cartzilla | Cont - Adrese';
$pageDescription = 'Cartzilla - Magazin Online E-Commerce';

// Initialize classes BEFORE header to allow redirects
require_once __DIR__ . '/includes/init.php';
$userObj = new User();
$auth = new Auth();

// Check if user is logged in
if (!$auth->isLoggedIn()) {
    header('Location: /cont/login?redirect=' . urlencode($_SERVER['REQUEST_URI']));
    exit;
}

$userId = $auth->getUserId();
$userData = $userObj->getUserById($userId);

// Handle form submissions (BEFORE header to allow redirects)
$successMessage = '';
$errorMessage = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (isset($_POST['action'])) {
        switch ($_POST['action']) {
            case 'add_address':
                $addressData = [
                    'first_name' => $_POST['first_name'] ?? '',
                    'last_name' => $_POST['last_name'] ?? '',
                    'email' => $_POST['email'] ?? $userData['email'],
                    'phone' => $_POST['phone'] ?? '',
                    'company_name' => $_POST['company_name'] ?? '',
                    'cui' => $_POST['cui'] ?? '',
                    'reg_com' => $_POST['reg_com'] ?? '',
                    'country' => $_POST['country'] ?? 'Romania',
                    'county' => $_POST['county'] ?? '',
                    'city' => $_POST['city'] ?? '',
                    'postcode' => $_POST['postcode'] ?? '',
                    'address_line1' => $_POST['address_line1'] ?? '',
                    'address_line2' => $_POST['address_line2'] ?? '',
                    'is_default' => isset($_POST['is_default']) ? 1 : 0
                ];
                
                if ($userObj->addAddress($userId, $addressData)) {
                    $successMessage = 'Adresa a fost adăugată cu succes!';
                } else {
                    $errorMessage = 'Eroare la adăugarea adresei.';
                }
                break;
                
            case 'update_address':
                $addressId = intval($_POST['address_id'] ?? 0);
                $addressData = [
                    'first_name' => $_POST['first_name'] ?? '',
                    'last_name' => $_POST['last_name'] ?? '',
                    'email' => $_POST['email'] ?? $userData['email'],
                    'phone' => $_POST['phone'] ?? '',
                    'company_name' => $_POST['company_name'] ?? '',
                    'cui' => $_POST['cui'] ?? '',
                    'reg_com' => $_POST['reg_com'] ?? '',
                    'country' => $_POST['country'] ?? 'Romania',
                    'county' => $_POST['county'] ?? '',
                    'city' => $_POST['city'] ?? '',
                    'postcode' => $_POST['postcode'] ?? '',
                    'address_line1' => $_POST['address_line1'] ?? '',
                    'address_line2' => $_POST['address_line2'] ?? '',
                    'is_default' => isset($_POST['is_default']) ? 1 : 0
                ];
                
                if ($userObj->updateAddress($addressId, $userId, $addressData)) {
                    $successMessage = 'Adresa a fost actualizată cu succes!';
                } else {
                    $errorMessage = 'Eroare la actualizarea adresei.';
                }
                break;
                
            case 'delete_address':
                $addressId = intval($_POST['address_id'] ?? 0);
                if ($userObj->deleteAddress($addressId, $userId)) {
                    $successMessage = 'Adresa a fost ștearsă cu succes!';
                } else {
                    $errorMessage = 'Eroare la ștergerea adresei.';
                }
                break;
                
            case 'set_default':
                $addressId = intval($_POST['address_id'] ?? 0);
                // Unset all defaults first
                $db = Database::getInstance();
                $db->execute("UPDATE addresses SET is_default = 0 WHERE user_id = ?", [$userId]);
                // Set new default
                $db->execute("UPDATE addresses SET is_default = 1 WHERE id = ? AND user_id = ?", [$addressId, $userId]);
                $successMessage = 'Adresa implicită a fost actualizată!';
                break;
        }
        
        // Refresh page to show updated data
        if ($successMessage || $errorMessage) {
            header('Location: /cont/adrese?success=' . urlencode($successMessage) . '&error=' . urlencode($errorMessage));
            exit;
        }
    }
}

// Get success/error messages from URL
if (isset($_GET['success'])) {
    $successMessage = $_GET['success'];
}
if (isset($_GET['error'])) {
    $errorMessage = $_GET['error'];
}

// Get user addresses
$addresses = $userObj->getUserAddresses($userId);

// Now include header (after all redirects and form processing are handled)
require_once __DIR__ . '/includes/header.php';

// Romanian counties
$romanianCounties = ['Alba', 'Arad', 'Argeș', 'Bacău', 'Bihor', 'Bistrița-Năsăud', 'Botoșani', 'Brașov', 'Brăila', 'Buzău', 'Caraș-Severin', 'Călărași', 'Cluj', 'Constanța', 'Covasna', 'Dâmbovița', 'Dolj', 'Galați', 'Giurgiu', 'Gorj', 'Harghita', 'Hunedoara', 'Ialomița', 'Iași', 'Ilfov', 'Maramureș', 'Mehedinți', 'Mureș', 'Neamț', 'Olt', 'Prahova', 'Satu Mare', 'Sălaj', 'Sibiu', 'Suceava', 'Teleorman', 'Timiș', 'Tulcea', 'Vâlcea', 'Vaslui', 'Vrancea'];
?>

    <!-- Page content -->
    <main class="content-wrapper">
      <div class="container py-5 mt-n2 mt-sm-0">
        <div class="row pt-md-2 pt-lg-3 pb-sm-2 pb-md-3 pb-lg-4 pb-xl-5">

          <!-- Sidebar navigation -->
          <aside class="col-lg-3">
            <div class="offcanvas-lg offcanvas-start pe-lg-0 pe-xl-4" id="accountSidebar">

              <!-- Header -->
              <div class="offcanvas-header d-lg-block py-3 p-lg-0">
                <div class="d-flex align-items-center">
                  <div class="h5 d-flex justify-content-center align-items-center flex-shrink-0 text-primary bg-primary-subtle lh-1 rounded-circle mb-0" style="width: 3rem; height: 3rem">
                    <?php echo strtoupper(mb_substr($userData['first_name'], 0, 1) . mb_substr($userData['last_name'], 0, 1)); ?>
                  </div>
                  <div class="min-w-0 ps-3">
                    <h5 class="h6 mb-1"><?php echo htmlspecialchars($userData['first_name'] . ' ' . $userData['last_name']); ?></h5>
                    <div class="nav flex-nowrap text-nowrap min-w-0">
                      <a class="nav-link animate-underline text-body p-0" href="#bonusesModal" data-bs-toggle="modal">
                        <svg class="text-warning flex-shrink-0 me-2" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"><path d="M1.333 9.667H7.5V16h-5c-.64 0-1.167-.527-1.167-1.167V9.667zm13.334 0v5.167c0 .64-.527 1.167-1.167 1.167h-5V9.667h6.167zM0 5.833V7.5c0 .64.527 1.167 1.167 1.167h.167H7.5v-1-3H1.167C.527 4.667 0 5.193 0 5.833zm14.833-1.166H8.5v3 1h6.167.167C15.473 8.667 16 8.14 16 7.5V5.833c0-.64-.527-1.167-1.167-1.167z"/><path d="M8 5.363a.5.5 0 0 1-.495-.573C7.752 3.123 9.054-.03 12.219-.03c1.807.001 2.447.977 2.447 1.813 0 1.486-2.069 3.58-6.667 3.58zM12.219.971c-2.388 0-3.295 2.27-3.595 3.377 1.884-.088 3.072-.565 3.756-.971.949-.563 1.287-1.193 1.287-1.595 0-.599-.747-.811-1.447-.811z"/><path d="M8.001 5.363c-4.598 0-6.667-2.094-6.667-3.58 0-.836.641-1.812 2.448-1.812 3.165 0 4.467 3.153 4.713 4.819a.5.5 0 0 1-.495.573zM3.782.971c-.7 0-1.448.213-1.448.812 0 .851 1.489 2.403 5.042 2.566C7.076 3.241 6.169.971 3.782.971z"/></svg>
                        <span class="animate-target me-1"><?php echo $userData['loyalty_points'] ?? 0; ?> bonusuri</span>
                        <span class="text-body fw-normal text-truncate">disponibile</span>
                      </a>
                    </div>
                  </div>
                </div>
                <button type="button" class="btn-close d-lg-none" data-bs-dismiss="offcanvas" data-bs-target="#accountSidebar" aria-label="Close"></button>
              </div>

              <!-- Body (Navigation) -->
              <div class="offcanvas-body d-block pt-2 pt-lg-4 pb-lg-0">
                <nav class="list-group list-group-borderless">
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/cont/comenzi">
                    <i class="ci-shopping-bag fs-base opacity-75 me-2"></i>
                    Comenzi
                  </a>
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/cont/wishlist">
                    <i class="ci-heart fs-base opacity-75 me-2"></i>
                    Lista de dorințe
                  </a>
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/cont/plata">
                    <i class="ci-credit-card fs-base opacity-75 me-2"></i>
                    Metode de plată
                  </a>
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/cont/recenzii">
                    <i class="ci-star fs-base opacity-75 me-2"></i>
                    Recenziile mele
                  </a>
                </nav>
                <h6 class="pt-4 ps-2 ms-1">Gestionează contul</h6>
                <nav class="list-group list-group-borderless">
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/cont/info">
                    <i class="ci-user fs-base opacity-75 me-2"></i>
                    Informații personale
                  </a>
                  <a class="list-group-item list-group-item-action d-flex align-items-center pe-none active" href="/cont/adrese">
                    <i class="ci-map-pin fs-base opacity-75 me-2"></i>
                    Adrese
                  </a>
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/cont/notificari">
                    <i class="ci-bell fs-base opacity-75 mt-1 me-2"></i>
                    Notificări
                  </a>
                </nav>
                <h6 class="pt-4 ps-2 ms-1">Servicii clienți</h6>
                <nav class="list-group list-group-borderless">
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/contact">
                    <i class="ci-help-circle fs-base opacity-75 me-2"></i>
                    Centru de ajutor
                  </a>
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/terms-and-conditions">
                    <i class="ci-info fs-base opacity-75 me-2"></i>
                    Termeni și condiții
                  </a>
                </nav>
                <nav class="list-group list-group-borderless pt-3">
                  <a class="list-group-item list-group-item-action d-flex align-items-center" href="/api/auth.php?action=logout">
                    <i class="ci-log-out fs-base opacity-75 me-2"></i>
                    Deconectare
                  </a>
                </nav>
              </div>
            </div>
          </aside>


          <!-- Addresses content -->
          <div class="col-lg-9">
            <div class="ps-lg-3 ps-xl-0">

              <!-- Page title -->
              <div class="d-flex align-items-center justify-content-between mb-4">
                <h1 class="h2 mb-0">Adrese</h1>
                <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newAddressModal">
                  <i class="ci-plus fs-base me-2"></i>
                  Adaugă adresă nouă
                </button>
              </div>

              <?php if ($successMessage): ?>
              <div class="alert alert-success alert-dismissible fade show" role="alert">
                <?php echo htmlspecialchars($successMessage); ?>
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
              </div>
              <?php endif; ?>

              <?php if ($errorMessage): ?>
              <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <?php echo htmlspecialchars($errorMessage); ?>
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
              </div>
              <?php endif; ?>

              <?php if (empty($addresses)): ?>
              <!-- Empty addresses -->
              <div class="text-center py-5">
                <i class="ci-map-pin fs-1 text-body-secondary mb-3"></i>
                <h3 class="h5 mb-2">Nu ai adrese salvate</h3>
                <p class="text-body-secondary mb-4">Adaugă o adresă pentru a accelera procesul de checkout.</p>
                <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newAddressModal">
                  Adaugă prima adresă
                </button>
              </div>
              <?php else: ?>
              <!-- Addresses list -->
              <?php foreach ($addresses as $address): ?>
              <div class="border-bottom py-4">
                <div class="nav flex-nowrap align-items-center justify-content-between pb-1 mb-3">
                  <div class="d-flex align-items-center gap-3 me-4">
                    <h2 class="h6 mb-0">Adresă de livrare</h2>
                    <?php if ($address['is_default']): ?>
                    <span class="badge text-bg-info rounded-pill">Implicită</span>
                    <?php endif; ?>
                  </div>
                  <div class="d-flex gap-2">
                    <?php if (!$address['is_default']): ?>
                    <form method="POST" class="d-inline">
                      <input type="hidden" name="action" value="set_default">
                      <input type="hidden" name="address_id" value="<?php echo $address['id']; ?>">
                      <button type="submit" class="btn btn-sm btn-outline-primary">Setează ca implicită</button>
                    </form>
                    <?php endif; ?>
                    <a class="nav-link hiding-collapse-toggle text-decoration-underline p-0 collapsed" href=".address-<?php echo $address['id']; ?>" data-bs-toggle="collapse" aria-expanded="false" aria-controls="addressPreview<?php echo $address['id']; ?> addressEdit<?php echo $address['id']; ?>">Editează</a>
                    <form method="POST" class="d-inline" onsubmit="return confirm('Ești sigur că vrei să ștergi această adresă?');">
                      <input type="hidden" name="action" value="delete_address">
                      <input type="hidden" name="address_id" value="<?php echo $address['id']; ?>">
                      <button type="submit" class="btn btn-sm btn-outline-danger">Șterge</button>
                    </form>
                  </div>
                </div>
                <div class="collapse address-<?php echo $address['id']; ?> show" id="addressPreview<?php echo $address['id']; ?>">
                  <ul class="list-unstyled fs-sm m-0">
                    <li class="mb-1"><strong><?php echo htmlspecialchars($address['first_name'] . ' ' . $address['last_name']); ?></strong></li>
                    <?php if ($address['company_name']): ?>
                    <li><?php echo htmlspecialchars($address['company_name']); ?></li>
                    <?php endif; ?>
                    <li><?php echo htmlspecialchars($address['address_line1']); ?></li>
                    <?php if ($address['address_line2']): ?>
                    <li><?php echo htmlspecialchars($address['address_line2']); ?></li>
                    <?php endif; ?>
                    <li><?php echo htmlspecialchars($address['city'] . ', ' . $address['county'] . ' ' . $address['postcode']); ?></li>
                    <li><?php echo htmlspecialchars($address['country']); ?></li>
                    <?php if ($address['phone']): ?>
                    <li><?php echo htmlspecialchars($address['phone']); ?></li>
                    <?php endif; ?>
                    <?php if ($address['email']): ?>
                    <li><?php echo htmlspecialchars($address['email']); ?></li>
                    <?php endif; ?>
                  </ul>
                </div>
                <div class="collapse address-<?php echo $address['id']; ?>" id="addressEdit<?php echo $address['id']; ?>">
                  <form method="POST" class="row g-3 g-sm-4 needs-validation" novalidate>
                    <input type="hidden" name="action" value="update_address">
                    <input type="hidden" name="address_id" value="<?php echo $address['id']; ?>">
                    <div class="col-sm-6">
                      <label for="first_name_<?php echo $address['id']; ?>" class="form-label">Prenume <span class="text-danger">*</span></label>
                      <input type="text" class="form-control" id="first_name_<?php echo $address['id']; ?>" name="first_name" value="<?php echo htmlspecialchars($address['first_name']); ?>" required>
                    </div>
                    <div class="col-sm-6">
                      <label for="last_name_<?php echo $address['id']; ?>" class="form-label">Nume <span class="text-danger">*</span></label>
                      <input type="text" class="form-control" id="last_name_<?php echo $address['id']; ?>" name="last_name" value="<?php echo htmlspecialchars($address['last_name']); ?>" required>
                    </div>
                    <div class="col-sm-6">
                      <label for="email_<?php echo $address['id']; ?>" class="form-label">Email</label>
                      <input type="email" class="form-control" id="email_<?php echo $address['id']; ?>" name="email" value="<?php echo htmlspecialchars($address['email'] ?? $userData['email']); ?>">
                    </div>
                    <div class="col-sm-6">
                      <label for="phone_<?php echo $address['id']; ?>" class="form-label">Telefon</label>
                      <input type="text" class="form-control" id="phone_<?php echo $address['id']; ?>" name="phone" value="<?php echo htmlspecialchars($address['phone'] ?? ''); ?>">
                    </div>
                    <div class="col-sm-6">
                      <label for="company_name_<?php echo $address['id']; ?>" class="form-label">Nume companie</label>
                      <input type="text" class="form-control" id="company_name_<?php echo $address['id']; ?>" name="company_name" value="<?php echo htmlspecialchars($address['company_name'] ?? ''); ?>">
                    </div>
                    <div class="col-sm-6">
                      <label for="cui_<?php echo $address['id']; ?>" class="form-label">CUI</label>
                      <input type="text" class="form-control" id="cui_<?php echo $address['id']; ?>" name="cui" value="<?php echo htmlspecialchars($address['cui'] ?? ''); ?>">
                    </div>
                    <div class="col-sm-6">
                      <label for="county_<?php echo $address['id']; ?>" class="form-label">Județ <span class="text-danger">*</span></label>
                      <select class="form-select" id="county_<?php echo $address['id']; ?>" name="county" required>
                        <option value="">Selectează județul</option>
                        <?php foreach ($romanianCounties as $county): ?>
                        <option value="<?php echo htmlspecialchars($county); ?>" <?php echo ($address['county'] === $county) ? 'selected' : ''; ?>><?php echo htmlspecialchars($county); ?></option>
                        <?php endforeach; ?>
                      </select>
                    </div>
                    <div class="col-sm-6">
                      <label for="city_<?php echo $address['id']; ?>" class="form-label">Oraș <span class="text-danger">*</span></label>
                      <input type="text" class="form-control" id="city_<?php echo $address['id']; ?>" name="city" value="<?php echo htmlspecialchars($address['city']); ?>" required>
                    </div>
                    <div class="col-sm-6">
                      <label for="postcode_<?php echo $address['id']; ?>" class="form-label">Cod poștal <span class="text-danger">*</span></label>
                      <input type="text" class="form-control" id="postcode_<?php echo $address['id']; ?>" name="postcode" value="<?php echo htmlspecialchars($address['postcode']); ?>" required>
                    </div>
                    <div class="col-sm-6">
                      <label for="address_line1_<?php echo $address['id']; ?>" class="form-label">Stradă și număr <span class="text-danger">*</span></label>
                      <input type="text" class="form-control" id="address_line1_<?php echo $address['id']; ?>" name="address_line1" value="<?php echo htmlspecialchars($address['address_line1']); ?>" required>
                    </div>
                    <div class="col-sm-6">
                      <label for="address_line2_<?php echo $address['id']; ?>" class="form-label">Adresă linia 2</label>
                      <input type="text" class="form-control" id="address_line2_<?php echo $address['id']; ?>" name="address_line2" value="<?php echo htmlspecialchars($address['address_line2'] ?? ''); ?>">
                    </div>
                    <div class="col-12">
                      <div class="form-check mb-0">
                        <input type="checkbox" class="form-check-input" id="is_default_<?php echo $address['id']; ?>" name="is_default" <?php echo $address['is_default'] ? 'checked' : ''; ?>>
                        <label for="is_default_<?php echo $address['id']; ?>" class="form-check-label">Setează ca adresă implicită</label>
                      </div>
                    </div>
                    <div class="col-12">
                      <div class="d-flex gap-3 pt-2 pt-sm-0">
                        <button type="submit" class="btn btn-primary">Salvează modificările</button>
                        <button type="button" class="btn btn-secondary" data-bs-toggle="collapse" data-bs-target=".address-<?php echo $address['id']; ?>" aria-expanded="true" aria-controls="addressPreview<?php echo $address['id']; ?> addressEdit<?php echo $address['id']; ?>">Anulează</button>
                      </div>
                    </div>
                  </form>
                </div>
              </div>
              <?php endforeach; ?>
              <?php endif; ?>
            </div>
          </div>
        </div>
      </div>
    </main>

    <!-- Add new address modal -->
    <div class="modal fade" id="newAddressModal" data-bs-backdrop="static" tabindex="-1" aria-labelledby="newAddressModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-dialog-scrollable">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="newAddressModalLabel">Adaugă adresă nouă</h5>
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body">
            <form method="POST" class="row g-3 g-sm-4 needs-validation" novalidate>
              <input type="hidden" name="action" value="add_address">
              <div class="col-sm-6">
                <label for="new_first_name" class="form-label">Prenume <span class="text-danger">*</span></label>
                <input type="text" class="form-control" id="new_first_name" name="first_name" value="<?php echo htmlspecialchars($userData['first_name']); ?>" required>
              </div>
              <div class="col-sm-6">
                <label for="new_last_name" class="form-label">Nume <span class="text-danger">*</span></label>
                <input type="text" class="form-control" id="new_last_name" name="last_name" value="<?php echo htmlspecialchars($userData['last_name']); ?>" required>
              </div>
              <div class="col-sm-6">
                <label for="new_email" class="form-label">Email</label>
                <input type="email" class="form-control" id="new_email" name="email" value="<?php echo htmlspecialchars($userData['email']); ?>">
              </div>
              <div class="col-sm-6">
                <label for="new_phone" class="form-label">Telefon</label>
                <input type="text" class="form-control" id="new_phone" name="phone" value="<?php echo htmlspecialchars($userData['phone'] ?? ''); ?>">
              </div>
              <div class="col-sm-6">
                <label for="new_company_name" class="form-label">Nume companie</label>
                <input type="text" class="form-control" id="new_company_name" name="company_name" value="<?php echo htmlspecialchars($userData['company_name'] ?? ''); ?>">
              </div>
              <div class="col-sm-6">
                <label for="new_cui" class="form-label">CUI</label>
                <input type="text" class="form-control" id="new_cui" name="cui" value="<?php echo htmlspecialchars($userData['cui'] ?? ''); ?>">
              </div>
              <div class="col-sm-6">
                <label for="new_county" class="form-label">Județ <span class="text-danger">*</span></label>
                <select class="form-select" id="new_county" name="county" required>
                  <option value="">Selectează județul</option>
                  <?php foreach ($romanianCounties as $county): ?>
                  <option value="<?php echo htmlspecialchars($county); ?>"><?php echo htmlspecialchars($county); ?></option>
                  <?php endforeach; ?>
                </select>
              </div>
              <div class="col-sm-6">
                <label for="new_city" class="form-label">Oraș <span class="text-danger">*</span></label>
                <input type="text" class="form-control" id="new_city" name="city" required>
              </div>
              <div class="col-sm-6">
                <label for="new_postcode" class="form-label">Cod poștal <span class="text-danger">*</span></label>
                <input type="text" class="form-control" id="new_postcode" name="postcode" required>
              </div>
              <div class="col-sm-6">
                <label for="new_address_line1" class="form-label">Stradă și număr <span class="text-danger">*</span></label>
                <input type="text" class="form-control" id="new_address_line1" name="address_line1" required>
              </div>
              <div class="col-12">
                <label for="new_address_line2" class="form-label">Adresă linia 2</label>
                <input type="text" class="form-control" id="new_address_line2" name="address_line2">
              </div>
              <div class="col-12">
                <div class="form-check mb-0">
                  <input type="checkbox" class="form-check-input" id="new_is_default" name="is_default">
                  <label for="new_is_default" class="form-check-label">Setează ca adresă implicită</label>
                </div>
              </div>
              <div class="col-12">
                <div class="d-flex gap-3 pt-2 pt-sm-0">
                  <button type="submit" class="btn btn-primary">Adaugă adresă</button>
                  <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Anulează</button>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>

<?php require_once __DIR__ . '/includes/footer.php'; ?>

