<?php
/**
 * Template Name: Giao diện Đối tác
 * Template Post Type: page
 *
 * @package Theme_An_Phat
 */

get_header(); ?>

<div class="page-hero text-center py-5">
    <div class="container">
        <h1 class="page-title font-heading fw-bold text-white mb-2"><?php the_title(); ?></h1>
        <div class="accent-line mx-auto bg-accent"></div>
        <div class="breadcrumbs mt-3 text-sm text-white-70">
            <a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="text-white-70 hover-white text-decoration-none"><?php esc_html_e( 'Trang chủ', 'theme-anphat' ); ?></a>
            <span class="mx-2">/</span>
            <span class="text-white"><?php esc_html_e( 'Đối tác', 'theme-anphat' ); ?></span>
        </div>
    </div>
</div>

<main id="primary" class="site-main py-5 bg-light text-dark">
    <div class="container">
        <div class="section-header text-center mb-5 scroll-reveal">
            <h2 class="font-heading fw-bold text-primary mb-2"><?php esc_html_e( 'ĐỐI TÁC CHIẾN LƯỢC', 'theme-anphat' ); ?></h2>
            <p class="text-muted max-w-2xl mx-auto mt-2">
                <?php esc_html_e( 'An Phát Pharma tự hào hợp tác chặt chẽ cùng các hãng dược danh tiếng toàn cầu và các cơ sở y tế hàng đầu Việt Nam để đưa thuốc chất lượng tốt tới tận tay người dân.', 'theme-anphat' ); ?>
            </p>
        </div>

        <div class="row g-4 scroll-reveal-right">
            <?php
            $args = array(
                'post_type'      => 'doi_tac',
                'posts_per_page' => -1,
                'orderby'        => 'title',
                'order'          => 'ASC'
            );
            $query = new WP_Query( $args );

            if ( $query->have_posts() ) :
                while ( $query->have_posts() ) : $query->the_post();
                    $terms = get_the_terms( get_the_ID(), 'loai_doi_tac' );
                    $loai_doi_tac = ( $terms && ! is_wp_error( $terms ) ) ? $terms[0]->name : __( 'Đại lý', 'theme-anphat' );
                    ?>
                    <div class="col-lg-3 col-md-4 col-sm-6 d-flex">
                        <div class="partner-details-card bg-white border rounded-4 shadow-sm p-4 text-center w-100 d-flex flex-column hover-shadow">
                            <div class="partner-logo-box rounded bg-light p-3 mb-3 d-flex align-items-center justify-content-center border" style="height: 100px;">
                                <?php if ( has_post_thumbnail() ) : ?>
                                    <?php the_post_thumbnail( 'medium', array( 'class' => 'img-fluid max-h-100' ) ); ?>
                                <?php else : ?>
                                    <span class="fs-4 fw-bold text-primary"><?php the_title(); ?></span>
                                <?php endif; ?>
                            </div>
                            <h3 class="font-heading fw-bold text-dark fs-6 mb-2"><?php the_title(); ?></h3>
                            <span class="badge bg-primary-light text-primary mx-auto mb-2 text-xs"><?php echo esc_html( $loai_doi_tac ); ?></span>
                        </div>
                    </div>
                <?php
                endwhile;
                wp_reset_postdata();
            else :
                ?>
                <!-- Seeding default visual mockups if no CPT posts yet -->
                <div class="col-lg-3 col-md-4 col-sm-6 d-flex">
                    <div class="partner-details-card bg-white border rounded-4 shadow-sm p-4 text-center w-100 d-flex flex-column hover-shadow">
                        <div class="partner-logo-box rounded bg-light p-3 mb-3 d-flex align-items-center justify-content-center border" style="height: 100px;"><span class="fs-4 fw-bold text-primary">GETZ PHARMA</span></div>
                        <h3 class="font-heading fw-bold text-dark fs-6 mb-2">Getz Pharma</h3>
                        <span class="badge bg-primary-light text-primary mx-auto mb-2 text-xs"><?php esc_html_e( 'Đối tác Quốc tế', 'theme-anphat' ); ?></span>
                    </div>
                </div>
                <div class="col-lg-3 col-md-4 col-sm-6 d-flex">
                    <div class="partner-details-card bg-white border rounded-4 shadow-sm p-4 text-center w-100 d-flex flex-column hover-shadow">
                        <div class="partner-logo-box rounded bg-light p-3 mb-3 d-flex align-items-center justify-content-center border" style="height: 100px;"><span class="fs-4 fw-bold text-primary">SANOFI</span></div>
                        <h3 class="font-heading fw-bold text-dark fs-6 mb-2">Sanofi-Aventis</h3>
                        <span class="badge bg-primary-light text-primary mx-auto mb-2 text-xs"><?php esc_html_e( 'Đối tác Quốc tế', 'theme-anphat' ); ?></span>
                    </div>
                </div>
                <div class="col-lg-3 col-md-4 col-sm-6 d-flex">
                    <div class="partner-details-card bg-white border rounded-4 shadow-sm p-4 text-center w-100 d-flex flex-column hover-shadow">
                        <div class="partner-logo-box rounded bg-light p-3 mb-3 d-flex align-items-center justify-content-center border" style="height: 100px;"><span class="fs-4 fw-bold text-primary">BV ĐỒNG NAI</span></div>
                        <h3 class="font-heading fw-bold text-dark fs-6 mb-2">Bệnh Viện Đa Khoa Đồng Nai</h3>
                        <span class="badge bg-primary-light text-primary mx-auto mb-2 text-xs"><?php esc_html_e( 'Đối tác Trong nước', 'theme-anphat' ); ?></span>
                    </div>
                </div>
                <div class="col-lg-3 col-md-4 col-sm-6 d-flex">
                    <div class="partner-details-card bg-white border rounded-4 shadow-sm p-4 text-center w-100 d-flex flex-column hover-shadow">
                        <div class="partner-logo-box rounded bg-light p-3 mb-3 d-flex align-items-center justify-content-center border" style="height: 100px;"><span class="fs-4 fw-bold text-primary">MED347</span></div>
                        <h3 class="font-heading fw-bold text-dark fs-6 mb-2">Med347 Clinic</h3>
                        <span class="badge bg-primary-light text-primary mx-auto mb-2 text-xs"><?php esc_html_e( 'Đối tác Trong nước', 'theme-anphat' ); ?></span>
                    </div>
                </div>
            <?php endif; ?>
        </div>
    </div>
</main>

<?php get_footer(); ?>
