<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>@yield('title', __('vetPortal::lang.pet_portal')) · {{ optional($portalSettings ?? null)->clinic_name ?: 'Pet Portal' }}</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        :root { --pc: {{ optional($portalSettings ?? null)->primary_color ?: '#2563eb' }}; }
        * { box-sizing: border-box; margin: 0; padding: 0; }
        body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: #f1f5f9; color: #1e293b; }
        a { color: var(--pc); text-decoration: none; }
        .vp-header { background: var(--pc); color: #fff; }
        .vp-header-in { max-width: 960px; margin: 0 auto; padding: 12px 16px;
            display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
        .vp-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; }
        .vp-brand img { height: 34px; border-radius: 6px; background: #fff; }
        .vp-logout { background: rgba(255,255,255,.18); color: #fff; border: none; padding: 6px 12px;
            border-radius: 7px; font-size: 12px; cursor: pointer; }
        .vp-nav { background: #fff; border-bottom: 1px solid #e2e8f0; }
        .vp-nav-in { max-width: 960px; margin: 0 auto; display: flex; gap: 4px; padding: 0 8px; overflow-x: auto; }
        .vp-nav a { padding: 12px 14px; font-size: 13px; font-weight: 600; color: #475569;
            border-bottom: 3px solid transparent; white-space: nowrap; }
        .vp-nav a.active { color: var(--pc); border-bottom-color: var(--pc); }
        .vp-container { max-width: 960px; margin: 18px auto; padding: 0 16px 40px; }
        .vp-card { background: #fff; border: 1px solid #e5e9f0; border-radius: 12px; margin-bottom: 16px; }
        .vp-card-h { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; font-weight: 700; }
        .vp-card-b { padding: 14px 16px; }
        .vp-page-title { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
        .vp-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
        .vp-pet { background: #fff; border: 1px solid #e5e9f0; border-radius: 12px; padding: 14px;
            display: block; color: #1e293b; }
        .vp-pet:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
        .vp-pet .nm { font-weight: 800; font-size: 15px; }
        .vp-pet .sub { font-size: 12px; color: #64748b; }
        .vp-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px;
            border-radius: 20px; }
        .vp-b-green { background: #dcfce7; color: #15803d; }
        .vp-b-amber { background: #fef3c7; color: #92400e; }
        .vp-b-red   { background: #fee2e2; color: #b91c1c; }
        .vp-b-blue  { background: #dbeafe; color: #1d4ed8; }
        .vp-b-gray  { background: #f1f5f9; color: #475569; }
        .vp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
        .vp-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
            color: #94a3b8; padding: 8px 10px; border-bottom: 2px solid #eef2f7; }
        .vp-table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; }
        .vp-btn { display: inline-block; background: var(--pc); color: #fff; padding: 9px 15px;
            border-radius: 8px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; }
        .vp-btn-wa { background: #25d366; }
        .vp-empty { text-align: center; color: #94a3b8; padding: 26px 10px; font-size: 13px; }
        .vp-stat-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); margin-bottom: 16px; }
        .vp-stat { background: #fff; border: 1px solid #e5e9f0; border-radius: 12px; padding: 14px 16px; }
        .vp-stat .n { font-size: 26px; font-weight: 800; }
        .vp-stat .l { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: .5px; }
        .vp-footer { text-align: center; font-size: 11px; color: #94a3b8; padding: 16px; }
    </style>
</head>
<body>
    <div class="vp-header">
        <div class="vp-header-in">
            <div class="vp-brand">
                @if(optional($portalSettings ?? null)->logo_path)
                    <img src="{{ asset('uploads/' . $portalSettings->logo_path) }}" alt="logo">
                @else
                    <i class="fas fa-paw"></i>
                @endif
                <span>{{ optional($portalSettings ?? null)->clinic_name ?: __('vetPortal::lang.pet_portal') }}</span>
            </div>
            @if($portalAccount ?? null)
            <form method="POST" action="{{ route('vp.portal.logout') }}">
                @csrf
                <span style="font-size:12px;margin-right:8px;opacity:.9;">{{ $portalAccount->name }}</span>
                <button class="vp-logout"><i class="fas fa-sign-out-alt"></i> {{ __('vetPortal::lang.logout') }}</button>
            </form>
            @endif
        </div>
    </div>

    @if($portalAccount ?? null)
    <div class="vp-nav">
        <div class="vp-nav-in">
            <a href="{{ route('vp.portal.dashboard') }}" class="{{ request()->routeIs('vp.portal.dashboard') ? 'active' : '' }}">
                <i class="fas fa-home"></i> {{ __('vetPortal::lang.dashboard') }}</a>
            <a href="{{ route('vp.portal.pets') }}" class="{{ request()->routeIs('vp.portal.pet*') ? 'active' : '' }}">
                <i class="fas fa-paw"></i> {{ __('vetPortal::lang.my_pets') }}</a>
            <a href="{{ route('vp.portal.appointments') }}" class="{{ request()->routeIs('vp.portal.appointments') ? 'active' : '' }}">
                <i class="fas fa-calendar"></i> {{ __('vetPortal::lang.appointments') }}</a>
        </div>
    </div>
    @endif

    <div class="vp-container">
        @if(session('status'))
            <div class="vp-card" style="border-left:4px solid #22c55e;">
                <div class="vp-card-b" style="color:#15803d;font-size:13px;">{{ is_array(session('status')) ? (session('status')['msg'] ?? '') : session('status') }}</div>
            </div>
        @endif
        @yield('content')
    </div>

    <div class="vp-footer">
        {{ optional($portalSettings ?? null)->clinic_name ?: 'Pet Owner Portal' }} · powered by Vet Clinic
        <div style="font-size:10px;margin-top:3px;color:#cbd5e1;">
            <strong>TPS</strong> &mdash; owner of the medical system &copy; {{ now()->year }}.
        </div>
    </div>
</body>
</html>
