<!DOCTYPE html>
<html lang="fa" dir="rtl">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>چت دو نفره</title>

    <style>
        * {
            box-sizing: border-box;
            font-family: sans-serif;
        }

        body {
            margin: 0;
            height: 100vh;
            width: 100vw;
            background-color: #e5ddd5;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .chat-box {
            width: 100%;
            max-width: 500px;
            height: 100vh;
            background-color: #f7f7f7;
            display: flex;
            flex-direction: column;
            border-left: 1px solid #ddd;
            border-right: 1px solid #ddd;
        }

        .chat-header {
            height: 60px;
            background-color: #075e54;
            color: white;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 15px;
        }

        .header-info {
            display: flex;
            flex-direction: column;
            gap: 3px;
        }

        .header-title {
            font-size: 17px;
            font-weight: bold;
        }

        .header-user {
            font-size: 12px;
            font-weight: normal;
            opacity: 0.9;
        }

        .clear-btn {
            text-decoration: none;
            width: auto;
            height: 36px;
            padding: 0 14px;
            border-radius: 18px;
            background-color: #d32f2f;
            color: white;
            font-size: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .clear-btn:hover {
            background-color: #b71c1c;
        }

        .messages {
            flex: 1;
            padding: 15px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 10px;
            background-color: #efe7dd;
        }

        .message {
            max-width: 75%;
            padding: 10px 14px;
            border-radius: 12px;
            font-size: 14px;
            line-height: 1.7;
            word-break: break-word;
        }

        .me {
            align-self: flex-end;
            background-color: #dcf8c6;
            border-bottom-right-radius: 0;
        }

        .other {
            align-self: flex-start;
            background-color: white;
            border-bottom-left-radius: 0;
        }

        .sender-name {
            display: block;
            font-size: 11px;
            color: #555;
            margin-bottom: 4px;
        }

        .empty-message {
            color: #777;
            text-align: center;
            font-size: 14px;
            margin-top: 20px;
        }

        .form {
            height: 60px;
            background-color: #f0f0f0;
            padding: 8px;
            display: flex;
            align-items: center;
        }

        .form form {
            width: 100%;
            display: flex;
            gap: 8px;
        }

        .msg-input {
            flex: 1;
        }

        .msg-input input {
            width: 100%;
            height: 44px;
            border: none;
            outline: none;
            border-radius: 22px;
            padding: 0 15px;
            font-size: 15px;
            background-color: white;
        }

        button {
            width: 70px;
            height: 44px;
            border: none;
            border-radius: 22px;
            background-color: #075e54;
            color: white;
            font-size: 15px;
            cursor: pointer;
        }

        button:hover {
            background-color: #064b43;
        }
    </style>
</head>

<body>

    <div class="chat-box">

        <div class="chat-header">
            <div class="header-info">
                <span class="header-title">چت دو نفره</span>
                <span class="header-user">
                    شما: کاربر <?php echo e($user); ?>

                </span>
            </div>

            <a href="/clear" class="clear-btn">پاک کردن</a>
        </div>

        <div class="messages">
            <?php
            $messages = cache()->get('msgs', []);

            if (!is_array($messages)) {
            $messages = [];
            }
            ?>

            <?php if(count($messages) == 0): ?>
            <div class="empty-message">
                هنوز پیامی ارسال نشده است.
            </div>
            <?php endif; ?>

            <?php $__currentLoopData = $messages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <?php if(is_array($message) && isset($message['sender']) && isset($message['text'])): ?>
            <div class="message <?php echo e($message['sender'] == $user ? 'me' : 'other'); ?>">
                <span class="sender-name">
                    کاربر <?php echo e($message['sender']); ?>

                </span>

                <?php echo e($message['text']); ?>

            </div>
            <?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>

        <div class="form">
            <form action="/ch" method="POST">
                <?php echo csrf_field(); ?>

                <div class="msg-input">
                    <input
                        type="text"
                        name="msg"
                        placeholder="پیام خود را بنویسید..."
                        autocomplete="off">
                </div>

                <button type="submit">ارسال</button>
            </form>
        </div>

    </div>

</body>

</html><?php /**PATH C:\Users\Arminn\Desktop\aydi\aydi\resources\views/ch.blade.php ENDPATH**/ ?>