

<?php $__env->startSection('title', 'Sohbet Odaları'); ?>

<?php $__env->startSection('content'); ?>
<?php
    $totalRooms = $chatCategories->sum(fn($cat) => $cat->rooms->count()) + $uncategorizedRooms->count();
    $totalMessages = \App\Models\ChatMessage::count();
?>

<style>
/* ═══════════════════════════════════════════════
   CHAT INDEX — Modern Design
   ═══════════════════════════════════════════════ */
:root {
    --chat-primary:      #667eea;
    --chat-primary-dark: #5a67d8;
    --chat-secondary:    #764ba2;
    --chat-text:         #111827;
    --chat-text-muted:   #6b7280;
    --chat-border:       #e5e7eb;
    --chat-bg:           #f9fafb;
    --chat-card-bg:      #ffffff;
    --chat-radius-sm:    8px;
    --chat-radius-md:    12px;
    --chat-radius-lg:    16px;
    --chat-shadow-sm:    0 1px 3px rgba(0,0,0,0.07);
    --chat-shadow-md:    0 4px 12px rgba(0,0,0,0.1);
    --chat-shadow-lg:    0 12px 28px rgba(0,0,0,0.13);
    --chat-transition:   all 0.25s ease;
}

/* ── Hero ─────────────────────────────────────── */
.chat-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--chat-radius-lg);
    padding: 32px;
    color: white;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}
.chat-hero::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    pointer-events: none;
}
.chat-hero-inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.chat-hero-left h1 {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 6px;
    letter-spacing: -0.5px;
}
.chat-hero-left p {
    margin: 0 0 20px;
    opacity: 0.85;
    font-size: 14px;
}
.chat-hero-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.chat-stat-pill {
    background: rgba(255,255,255,0.15);
    border-radius: var(--chat-radius-sm);
    padding: 10px 20px;
    text-align: center;
}
.chat-stat-pill .num {
    font-size: 20px;
    font-weight: 800;
    display: block;
    line-height: 1;
}
.chat-stat-pill .lbl {
    font-size: 11px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-top: 3px;
}
.chat-hero-actions {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.chat-admin-btn {
    background: white;
    color: #764ba2;
    padding: 9px 18px;
    border-radius: var(--chat-radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    transition: var(--chat-transition);
}
.chat-admin-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.chat-manage-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 9px 18px;
    border-radius: var(--chat-radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--chat-transition);
}
.chat-manage-btn:hover { background: rgba(255,255,255,0.3); }

/* ── Alert ────────────────────────────────────── */
.chat-alert-success {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
    padding: 12px 16px;
    border-radius: var(--chat-radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}

/* ── Category Group ───────────────────────────── */
.chat-group {
    margin-bottom: 32px;
}
.chat-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
}
.chat-group-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.chat-group-info h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    color: var(--chat-text);
}
.chat-group-info p {
    color: #9ca3af;
    margin: 0;
    font-size: 12px;
}
.chat-group-badge {
    margin-left: auto;
    font-size: 12px;
    color: var(--chat-text-muted);
    background: #f3f4f6;
    padding: 3px 12px;
    border-radius: 20px;
}
.chat-rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

/* ── Room Card ────────────────────────────────── */
.chat-room-card {
    text-decoration: none;
    display: block;
    background: var(--chat-card-bg);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-md);
    overflow: hidden;
    box-shadow: var(--chat-shadow-sm);
    transition: var(--chat-transition);
    color: inherit;
}
.chat-room-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--chat-shadow-lg);
    border-color: rgba(102, 126, 234, 0.4);
}
.chat-room-banner {
    padding: 20px 18px;
}
.chat-room-banner-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
    line-height: 1;
}
.chat-room-banner-name {
    font-size: 16px;
    font-weight: 700;
    color: white;
    margin-bottom: 3px;
}
.chat-room-banner-count {
    font-size: 12px;
    color: rgba(255,255,255,0.75);
}
.chat-room-body {
    padding: 12px 16px;
}
.chat-room-desc {
    color: var(--chat-text-muted);
    font-size: 13px;
    margin: 0 0 10px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chat-room-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-room-cat-badge {
    font-size: 11px;
    color: var(--chat-text-muted);
    background: var(--chat-bg);
    border: 1px solid #f3f4f6;
    padding: 2px 8px;
    border-radius: 5px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-room-join {
    font-size: 13px;
    font-weight: 700;
}

/* ── Empty State ──────────────────────────────── */
.chat-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--chat-card-bg);
    border-radius: var(--chat-radius-md);
    border: 1px solid var(--chat-border);
}
.chat-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}
.chat-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--chat-text);
    margin-bottom: 6px;
}
.chat-empty-desc {
    font-size: 14px;
    color: var(--chat-text-muted);
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
    .chat-hero { padding: 24px 20px; }
    .chat-hero-inner { flex-direction: column; }
    .chat-hero-left h1 { font-size: 22px; }
    .chat-hero-stats { flex-wrap: wrap; }
    .chat-rooms-grid { grid-template-columns: 1fr; }
}
</style>


<div class="chat-hero">
    <div class="chat-hero-inner">
        <div class="chat-hero-left">
            <h1>💬 Sohbet Odaları</h1>
            <p>Askeri kariyer hakkında gerçek zamanlı sohbet edin</p>
            <div class="chat-hero-stats">
                <div class="chat-stat-pill">
                    <span class="num"><?php echo e($totalRooms); ?></span>
                    <span class="lbl">Aktif Oda</span>
                </div>
                <div class="chat-stat-pill">
                    <span class="num"><?php echo e(number_format($totalMessages)); ?></span>
                    <span class="lbl">Toplam Mesaj</span>
                </div>
                <div class="chat-stat-pill">
                    <span class="num"><?php echo e($chatCategories->count()); ?></span>
                    <span class="lbl">Kategori</span>
                </div>
            </div>
        </div>
        <?php if(auth()->check() && auth()->user()->isAdmin()): ?>
        <div class="chat-hero-actions">
            <a href="<?php echo e(route('admin.chat-rooms.create')); ?>" class="chat-admin-btn">+ Yeni Oda</a>
            <a href="<?php echo e(route('admin.chat-rooms.index')); ?>" class="chat-manage-btn">⚙️ Yönet</a>
        </div>
        <?php endif; ?>
    </div>
</div>

<?php if(session('success')): ?>
<div class="chat-alert-success">✅ <?php echo e(session('success')); ?></div>
<?php endif; ?>


<?php $__currentLoopData = $chatCategories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    <?php if($category->rooms->count() > 0): ?>
    <div class="chat-group">
        <div class="chat-group-header">
            <div class="chat-group-icon" style="background: <?php echo e($category->color ?? '#3b82f6'); ?>;">
                <?php echo e($category->icon ?? '💬'); ?>

            </div>
            <div class="chat-group-info">
                <h2><?php echo e($category->name); ?></h2>
                <?php if($category->description): ?>
                <p><?php echo e($category->description); ?></p>
                <?php endif; ?>
            </div>
            <span class="chat-group-badge"><?php echo e($category->rooms->count()); ?> oda</span>
        </div>
        <div class="chat-rooms-grid">
            <?php $__currentLoopData = $category->rooms; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $room): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <a href="<?php echo e(route('chat.show', $room)); ?>" class="chat-room-card">
                <div class="chat-room-banner" style="background: <?php echo e($category->color ?? '#1d4ed8'); ?>;">
                    <span class="chat-room-banner-icon"><?php echo e($category->icon ?? '💬'); ?></span>
                    <div class="chat-room-banner-name"><?php echo e($room->name); ?></div>
                    <div class="chat-room-banner-count"><?php echo e(number_format($room->messages_count)); ?> mesaj</div>
                </div>
                <div class="chat-room-body">
                    <?php if($room->description): ?>
                    <p class="chat-room-desc"><?php echo e($room->description); ?></p>
                    <?php endif; ?>
                    <div class="chat-room-footer">
                        <span class="chat-room-cat-badge"><?php echo e($category->icon ?? '💬'); ?> <?php echo e($category->name); ?></span>
                        <span class="chat-room-join" style="color: <?php echo e($category->color ?? '#1d4ed8'); ?>;">Katıl →</span>
                    </div>
                </div>
            </a>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
    </div>
    <?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


<?php if($uncategorizedRooms->count() > 0): ?>
<div class="chat-group">
    <div class="chat-group-header">
        <div class="chat-group-icon" style="background: #9ca3af;">💬</div>
        <div class="chat-group-info">
            <h2>Diğer Odalar</h2>
        </div>
        <span class="chat-group-badge"><?php echo e($uncategorizedRooms->count()); ?> oda</span>
    </div>
    <div class="chat-rooms-grid">
        <?php $__currentLoopData = $uncategorizedRooms; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $room): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <a href="<?php echo e(route('chat.show', $room)); ?>" class="chat-room-card">
            <div class="chat-room-banner" style="background: linear-gradient(135deg, #6b7280, #4b5563);">
                <span class="chat-room-banner-icon">💬</span>
                <div class="chat-room-banner-name"><?php echo e($room->name); ?></div>
                <div class="chat-room-banner-count"><?php echo e(number_format($room->messages_count)); ?> mesaj</div>
            </div>
            <div class="chat-room-body">
                <?php if($room->description): ?>
                <p class="chat-room-desc"><?php echo e($room->description); ?></p>
                <?php endif; ?>
                <div class="chat-room-footer">
                    <span class="chat-room-cat-badge">Diğer</span>
                    <span class="chat-room-join" style="color: #6b7280;">Katıl →</span>
                </div>
            </div>
        </a>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
</div>
<?php endif; ?>

<?php if($totalRooms === 0): ?>
<div class="chat-empty">
    <span class="chat-empty-icon">💬</span>
    <div class="chat-empty-title">Henüz sohbet odası yok</div>
    <div class="chat-empty-desc">Yakında yeni odalar eklenecek.</div>
</div>
<?php endif; ?>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.public', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\askeribilgiler\resources\views\chat\index.blade.php ENDPATH**/ ?>