<template>
  <div class="admin-klinik-ruang-index">
    <PageHeader
      icon="mdi-door-open"
      title="Admin Klinik Ruang"
      subtitle="Pilih Klinik untuk mengelola antrian ruang"
      :show-add-button="false"
      theme="warning"
    />

    <v-row class="mt-4">
      <v-col
        v-for="klinikRuang in klinikRuangList"
        :key="klinikRuang.id"
        cols="12"
        sm="6"
        md="4"
        lg="3"
      >
        <v-card
          class="klinik-card"
          elevation="2"
          @click="navigateToKlinik(klinikRuang.kodeKlinik)"
        >
          <v-card-text class="text-center pa-6">
            <v-icon size="64" color="warning" class="mb-4">mdi-hospital-building</v-icon>
            <div class="klinik-name">{{ klinikRuang.namaKlinik }}</div>
            <v-chip size="small" color="warning" class="mt-2">
              {{ klinikRuang.kodeKlinik }}
            </v-chip>
            <div class="ruang-count mt-3">
              <v-icon size="16" class="mr-1">mdi-door</v-icon>
              {{ klinikRuang.ruangList.length }} Ruang
            </div>
          </v-card-text>
        </v-card>
      </v-col>
    </v-row>

    <div v-if="klinikRuangList.length === 0" class="empty-state">
      <v-icon size="64" color="grey-lighten-2">mdi-hospital-building-outline</v-icon>
      <div class="empty-text">Tidak ada klinik ruang yang tersedia</div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useRouter } from 'vue-router';
import { useMasterStore } from '@/stores/masterStore';
import PageHeader from '@/components/common/PageHeader.vue';

const router = useRouter();
const masterStore = useMasterStore();

const klinikRuangList = computed(() => {
  return masterStore.ruangData || [];
});

const navigateToKlinik = (kodeKlinik) => {
  router.push(`/adminklinikruang/${kodeKlinik}`);
};
</script>

<style scoped lang="scss">
.admin-klinik-ruang-index {
  background: var(--color-neutral-300);
  min-height: 100vh;
  padding: 16px;
}

.klinik-card {
  border-radius: 12px;
  border: 1px solid var(--color-neutral-500);
  background: var(--color-neutral-100);
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    border-color: var(--color-warning-600);
  }
}

.klinik-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-neutral-900);
  margin-bottom: 8px;
}

.ruang-count {
  font-size: 13px;
  color: var(--color-neutral-700);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state {
  text-align: center;
  padding: 64px 16px;
}

.empty-text {
  font-size: 16px;
  color: var(--color-neutral-600);
  margin-top: 16px;
}
</style>

