<?php require "includes/header.php"; ?>
<?php require "config/config.php"; ?>

<?php
// Auth guard
if (!isset($_SESSION['username'])) {
  header("location: " . APPURL . "index.php");
  exit;
}

// Fetch active hotels
$hotels_stmt = $conn->query("SELECT * FROM hotels WHERE status = 1 ORDER BY id ASC");
$hotels = $hotels_stmt->fetchAll(PDO::FETCH_OBJ);

// Fetch featured rooms (up to 6)
$rooms_stmt = $conn->query("SELECT * FROM rooms WHERE status = 1 ORDER BY id ASC LIMIT 6");
$rooms = $rooms_stmt->fetchAll(PDO::FETCH_OBJ);
?>

<!-- ════════════════════════════════════════════
     HERO SECTION
════════════════════════════════════════════ -->
<div class="hero-wrap js-fullheight" style="background-image: url('<?php echo APPURL; ?>images/hotel-bg.jpg');" data-stellar-background-ratio="0.5">
  <div class="overlay"></div>
  <div class="container">
    <div class="row no-gutters slider-text js-fullheight align-items-center justify-content-start" data-scrollax-parent="true">
      <div class="col-md-8 ftco-animate" data-scrollax="properties: { translateY: '70%' }">
        <span class="subheading" style="font-family:'DM Sans',sans-serif; font-size:12px; font-weight:700; letter-spacing:5px; text-transform:uppercase; color:#A39382; display:block; margin-bottom:20px;">
          Welcome to ShiaStay Hotels
        </span>
        <h1 class="mb-4" style="color:#fff; font-family:'Cormorant Garamond',serif; font-size:72px; line-height:1.1;">
          Where Comfort<br>Meets Elegance
        </h1>
        <p style="color:rgba(255,255,255,0.7); font-size:17px; max-width:520px; margin-bottom:36px;">
          Discover a world of refined hospitality. From luxurious suites to attentive service — every detail of your stay is our priority.
        </p>
        <p class="mb-0">
          <a href="<?php echo APPURL; ?>rooms.php" class="btn btn-primary mr-3" style="padding:16px 36px; font-size:11px; letter-spacing:2px;">
            <i class="fa fa-bed mr-2"></i>Explore Rooms
          </a>
          <a href="<?php echo APPURL; ?>contact.php" class="btn btn-white" style="padding:16px 36px; font-size:11px; letter-spacing:2px;">
            <i class="fa fa-phone mr-2"></i>Contact Us
          </a>
        </p>
      </div>
    </div>
  </div>
</div>

<!-- ════════════════════════════════════════════
     STAT STRIP
════════════════════════════════════════════ -->
<div class="stat-strip">
  <div class="container">
    <div class="row text-center">
      <div class="col-6 col-md-3 stat-item py-3">
        <div class="number">12<span style="color:rgba(163,147,130,0.8);">+</span></div>
        <div class="label">Properties</div>
      </div>
      <div class="col-6 col-md-3 stat-item py-3">
        <div class="number">500<span style="color:rgba(163,147,130,0.8);">+</span></div>
        <div class="label">Guest Rooms</div>
      </div>
      <div class="col-6 col-md-3 stat-item py-3">
        <div class="number">98<span style="color:rgba(163,147,130,0.8);">%</span></div>
        <div class="label">Guest Satisfaction</div>
      </div>
      <div class="col-6 col-md-3 stat-item py-3">
        <div class="number">24<span style="color:rgba(163,147,130,0.8);">/7</span></div>
        <div class="label">Concierge Service</div>
      </div>
    </div>
  </div>
</div>

<!-- ════════════════════════════════════════════
    AVAILABLE (Hotels)
════════════════════════════════════════════ -->
<?php if (count($hotels) > 0): ?>
  <section class="ftco-section" style="background:#F7F4EF; padding:80px 0;">
    <div class="container">
      <div class="row justify-content-center mb-5">
        <div class="col-md-8 text-center heading-section ftco-animate">
          <span class="section-eyebrow">Our Portfolio</span>
          <h2 style="font-size:46px;">Available Hotels</h2>
          <div class="gold-divider"></div>
          <p style="color:#4A5568; font-size:16px;">
            Hand-curated hotels and resorts across Ghana, each offering a distinct character and exceptional service.
          </p>
        </div>
      </div>
      <div class="row">
        <?php foreach ($hotels as $hotel): ?>
          <div class="col-md-4 d-flex services align-self-stretch px-3 mb-4 ftco-animate">
            <div class="d-block services-wrap text-center w-100">
              <div class="img" style="background-image: url(<?php echo APPURL; ?>images/<?php echo htmlspecialchars($hotel->image); ?>); height:220px; background-size:cover; background-position:center;"></div>
              <div class="media-body py-4 px-4">
                <h3 class="heading mb-2"><?php echo htmlspecialchars($hotel->name); ?></h3>
                <p style="font-size:12px; text-transform:uppercase; letter-spacing:1px; color:#A39382; margin-bottom:10px;">
                  <i class="fa fa-map-marker mr-1"></i><?php echo htmlspecialchars($hotel->location); ?>
                </p>
                <p style="color:#4A5568; font-size:14px; margin-bottom:20px;"><?php echo htmlspecialchars(substr($hotel->description, 0, 120)); ?>...</p>
                <a href="<?php echo APPURL; ?>rooms.php?id=<?php echo $hotel->id; ?>" class="btn-outline-gold">
                  View Rooms <i class="fa fa-arrow-right ml-1"></i>
                </a>
              </div>
            </div>
          </div>
        <?php endforeach; ?>
      </div>
    </div>
  </section>
<?php endif; ?>

<!-- ════════════════════════════════════════════
     FEATURED ROOMS
════════════════════════════════════════════ -->
<?php if (count($rooms) > 0): ?>
  <section style="background:#E5DED2; padding:80px 0;">
    <div class="container-fluid px-md-0">
      <div class="row justify-content-center mb-5">
        <div class="col-md-8 text-center heading-section ftco-animate">
          <span class="section-eyebrow">Accommodation</span>
          <h2 style="font-size:46px;">Featured Guest Rooms</h2>
          <div class="gold-divider"></div>
          <p style="color:#4A5568; font-size:16px;">
            Every room is thoughtfully designed to provide the highest level of comfort and luxury.
          </p>
        </div>
      </div>
      <div class="row no-gutters">
        <?php foreach ($rooms as $room): ?>
          <div class="col-lg-6 ftco-animate">
            <div class="room-wrap d-md-flex">
              <a href="<?php echo APPURL; ?>rooms/room-single.php?id=<?php echo $room->id; ?>" class="img" style="background-image: url(<?php echo APPURL; ?>images/<?php echo htmlspecialchars($room->image); ?>);"></a>
              <div class="half left-arrow d-flex align-items-center">
                <div class="text p-4 p-xl-5 text-center">
                  <p class="star mb-0">
                    <span class="fa fa-star"></span><span class="fa fa-star"></span>
                    <span class="fa fa-star"></span><span class="fa fa-star"></span>
                    <span class="fa fa-star"></span>
                  </p>
                  <span class="price-badge mb-2 d-inline-block">GH&#8373;<?php echo number_format($room->price ?? 0, 2); ?>/night</span>
                  <h3 class="mb-3">
                    <a href="<?php echo APPURL; ?>rooms/room-single.php?id=<?php echo $room->id; ?>" class="room">
                      <?php echo htmlspecialchars($room->name); ?>
                    </a>
                  </h3>
                  <ul class="list-accomodation">
                    <li><span>Capacity:</span> <?php echo htmlspecialchars($room->num_persons); ?> Guests</li>
                    <li><span>Room Size:</span> <?php echo htmlspecialchars($room->size); ?> m²</li>
                    <li><span>View:</span> <?php echo htmlspecialchars($room->view); ?></li>
                    <li><span>Bed Type:</span> <?php echo htmlspecialchars($room->num_beds); ?></li>
                  </ul>
                  <p class="pt-1">
                    <a href="<?php echo APPURL; ?>rooms/room-single.php?id=<?php echo $room->id; ?>" class="btn-custom px-3 py-2">
                      Reserve This Room <span class="icon-long-arrow-right"></span>
                    </a>
                  </p>
                </div>
              </div>
            </div>
          </div>
        <?php endforeach; ?>
      </div>
      <div class="text-center mt-5">
        <a href="<?php echo APPURL; ?>rooms.php" class="btn btn-primary" style="padding:16px 48px; font-size:11px; letter-spacing:2px;">
          View All Rooms
        </a>
      </div>
    </div>
  </section>
<?php endif; ?>

<!-- ════════════════════════════════════════════
     AMENITIES SECTION
════════════════════════════════════════════ -->
<section style="background:#F7F4EF; padding:80px 0;">
  <div class="container">
    <div class="row justify-content-center mb-5">
      <div class="col-md-8 text-center heading-section ftco-animate">
        <span class="section-eyebrow">Hotel Facilities</span>
        <h2 style="font-size:46px;">World-Class Amenities</h2>
        <div class="gold-divider"></div>
        <p style="color:#232323; font-size:16px;">
          Every facility at ShiaStay is designed to enhance your stay and exceed your expectations.
        </p>
      </div>
    </div>
    <div class="row">
      <div class="col-md-4 mb-4 ftco-animate">
        <div class="amenity-card">
          <div class="amenity-icon"><i class="fa fa-cutlery"></i></div>
          <h5>Fine Dining Restaurant</h5>
          <p>Savor exceptional cuisine crafted by our executive chefs. Open for breakfast, lunch, and dinner, featuring local and international dishes.</p>
        </div>
      </div>
      <div class="col-md-4 mb-4 ftco-animate">
        <div class="amenity-card">
          <div class="amenity-icon"><i class="fa fa-tint"></i></div>
          <h5>Swimming Pool & Spa</h5>
          <p>Unwind in our rooftop infinity pool or rejuvenate at our full-service spa with professional treatments and wellness programs.</p>
        </div>
      </div>
      <div class="col-md-4 mb-4 ftco-animate">
        <div class="amenity-card">
          <div class="amenity-icon"><i class="fa fa-wifi"></i></div>
          <h5>High-Speed Wi-Fi</h5>
          <p>Stay connected with complimentary high-speed internet access throughout the entire property — in rooms, lobbies, and event spaces.</p>
        </div>
      </div>
      <div class="col-md-4 mb-4 ftco-animate">
        <div class="amenity-card">
          <div class="amenity-icon"><i class="fa fa-car"></i></div>
          <h5>Valet & Parking</h5>
          <p>Enjoy hassle-free arrivals with our professional valet service and secure on-site parking available around the clock.</p>
        </div>
      </div>
      <div class="col-md-4 mb-4 ftco-animate">
        <div class="amenity-card">
          <div class="amenity-icon"><i class="fa fa-briefcase"></i></div>
          <h5>Conference & Events</h5>
          <p>Host corporate meetings, conferences, and private events in our state-of-the-art venues fully equipped with AV technology.</p>
        </div>
      </div>
      <div class="col-md-4 mb-4 ftco-animate">
        <div class="amenity-card">
          <div class="amenity-icon"><i class="fa fa-bell"></i></div>
          <h5>24/7 Concierge</h5>
          <p>Our dedicated concierge team is always available to assist with reservations, transportation, tours, and any special requests.</p>
        </div>
      </div>
    </div>
  </div>
</section>

<!-- ════════════════════════════════════════════
     CTA BANNER
════════════════════════════════════════════ -->
<div class="cta-banner">
  <div class="container" style="position:relative; z-index:2;">
    <div class="row justify-content-center">
      <div class="col-md-8 text-center">
        <span class="section-eyebrow" style="color:#A39382;">Your Next Stay Awaits</span>
        <h2>Reserve Your Room Tonight</h2>
        <p style="color:rgba(255,255,255,0.65); font-size:16px; margin-bottom:36px;">
          Experience unmatched comfort and elegance. Our front desk team is available 24/7 to make your reservation seamless.
        </p>
        <a href="<?php echo APPURL; ?>rooms.php" class="btn btn-primary mr-3" style="padding:18px 48px; font-size:11px; letter-spacing:2px;">
          <i class="fa fa-calendar-check-o mr-2"></i>Book Now
        </a>
        <a href="<?php echo APPURL; ?>contact.php" class="btn btn-white" style="padding:18px 48px; font-size:11px; letter-spacing:2px;">
          <i class="fa fa-phone mr-2"></i>Call Us
        </a>
      </div>
    </div>
  </div>
</div>

<?php require "includes/footer.php"; ?>