<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CMS - @yield('title')</title>
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #10b981;
            --primary-hover: #059669;
            --sidebar: #1e293b;
            --sidebar-hover: #334155;
            --bg: #f1f5f9;
            --surface: #ffffff;
            --text: #0f172a;
            --text-muted: #64748b;
            --border: #e2e8f0;
            --danger: #ef4444;
        }
        
        * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; }
        
        body { display: flex; min-height: 100vh; background: var(--bg); color: var(--text); }

        .sidebar {
            width: 250px;
            background: var(--sidebar);
            color: white;
            display: flex;
            flex-direction: column;
        }

        .sidebar-brand {
            padding: 1.5rem;
            font-size: 1.25rem;
            font-weight: 700;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            text-align: center;
            color: var(--primary);
        }

        .sidebar-menu {
            list-style: none;
            flex: 1;
            overflow-y: auto;
            padding: 1rem 0;
        }

        .sidebar-menu a {
            display: block;
            padding: 0.75rem 1.5rem;
            color: #cbd5e1;
            text-decoration: none;
            transition: 0.2s;
        }

        .sidebar-menu a:hover, .sidebar-menu a.active {
            background: var(--sidebar-hover);
            color: white;
            border-left: 4px solid var(--primary);
        }

        .license-badge {
            margin: 1rem;
            padding: 1rem;
            background: rgba(255,255,255,0.05);
            border-radius: 8px;
            font-size: 0.875rem;
            text-align: center;
        }
        .license-badge strong { color: var(--primary); display:block; margin-bottom: 0.25rem;}

        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .header {
            background: var(--surface);
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border);
        }

        .content {
            padding: 2rem;
            flex: 1;
        }
        
        /* Layout Grids & Cards */
        .card {
            background: var(--surface);
            border-radius: 8px;
            padding: 1.5rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            border: 1px solid var(--border);
        }
        
        .campaign-banner {
            background: var(--danger);
            color: white;
            padding: 0.75rem;
            text-align: center;
            font-weight: 600;
        }

        .btn {
            padding: 0.5rem 1rem;
            background: var(--primary);
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <aside class="sidebar">
        <div class="sidebar-brand">SanoDiji CMS</div>
        <ul class="sidebar-menu">
            <li><a href="{{ route('admin.dashboard') }}" class="active">Dashboard</a></li>
            
            @if(isset($license_plan['page_limit']))
            <li><a href="#">Sayfalar</a></li>
            @endif
            
            @if(isset($license_plan['has_blog']) && $license_plan['has_blog'])
            <li><a href="#">Blog</a></li>
            @endif
            
            @if(isset($license_plan['has_product']) && $license_plan['has_product'])
            <li><a href="#">Ürünler</a></li>
            @endif
            
            <li><a href="#">Slider</a></li>
            <li><a href="#">Anasayfa Builder</a></li>
            <li><a href="#">Temalar</a></li>
            <li><a href="#">Medya</a></li>
            <li><a href="#">Menüler</a></li>
            
            @if(isset($license_plan['has_newsletter']) && $license_plan['has_newsletter'])
            <li><a href="#">E-Bülten</a></li>
            @endif
            
            @if(isset($license_plan['has_contact_form']) && $license_plan['has_contact_form'])
            <li><a href="#">İletişim</a></li>
            @endif
            
            <li><a href="#">Kullanıcılar</a></li>
            <li><a href="#">Ayarlar</a></li>
        </ul>
        
        @if(isset($license_plan))
        <div class="license-badge">
            <strong>Plan: {{ $license_plan['name'] }}</strong>
            Bitiş: {{ \Carbon\Carbon::parse($license_end_date)->format('d.m.Y') }}
        </div>
        @endif
    </aside>

    <main class="main">
        <!-- Optional Campaign Banner -->
        @if(session('campaign'))
        <div class="campaign-banner">
            {{ session('campaign') }}
        </div>
        @endif

        <header class="header">
            <h2>@yield('title')</h2>
            <div>
                <form action="{{ route('logout') }}" method="POST" style="display:inline;">
                    @csrf
                    <button class="btn" style="background:transparent; color:var(--danger); border:1px solid var(--danger);">Çıkış Yap</button>
                </form>
            </div>
        </header>

        <div class="content">
            @yield('content')
        </div>
    </main>
</body>
</html>
