<?php
declare(strict_types=1);
/**
 * 인증 페이지 공통 셸 — gov-portal 디자인.
 * 사용: 자식 뷰 상단에서 $this->extend('auth/_shell'),
 *      섹션 'heading'(카드 제목)·'content'(본문) 정의.
 * 선택 변수: $subtitle(카드 헤더 소제목), $cardMax(예: 'max-w-lg', 기본 'max-w-md')
 */
$cardMax  = $cardMax ?? 'max-w-md';
$subtitle = $subtitle ?? '종량제 쓰레기봉투 물류시스템';
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title><?= esc($pageTitle ?? 'GBLS') ?></title>
<script src="https://cdn.tailwindcss.com?plugins=forms,container-queries"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"/>
<script>
tailwind.config = {
  theme: {
    extend: {
      fontFamily: { sans: ['Pretendard', '"Malgun Gothic"', '"Noto Sans KR"', 'sans-serif'] },
      colors: {
        'navy': '#1a2b4b', 'title-bar': '#1a2b4b', 'portal-bg': '#f0f4f8',
        'btn-search': '#243a5e', 'btn-exit': '#d9534f',
      }
    }
  }
}
</script>
<style>body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; letter-spacing: -0.01em; }</style>
</head>
<script>
// iframe(워크스페이스 탭) 안에서 세션 만료로 로그인이 열리면 상위 창 전체를 로그인으로 전환
if (window.top !== window.self) { try { window.top.location.href = <?= json_encode(base_url('login'), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT) ?>; } catch (e) {} }
</script>
<body class="bg-portal-bg text-gray-700 flex flex-col min-h-screen font-sans antialiased">
<header class="bg-navy text-white h-12 flex items-center justify-between px-4 shrink-0 shadow">
  <a href="<?= base_url() ?>" class="flex items-center gap-2 shrink-0 tracking-tight hover:opacity-90" title="GBLS (Garbage Bag Logistics System)">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="h-6 w-6 text-white shrink-0" aria-hidden="true" focusable="false">
      <path fill="currentColor" d="M9 3a1 1 0 00-1 1v1H5.75a.75.75 0 000 1.5h12.5a.75.75 0 000-1.5H16V4a1 1 0 00-1-1H9zm9 4H6v11a2 2 0 002 2h8a2 2 0 002-2V7zM10 9a.75.75 0 01.75.75v6a.75.75 0 01-1.5 0v-6A.75.75 0 0110 9zm4 0a.75.75 0 01.75.75v6a.75.75 0 01-1.5 0v-6A.75.75 0 0114 9z"/>
    </svg>
    <span class="leading-none flex flex-col">
      <strong class="text-base font-extrabold tracking-wide">GBLS</strong>
      <span class="text-[0.56rem] font-medium text-white/65 tracking-tight whitespace-nowrap">Garbage Bag Logistics System</span>
    </span>
  </a>
</header>

<main class="flex-grow p-6 flex items-center justify-center">
  <section class="w-full <?= esc($cardMax) ?> bg-white border border-[#dde4ec] rounded-2xl shadow-[0_2px_12px_rgba(26,43,75,0.08)] overflow-hidden">
    <div class="bg-gradient-to-br from-navy to-[#007bff] text-white px-6 py-5">
      <p class="text-xs text-white/70"><?= esc($subtitle) ?></p>
      <h1 class="text-lg font-bold mt-0.5"><?= $this->renderSection('heading') ?></h1>
    </div>
    <div class="p-6">
      <?php if (session()->getFlashdata('error')): ?>
      <div class="mb-4 p-3 rounded-lg bg-red-50 text-red-700 text-sm" role="alert"><?= esc(session()->getFlashdata('error')) ?></div>
      <?php endif; ?>
      <?php if (session()->getFlashdata('errors')): ?>
      <div class="mb-4 p-3 rounded-lg bg-red-50 text-red-700 text-sm space-y-1" role="alert">
        <?php foreach (session()->getFlashdata('errors') as $error): ?><p><?= esc($error) ?></p><?php endforeach; ?>
      </div>
      <?php endif; ?>
      <?php if (session()->getFlashdata('success')): ?>
      <div class="mb-4 p-3 rounded-lg bg-green-50 text-green-700 text-sm" role="alert"><?= esc(session()->getFlashdata('success')) ?></div>
      <?php endif; ?>
      <?= $this->renderSection('content') ?>
    </div>
  </section>
</main>
<footer class="bg-[#eef2f7] border-t border-[#dde4ec] px-4 py-1.5 text-xs text-gray-500 shrink-0 text-center">종량제 물류시스템</footer>
</body>
</html>
