<!-- ══ DEPOIMENTOS DE CLIENTES ═══════════════════════════════════════════════════════ -->
<?php
// Configurações da seção depoimentos — mesmo padrão do CTA e Typewriter
$depStatus = $dbThemeConfig['depoimentos_status'] ?? 'ativo';
if ($depStatus !== 'ativo') return;

$depImagem = $dbThemeConfig['depoimentos_imagem'] ?? '';
$depImgUrl = !empty($depImagem) ? "../adm/uploads/depoimentos_bg/" . $depImagem : "";

$resDep = $conn->query("SELECT * FROM depoimentos WHERE status = 'Ativo' ORDER BY posicao ASC, id DESC");
$hasTestimonials = ($resDep && $resDep->num_rows > 0);
$isLoggedIn = isset($_SESSION['usuario_id']);
$userNome = $_SESSION['usuario_nome'] ?? $_SESSION['nome_completo'] ?? '';

if ($hasTestimonials) : ?>
    <div class="container-fluid testimonial-section py-5 my-5 wow fadeInUp" data-wow-delay="0.1s"
         style="background: linear-gradient(rgba(9, 30, 62, 0.7), rgba(9, 30, 62, 0.7)), url('<?= !empty($depImgUrl) ? $depImgUrl : "https://via.placeholder.com/1920x600" ?>') center center no-repeat; background-size: cover; background-attachment: fixed;">
        <div class="container py-5">
            <div class="row justify-content-center">
                <div class="col-lg-7">
                    <div class="owl-carousel testimonial-carousel rounded p-5 wow zoomIn" data-wow-delay="0.6s">
                        <?php while ($d = $resDep->fetch_assoc()) :
                            $imgDep = !empty($d['imagem']) ? '../adm/uploads/depoimentos/' . $d['imagem'] : 'img/testimonial-1.jpg';
                        ?>
                            <div class="testimonial-item text-center text-white">
                                <img class="img-fluid mx-auto rounded mb-4" src="<?= $imgDep ?>" alt="<?= htmlspecialchars($d['nome']) ?>" style="width: 100px; height: 100px; object-fit: cover;">
                                <div class="fs-5 text-white"><?= htmlspecialchars($d['texto'] ?? '') ?></div>
                                <hr class="mx-auto w-25">
                                <h4 class="text-white mb-0"><?= htmlspecialchars($d['nome']) ?></h4>
                            </div>
                        <?php endwhile; ?>
                    </div>
                    <div class="text-center mt-4 wow fadeInUp" data-wow-delay="0.9s">
                        <?php if ($isLoggedIn): ?>
                            <button type="button" class="btn btn-glass-primary py-3 px-5" data-bs-toggle="modal" data-bs-target="#modalDepoimento">
                                <i class="bi bi-chat-quote-fill me-2"></i>Deixar meu Depoimento
                            </button>
                        <?php else: ?>
                            <a href="login.php" class="btn btn-glass-primary py-3 px-5">
                                <i class="bi bi-person-lock me-2"></i>Faça login para avaliar
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php else : ?>
    <!-- Testimonial Empty Start (White BG) -->
    <div class="container-fluid testimonial-section py-5 my-5 wow fadeInUp" data-wow-delay="0.1s"
         style="background: linear-gradient(rgba(9, 30, 62, 0.7), rgba(9, 30, 62, 0.7)), url('<?= !empty($depImgUrl) ? $depImgUrl : "https://via.placeholder.com/1920x600" ?>') center center no-repeat; background-size: cover; background-attachment: fixed;">
        <div class="container py-5">
            <div class="row justify-content-center text-center">
                <div class="col-lg-7">
                    <div class="mb-4">
                        <i class="bi bi-chat-left-quote text-white" style="font-size: 3rem; opacity: 0.5;"></i>
                    </div>
                    <h2 class="display-6 mb-3 text-white">O que nossos clientes dizem?</h2>
                    <p class="fs-5 text-white mb-4" style="opacity:0.85;">Ainda não temos depoimentos. Seja o primeiro a compartilhar sua experiência!</p>
                    <?php if ($isLoggedIn): ?>
                        <button type="button" class="btn btn-glass-primary py-3 px-5" data-bs-toggle="modal" data-bs-target="#modalDepoimento">
                            <i class="bi bi-plus-circle me-2"></i>Seja o primeiro a avaliar
                        </button>
                    <?php else: ?>
                        <a href="login.php" class="btn btn-glass-primary py-3 px-5">
                            <i class="bi bi-person-lock me-2"></i>Faça login para avaliar
                        </a>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
    <!-- Testimonial Empty End -->
<?php endif; ?>

<style>
    @media (max-width: 991px) {
        .testimonial-section {
            background-attachment: scroll !important;
        }
    }
</style>
<!-- ══ FIM DEPOIMENTOS DE CLIENTES ═══════════════════════════════════════════════════════ -->