<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title', 'لوحة التحكم') - {{ config('app.name') }}</title>
    <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
    <link rel="stylesheet" href="{{ asset('css/sndian.css') }}">
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'Cairo', sans-serif; background: #f5f5f5; display: flex; min-height: 100vh; }
        .sidebar { width: 260px; background: #1a1a2e; color: #fff; padding: 20px; position: fixed; top: 0; right: 0; height: 100vh; overflow-y: auto; z-index: 100; }
        .sidebar .logo { font-size: 22px; font-weight: 700; color: #e53935; margin-bottom: 30px; text-align: center; }
        .sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 12px 15px; color: #ccc; text-decoration: none; border-radius: 8px; margin-bottom: 5px; transition: .3s; }
        .sidebar nav a:hover, .sidebar nav a.active { background: #e53935; color: #fff; }
        .sidebar nav a i { width: 20px; text-align: center; }
        .main-content { margin-right: 260px; flex: 1; padding: 30px; min-height: 100vh; }
        .page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; flex-wrap: wrap; gap: 15px; }
        .page-header h1 { font-size: 24px; color: #333; }
        .btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 14px; border: none; cursor: pointer; transition: .3s; font-family: 'Cairo', sans-serif; }
        .btn-primary { background: #e53935; color: #fff; }
        .btn-primary:hover { background: #c62828; }
        .btn-success { background: #2e7d32; color: #fff; }
        .btn-success:hover { background: #1b5e20; }
        .btn-warning { background: #f9a825; color: #333; }
        .btn-warning:hover { background: #f57f17; }
        .btn-danger { background: #d32f2f; color: #fff; }
        .btn-danger:hover { background: #b71c1c; }
        .btn-sm { padding: 6px 12px; font-size: 13px; }
        .card { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 20px; margin-bottom: 25px; }
        table { width: 100%; border-collapse: collapse; }
        table th, table td { padding: 12px 15px; text-align: right; border-bottom: 1px solid #eee; font-size: 14px; }
        table th { background: #fafafa; font-weight: 700; color: #555; }
        table tr:hover { background: #f9f9f9; }
        .actions { display: flex; gap: 6px; }
        .form-group { margin-bottom: 18px; }
        .form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #444; font-size: 14px; }
        .form-control { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; font-family: 'Cairo', sans-serif; transition: .3s; }
        .form-control:focus { border-color: #e53935; outline: none; box-shadow: 0 0 0 3px rgba(229,57,53,.15); }
        .form-control.error { border-color: #d32f2f; }
        .invalid-feedback { color: #d32f2f; font-size: 13px; margin-top: 4px; }
        .alert { padding: 12px 18px; border-radius: 6px; margin-bottom: 20px; font-size: 14px; }
        .alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
        .alert-danger { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
        .checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
        .checkbox-group label { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 14px; cursor: pointer; padding: 8px 12px; border: 1px solid #eee; border-radius: 6px; transition: .3s; }
        .checkbox-group label:hover { border-color: #e53935; }
        .checkbox-group input[type="checkbox"] { width: 16px; height: 16px; accent-color: #e53935; }
        .badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
        .badge-danger { background: #ffebee; color: #c62828; }
        .badge-success { background: #e8f5e9; color: #2e7d32; }
        .badge-info { background: #e3f2fd; color: #1565c0; }
        .badge-warning { background: #fff8e1; color: #f57f17; }
        .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
        .pagination { display: flex; justify-content: center; gap: 5px; margin-top: 20px; }
        .pagination a, .pagination span { padding: 8px 14px; border: 1px solid #ddd; border-radius: 6px; text-decoration: none; color: #555; font-size: 14px; }
        .pagination a:hover { background: #e53935; color: #fff; border-color: #e53935; }
        .pagination .active { background: #e53935; color: #fff; border-color: #e53935; }
        .topbar { display: flex; justify-content: flex-end; align-items: center; padding: 15px 0; margin-bottom: 20px; border-bottom: 1px solid #eee; }
        .topbar .user-info { display: flex; align-items: center; gap: 10px; }
        .topbar .user-info .name { font-weight: 600; color: #333; }
        .topbar .user-info a { color: #e53935; text-decoration: none; font-size: 14px; }
        .sidebar-section-title { color: #888; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 20px 0 10px 15px; }
        @media (max-width: 768px) {
            .sidebar { width: 200px; }
            .main-content { margin-right: 200px; }
            .grid-2 { grid-template-columns: 1fr; }
        }
    </style>
</head>
<body>
    <aside class="sidebar">
        <div class="logo">{{ config('app.name') }}</div>
        <nav>
            <div class="sidebar-section-title">الرئيسية</div>
            <a href="{{ route('dashboard.index') }}" class="{{ request()->routeIs('dashboard.*') ? 'active' : '' }}">
                <i class="fas fa-home"></i> لوحة التحكم
            </a>
            <div class="sidebar-section-title">الإدارة</div>
            <a href="{{ route('dashboard.users.index') }}" class="{{ request()->routeIs('dashboard.users.*') ? 'active' : '' }}">
                <i class="fas fa-users"></i> المستخدمين
            </a>
            <a href="{{ route('dashboard.roles.index') }}" class="{{ request()->routeIs('dashboard.roles.*') ? 'active' : '' }}">
                <i class="fas fa-shield-alt"></i> الأدوار
            </a>
            <a href="{{ route('dashboard.permissions.index') }}" class="{{ request()->routeIs('dashboard.permissions.*') ? 'active' : '' }}">
                <i class="fas fa-key"></i> الصلاحيات
            </a>
            <div class="sidebar-section-title">الموقع</div>
            <a href="{{ route('home') }}">
                <i class="fas fa-arrow-left"></i> العودة للموقع
            </a>
        </nav>
    </aside>

    <div class="main-content">
        <div class="topbar">
            <div class="user-info">
                <span class="name">{{ Auth::user()?->name }}</span>
                <a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                    <i class="fas fa-sign-out-alt"></i> تسجيل خروج
                </a>
                <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display:none;">@csrf</form>
            </div>
        </div>

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

        @yield('content')
    </div>
</body>
</html>
