<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ $title ?? 'AKRSera MLM' }}</title>
    <style>
        :root {
            --primary: #16A34A;
            --secondary: #2563EB;
            --accent: #F59E0B;
            --danger: #EF4444;
            --bg: #F8FAFC;
            --text: #0f172a;
            --muted: #64748b;
            --card: #ffffff;
            --border: #e2e8f0;
        }
        body { margin: 0; font-family: "Segoe UI", Tahoma, sans-serif; background: var(--bg); color: var(--text); }
        .shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
        .sidebar { background: #0f172a; color: #cbd5e1; padding: 20px; }
        .brand { color: #fff; font-weight: 700; margin-bottom: 18px; }
        .sidebar a { display: block; color: #cbd5e1; text-decoration: none; padding: 10px; border-radius: 10px; margin-bottom: 6px; }
        .sidebar a:hover { background: rgba(148,163,184,0.2); }
        .main { padding: 20px; }
        .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
        .grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
        .card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 14px; box-shadow: 0 10px 30px rgba(15,23,42,0.06); }
        .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
        .muted { color: var(--muted); font-size: 13px; }
        .btn { border: 0; border-radius: 10px; padding: 10px 12px; text-decoration: none; color: #fff; background: var(--primary); }
        @media (max-width: 1024px) { .grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .shell { grid-template-columns: 1fr; } .sidebar { display: none; } }
        @media (max-width: 600px) { .grid { grid-template-columns: 1fr; } .main { padding: 12px; } }
    </style>
</head>
<body>
    <div class="shell">
        <aside class="sidebar">
            <div class="brand">AKRSera MLM</div>
            <a href="{{ route('home') }}">Website</a>
            @if(auth()->check() && auth()->user()->role === 'admin')
                <a href="{{ route('admin.dashboard') }}">Admin Dashboard</a>
            @endif
            @if(auth()->check() && auth()->user()->role === 'user')
                <a href="{{ route('user.dashboard') }}">User Dashboard</a>
            @endif
            @if(auth()->check() && auth()->user()->role === 'franchise')
                <a href="{{ route('franchise.dashboard') }}">Franchise Dashboard</a>
            @endif
            @if(auth()->check())
                <form method="post" action="{{ route('auth.logout') }}">
                    @csrf
                    <button type="submit" class="btn" style="margin-top:10px;width:100%;">Logout</button>
                </form>
            @endif
        </aside>
        <main class="main">
            <div class="top">
                <div>
                    <h1 style="margin:0;">{{ $heading ?? 'Dashboard' }}</h1>
                    <div class="muted">{{ $subheading ?? 'AKRSera MLM Control Center' }}</div>
                </div>
            </div>
            @if(session('status'))
                <div class="card" style="margin-bottom:14px;border-color:#86efac;background:#f0fdf4;">
                    {{ session('status') }}
                </div>
            @endif
            @yield('content')
            @include('partials.made-by-footer')
        </main>
    </div>
</body>
</html>
