<script setup lang="ts">
import type { TourDay } from "@/types";
import { ref } from "vue";

interface Props {
    tourDays: TourDay[];
}

const currentStep = ref(1);
const props = defineProps<Props>();
</script>

<template>
    <div v-if="tourDays?.length" class="custom-stepper">
        <!-- Horizontal Stepper Header -->
        <div class="stepper-header">
            <button class="stepper-step">
                <span class="step-number">Summary</span>
            </button>
            <button
                v-for="(day, index) in tourDays"
                :key="day.id"
                class="stepper-step"
                :class="{
                    active: currentStep === index + 1,
                    complete: currentStep > index + 1
                }"
                @click="currentStep = index + 1"
            >
                <span class="step-number">Day {{ index + 1 }}</span>
            </button>
        </div>

        <!-- Stepper Content -->
        <div class="stepper-content">
            <div
                v-for="(day, index) in tourDays"
                :key="day.id"
                v-show="currentStep === index + 1"
                class="step-item"
            >
                <h2 class="text-h3 font-weight-bold mb-2">
                    Day {{ index + 1 }}
                </h2>
                <p class="text-h6 text-grey mb-6">
                    {{ day.description }}
                </p>

                <div v-if="day.image" class="mb-6">
                    <v-img
                        :src="day.image"
                        :alt="`Day ${index + 1}`"
                        class="rounded"
                        height="300"
                        cover
                    />
                </div>

                <div class="text-body1 line-height-relaxed mb-6">
                    {{ day.content }}
                </div>

                <div class="d-flex gap-3">
                    <v-btn
                        v-if="index > 0"
                        variant="outlined"
                        @click="currentStep = index"
                    >
                        Previous
                    </v-btn>
                    <v-btn
                        v-if="index < tourDays.length - 1"
                        color="primary"
                        @click="currentStep = index + 2"
                    >
                        Next
                    </v-btn>
                    <v-btn
                        v-else
                        color="success"
                        disabled
                    >
                        Tour Complete
                    </v-btn>
                </div>
            </div>
        </div>
    </div>
</template>

<style scoped>
.custom-stepper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stepper-header {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.stepper-step:hover {
    border-color: rgba(255, 255, 255, 0.6);
    color: rgba(255, 255, 255, 0.9);
}

.stepper-step.active {
    border-color: #1976d2;
    background-color: rgba(25, 118, 210, 0.1);
    color: #1976d2;
}

.stepper-step.complete {
    border-color: #4caf50;
    color: #4caf50;
}

.step-number {
    font-weight: bold;
    font-size: 1.2em;
}

.stepper-content {
    flex: 1;
    overflow-y: auto;
}

.step-item {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
</style>
