@extends('admin.layout')

@section('header-title', 'Menü Yönetimi')

@section('content')
<style>
    .menu-page-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 28px;
    }
    .menu-page-title {
        font-size: 24px;
        font-weight: 800;
        color: #1f2937;
    }
    .menu-page-subtitle {
        font-size: 14px;
        color: #6b7280;
        margin-top: 4px;
    }
    .menu-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 10px 18px;
        border: none;
        border-radius: 8px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        text-decoration: none;
        transition: all 0.2s;
    }
    .menu-btn-primary {
        background: #1e40af;
        color: white;
    }
    .menu-btn-primary:hover { background: #1e3a8a; color: white; }
    .menu-btn-warning {
        background: #d97706;
        color: white;
    }
    .menu-btn-warning:hover { background: #b45309; color: white; }
    .menu-btn-danger {
        background: #dc2626;
        color: white;
    }
    .menu-btn-danger:hover { background: #b91c1c; color: white; }
    .menu-btn-secondary {
        background: #e5e7eb;
        color: #1f2937;
    }
    .menu-btn-secondary:hover { background: #d1d5db; }
    .menu-btn-sm {
        padding: 6px 12px;
        font-size: 13px;
    }

    .menu-card {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08);
        margin-bottom: 20px;
    }
    .menu-card-header {
        background: #f9fafb;
        border-bottom: 1px solid #e5e7eb;
        padding: 16px 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .menu-card-title {
        font-size: 15px;
        font-weight: 700;
        color: #1f2937;
        margin: 0;
    }
    .menu-card-body {
        padding: 20px;
    }

    .menus-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
        gap: 20px;
    }

    .menu-grid-card {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
        transition: box-shadow 0.2s;
    }
    .menu-grid-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

    .menu-grid-card-header {
        padding: 20px;
        border-bottom: 1px solid #f3f4f6;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }
    .menu-card-name {
        font-size: 17px;
        font-weight: 700;
        color: #1f2937;
    }
    .menu-card-meta {
        font-size: 13px;
        color: #6b7280;
        margin-top: 4px;
    }

    .menu-badge {
        display: inline-block;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 600;
    }
    .menu-badge-active { background: #d1fae5; color: #065f46; }
    .menu-badge-inactive { background: #fee2e2; color: #991b1b; }
    .menu-badge-top { background: #dbeafe; color: #1e40af; }
    .menu-badge-footer { background: #f3e8ff; color: #6b21a8; }

    .menu-grid-card-body {
        padding: 16px 20px;
    }
    .menu-stat {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 14px;
        color: #374151;
    }

    .menu-grid-card-footer {
        padding: 14px 20px;
        background: #f9fafb;
        border-top: 1px solid #f3f4f6;
        display: flex;
        gap: 8px;
        justify-content: flex-end;
    }

    .menu-alert {
        padding: 12px 16px;
        border-radius: 8px;
        margin-bottom: 20px;
        font-size: 14px;
    }
    .menu-alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
    .menu-alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
</style>

<div class="menu-page-header">
    <div>
        <h1 class="menu-page-title">🗂️ Menü Yönetimi</h1>
        <p class="menu-page-subtitle">Üst menü, footer menü ve navigasyon öğelerini yönetin</p>
    </div>
    <a href="{{ route('admin.menus.create') }}" class="menu-btn menu-btn-primary">
        + Yeni Menü Oluştur
    </a>
</div>

@if(session('success'))
<div class="menu-alert menu-alert-success">✅ {{ session('success') }}</div>
@endif
@if(session('error'))
<div class="menu-alert menu-alert-error">❌ {{ session('error') }}</div>
@endif

@if($menus->isEmpty())
<div class="menu-card">
    <div class="menu-card-body" style="text-align:center; padding: 60px 20px; color: #6b7280;">
        <div style="font-size: 48px; margin-bottom: 16px;">📋</div>
        <h3 style="font-size:18px; font-weight:700; color:#374151; margin-bottom:8px;">Henüz menü oluşturulmadı</h3>
        <p style="margin-bottom:20px;">İlk menünüzü oluşturun ve navigasyon öğelerini yönetin.</p>
        <a href="{{ route('admin.menus.create') }}" class="menu-btn menu-btn-primary">+ Yeni Menü Oluştur</a>
    </div>
</div>
@else
<div class="menus-grid">
    @foreach($menus as $menu)
    <div class="menu-grid-card">
        <div class="menu-grid-card-header">
            <div>
                <div class="menu-card-name">{{ $menu->name }}</div>
                <div class="menu-card-meta">
                    <span class="menu-badge menu-badge-{{ $menu->location }}">
                        {{ $locations[$menu->location] ?? $menu->location }}
                    </span>
                </div>
            </div>
            <span class="menu-badge {{ $menu->is_active ? 'menu-badge-active' : 'menu-badge-inactive' }}">
                {{ $menu->is_active ? 'Aktif' : 'Pasif' }}
            </span>
        </div>

        <div class="menu-grid-card-body">
            <div class="menu-stat">
                📋 {{ $menu->all_items_count }} öğe
            </div>
            @if($menu->description)
            <div style="font-size:13px; color:#6b7280; margin-top:8px;">{{ $menu->description }}</div>
            @endif
        </div>

        <div class="menu-grid-card-footer">
            <a href="{{ route('admin.menus.edit', $menu) }}" class="menu-btn menu-btn-warning menu-btn-sm">
                ✏️ Düzenle
            </a>
            <form action="{{ route('admin.menus.destroy', $menu) }}" method="POST"
                  onsubmit="return confirm('Bu menüyü silmek istediğinizden emin misiniz?')">
                @csrf
                @method('DELETE')
                <button type="submit" class="menu-btn menu-btn-danger menu-btn-sm">🗑️</button>
            </form>
        </div>
    </div>
    @endforeach
</div>
@endif
@endsection
