import { CommonModule } from '@angular/common';
import { Component, computed, inject } from '@angular/core';
import { RouterLink } from '@angular/router';
import { AuthService } from '../../core/services/auth.service';

@Component({
  selector: 'app-dashboard-page',
  standalone: true,
  imports: [CommonModule, RouterLink],
  template: `
    <section class="dashboard">
      <header class="hero card">
        <div>
          <p class="eyebrow">INNOVATECH SEMILLERO</p>
          <h1>Bienvenido, {{ fullName() }}</h1>
          <p class="subtitle">Contamos con estos modulos principales del sistema INVIMA.</p>
        </div>

        <div class="hero-brand">
          <img src="/assets/logo-learning.png" alt="Logo centro" />
          <strong>INNOVATECH SEMILLERO</strong>
        </div>
      </header>

      <section class="grid">
        <a class="module card" routerLink="/catalogo">
          <span class="icon">Q</span>
          <h3>Catalogo INVIMA</h3>
          <p>Busqueda rapida por texto, estado, categoria, modalidad y vigencia.</p>
        </a>

        <a class="module card" routerLink="/sincronizacion">
          <span class="icon">S</span>
          <h3>Sincronizacion</h3>
          <p>Actualiza datasets oficiales y reconstruye indices para respuestas mas veloces.</p>
        </a>

        <a class="module card" routerLink="/catalogo">
          <span class="icon">E</span>
          <h3>Exportacion</h3>
          <p>Descarga resultados filtrados en CSV o Excel para reportes y analisis.</p>
        </a>
      </section>
    </section>
  `,
  styles: `
    .dashboard {
      display: grid;
      gap: 18px;
    }

    .card {
      border-radius: 24px;
      border: 1px solid var(--color-border);
      background: var(--color-card-soft);
      box-shadow: var(--shadow-soft);
      backdrop-filter: blur(3px);
    }

    .hero {
      padding: 24px;
      display: flex;
      justify-content: space-between;
      gap: 16px;
      align-items: center;
      flex-wrap: wrap;
    }

    .eyebrow {
      margin: 0;
      color: var(--color-primary);
      font-family: var(--font-display);
      font-weight: 700;
      letter-spacing: 0.03em;
      font-size: 1.02rem;
    }

    h1 {
      margin: 8px 0 0;
      color: var(--color-primary);
      font-family: var(--font-display);
      font-weight: 800;
      font-size: clamp(2.2rem, 5vw, 3rem);
      line-height: 1.05;
    }

    .subtitle {
      margin: 10px 0 0;
      color: var(--color-muted);
      font-size: 1.04rem;
    }

    .hero-brand {
      border-radius: 20px;
      border: 1px solid var(--color-border);
      background: rgba(255, 255, 255, 0.45);
      padding: 14px 18px;
      display: inline-flex;
      align-items: center;
      gap: 12px;
      min-width: 280px;
      justify-content: flex-start;
    }

    .hero-brand img {
      width: 48px;
      height: 48px;
      object-fit: cover;
      border-radius: 12px;
      border: 1px solid #fff;
      background: #fff;
    }

    .hero-brand strong {
      color: #1d2536;
      font-size: 1.1rem;
      font-family: var(--font-display);
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
      gap: 14px;
    }

    .module {
      text-decoration: none;
      padding: 18px;
      color: var(--color-ink);
      transition: transform 0.16s ease, box-shadow 0.16s ease;
    }

    .module:hover {
      transform: translateY(-2px);
      box-shadow: 0 18px 32px rgba(32, 178, 170, 0.14);
    }

    .icon {
      width: 46px;
      height: 46px;
      border-radius: 13px;
      display: grid;
      place-items: center;
      background: rgba(255, 255, 255, 0.72);
      color: var(--color-primary);
      font-weight: 800;
      font-size: 1.3rem;
      margin-bottom: 12px;
    }

    .module h3 {
      margin: 0;
      color: var(--color-primary);
      font-family: var(--font-display);
      font-size: 1.42rem;
      line-height: 1.2;
    }

    .module p {
      margin: 9px 0 0;
      color: #4e617b;
      font-size: 0.98rem;
      line-height: 1.55;
    }
  `
})
export class DashboardPageComponent {
  private readonly auth = inject(AuthService);
  readonly fullName = computed(() => this.auth.user()?.fullName || 'Administrador');
}

