<template>
  <div class="min-h-screen bg-gray-50">
    <header class="bg-white shadow">
      <div class="max-w-7xl mx-auto py-4 sm:py-6 px-4 sm:px-6 lg:px-8 flex justify-between items-center">
        <h1 class="text-lg sm:text-2xl font-bold text-gray-900 truncate">Informe - Caso {{ caso.numero_reclamo }}</h1>
        <div class="flex items-center gap-3 sm:gap-4 flex-shrink-0">
          <Link :href="route('portal.casos.ver', caso.id)" class="text-sm sm:text-base text-blue-600 hover:underline whitespace-nowrap">← Volver al Caso</Link>
          <form method="POST" :action="route('portal.logout')">
            <button type="submit" class="text-sm sm:text-base text-gray-600 hover:text-gray-900 whitespace-nowrap">Cerrar Sesión</button>
          </form>
        </div>
      </div>
    </header>

    <main class="max-w-4xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
      <div class="bg-white shadow rounded-lg p-4 sm:p-6">
        <div class="border-b border-gray-200 pb-4 mb-4">
          <h2 class="text-xl font-bold text-gray-900">Informe de Ajuste</h2>
          <p class="text-sm text-gray-500">Caso: {{ caso.numero_reclamo }}</p>
        </div>

        <div class="space-y-4">
          <div class="grid grid-cols-2 gap-4">
            <div>
              <span class="text-sm text-gray-500">Estado:</span>
              <p class="font-medium">{{ caso.estado_actual }}</p>
            </div>
            <div>
              <span class="text-sm text-gray-500">Cobertura:</span>
              <p class="font-medium">{{ caso.cobertura }}</p>
            </div>
            <div>
              <span class="text-sm text-gray-500">Tipo de Ajuste:</span>
              <p class="font-medium">{{ caso.tipo_ajuste || 'No especificado' }}</p>
            </div>
            <div>
              <span class="text-sm text-gray-500">Fecha Siniestro:</span>
              <p class="font-medium">{{ caso.fecha_siniestro }}</p>
            </div>
          </div>

          <div v-if="caso.link_informe" class="mt-6 p-4 bg-blue-50 rounded-lg">
            <p class="text-blue-800">
              <strong>Documento del informe:</strong> 
              <a :href="caso.link_informe" target="_blank" class="underline">Descargar Informe</a>
            </p>
          </div>

          <div v-if="caso.observaciones" class="mt-4">
            <span class="text-sm text-gray-500">Observaciones:</span>
            <p class="mt-1 text-gray-700">{{ caso.observaciones }}</p>
          </div>

          <div v-if="!caso.link_informe && !caso.observaciones" class="text-center py-12">
            <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
            </svg>
            <p class="mt-4 text-gray-500">El informe aún no está disponible.</p>
          </div>
        </div>
      </div>
    </main>
  </div>
</template>

<script setup>
import { Link } from '@inertiajs/vue3'

defineProps({
  title: String,
  caso: Object
})
</script>
