<?php
include 'includes/db.php';
include 'includes/header.php';
?>

<?php
if (!isset($_GET['id'])) {
    echo "<p style='padding:20px;'>No service selected.</p>";
    include 'includes/footer.php';
    exit;
}

$id = intval($_GET['id']);
$result = $conn->query("SELECT * FROM services WHERE id=$id AND is_visible=1");

if ($result->num_rows == 0) {
    echo "<p style='padding:20px;'>Service not found.</p>";
    include 'includes/footer.php';
    exit;
}

$row = $result->fetch_assoc();
?>

<div class="service-details">
    <!-- Breadcrumb -->
    <div class="breadcrumb">
        <a href="index.php">Home</a>
        <span>&gt;</span>
        <a href="services.php">Services</a>
        <span>&gt;</span>
        <span><?= htmlspecialchars($row['test_name']) ?></span>
    </div>

    <!-- Back button -->
   
    <h1><?= htmlspecialchars($row['test_name']) ?></h1>
    <div class="service-info">
        <div class="item">
            <span class="label">Code</span>
            <span class="value"><?= htmlspecialchars($row['code']) ?></span>
        </div>
        <div class="item">
            <span class="label">Test Name</span>
            <span class="value"><?= htmlspecialchars($row['test_name']) ?></span>
        </div>
        <div class="item">
            <span class="label">Tube Container</span>
            <span class="value"><?= htmlspecialchars($row['tube_container']) ?></span>
        </div>
        <div class="item">
            <span class="label">Volume</span>
            <span class="value"><?= htmlspecialchars($row['volume']) ?></span>
        </div>
        <div class="item">
            <span class="label">Reporting Time</span>
            <span class="value"><?= htmlspecialchars($row['reporting_time']) ?></span>
        </div>
       <?php if ($row['is_price_visible'] == 1): ?>
<div class="item price">
    <span class="label">Price</span>
    <span class="value">AFN<?= htmlspecialchars($row['price']) ?></span>
</div>
<?php endif; ?>

        <div class="description">
            <span class="label">Description</span>
            <div class="value"><?= $row['description'] ?></div>
        </div>
        <div class="description">
            <span class="label">Preparation</span>
            <div class="value"><?= $row['preparation'] ?></div>
        </div>
    </div>
</div>

<?php include 'includes/footer.php'; ?>

<!-- Move CSS HERE, before content -->
<style>
/* ===== General Body & Section ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7fa;
    color: #333;
    margin: 0;
    padding: 0;
}

.service-details {
    max-width: 900px;
    margin: 60px auto;
    background: #ffffff;
    padding: 40px;
    border-radius: 14px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    font-family: "Segoe UI", sans-serif;
    transition: all 0.3s ease;
}

.service-details:hover {
    box-shadow: 0 12px 35px rgba(0,0,0,0.12);
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    font-size: 14px;
    margin-bottom: 20px;
    color: #555;
}

.breadcrumb a {
    color: #004aad;
    text-decoration: none;
    margin-right: 5px;
    transition: color 0.3s;
}

.breadcrumb a:hover {
    color: #002366;
}

.breadcrumb span {
    margin-right: 5px;
}

/* ===== Back Button ===== */
.back-btn {
    display: inline-block;
    margin-bottom: 25px;
    padding: 10px 18px;
    background: #25A9C2;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #003080;
    transform: translateY(-2px);
}

/* ===== Page Title ===== */
.service-details h1 {
    font-size: 2.2rem;
    color: #25A9C2;
    margin-bottom: 30px;
    border-bottom: 3px solid #25A9C2;
    padding-bottom: 12px;
    font-weight: 600;
}

/* ===== Info Grid ===== */
.service-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px 40px;
    margin-top: 20px;
}

.service-info .item {
    display: flex;
    flex-direction: column;
}

.service-info .label {
    font-weight: bold;
    color: #1a237e;
    font-size: 15px;
    margin-bottom: 6px;
}

.service-info .value {
    font-size: 15px;
    color: #333;
    background: #f8faff;
    border-radius: 8px;
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.service-info .value:hover {
    background: #e6f0ff;
    border-color: #b3d1ff;
}

/* ===== Description & Preparation Sections ===== */
.description {
    grid-column: span 2;
    margin-top: 30px;
}

.description .label {
    font-size: 16px;
    color: #1a237e;
    font-weight: 600;
    margin-bottom: 8px;
}

.description .value {
    font-size: 15px;
    color: #333;
    background: #f8faff;
    border-radius: 10px;
    padding: 18px;
    border: 1px solid #e0e0e0;
    white-space: pre-wrap;
    line-height: 1.6;
    transition: all 0.3s ease;
}

.description .value:hover {
    background: #e6f0ff;
    border-color: #b3d1ff;
}

/* ===== Price Highlight ===== */
.service-info .price {
    background: #fff4e5;
    border-color: #ffc107;
    color: #b35c00;
    font-weight: 600;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .service-details {
        padding: 30px 20px;
    }
    .service-info {
        grid-template-columns: 1fr;
        gap: 20px 0;
    }
}
</style>
