/* ==========================================
   فایل: assets/css/chat.css
   استایل‌های چت تورنمنت - نسخه نهایی
   ========================================== */

/* ═══════════════════════════════
   متغیرها
   ═══════════════════════════════ */

:root {
    --chat-bg: #f1f5f9;
    --chat-card: #ffffff;
    --chat-text: #1e293b;
    --chat-muted: #64748b;
    --chat-border: #e2e8f0;
    --chat-primary: #7c3aed;
    --chat-primary-light: #a78bfa;
    --chat-danger: #ef4444;
    --chat-success: #10b981;
    --chat-warning: #f59e0b;
    --chat-hover: #f8fafc;
    --chat-own-bg: #7c3aed;
    --chat-other-bg: #f1f5f9;
}

.dark-theme {
    --chat-bg: #0f172a;
    --chat-card: #1e293b;
    --chat-text: #e2e8f0;
    --chat-muted: #94a3b8;
    --chat-border: #334155;
    --chat-hover: #263142;
    --chat-other-bg: #334155;
}

/* ═══════════════════════════════
   کانتینر اصلی
   ═══════════════════════════════ */

.tournament-chat-section {
    margin-top: 20px;
}

.chat-card {
    background: var(--chat-card);
    border-radius: 15px;
    border: 1px solid var(--chat-border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px;
}

/* ═══════════════════════════════
   هدر چت
   ═══════════════════════════════ */

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
    flex-shrink: 0;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-icon {
    font-size: 1.5rem;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.chat-tabs {
    display: flex;
    gap: 5px;
}

.chat-tab {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s;
    font-family: inherit;
}

.chat-tab:hover {
    background: rgba(255,255,255,0.25);
}

.chat-tab.active {
    background: #fff;
    color: #7c3aed;
}

/* ═══════════════════════════════
   بدنه چت (پیام‌ها)
   ═══════════════════════════════ */

.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* اسکرول‌بار سفارشی */
.chat-messages-container::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--chat-muted);
}

.chat-loading {
    text-align: center;
    color: var(--chat-muted);
    padding: 30px;
    font-size: 0.9rem;
}

.no-messages {
    text-align: center;
    color: var(--chat-muted);
    padding: 30px;
    font-size: 0.9rem;
}

/* ═══════════════════════════════
   پیام‌ها
   ═══════════════════════════════ */

.chat-message {
    display: flex;
    gap: 10px;
    max-width: 75%;
    animation: messageIn 0.3s ease;
    position: relative;
}

@keyframes messageIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.chat-message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-size: 1rem;
    color: #6366f1;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-avatar i {
    font-size: 1.1rem;
}

.message-body {
    background: var(--chat-other-bg);
    padding: 10px 15px;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chat-message.own .message-body {
    background: var(--chat-own-bg);
    color: #fff;
}

.message-info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.message-name {
    font-weight: 700;
    color: #3b82f6;
    font-size: 0.8rem;
}

.chat-message.own .message-name {
    color: #fbbf24;
}

.captain-badge {
    font-size: 0.75rem;
}

.message-time {
    font-size: 0.65rem;
    color: var(--chat-muted);
}

.chat-message.own .message-time {
    color: rgba(255,255,255,0.7);
}

.message-text {
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: break-word;
}

/* ═══════════════════════════════
   ریپلای
   ═══════════════════════════════ */

.message-reply {
    background: rgba(0,0,0,0.06);
    border-right: 3px solid var(--chat-primary);
    padding: 5px 10px;
    border-radius: 8px;
    margin-bottom: 5px;
    font-size: 0.75rem;
    color: var(--chat-muted);
}

.chat-message.own .message-reply {
    background: rgba(255,255,255,0.15);
    border-right-color: #fbbf24;
    color: rgba(255,255,255,0.8);
}

/* ═══════════════════════════════
   اکشن‌های پیام
   ═══════════════════════════════ */

.message-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s;
    position: absolute;
    top: -12px;
    left: 10px;
    z-index: 10;
}

.chat-message:hover .message-actions {
    opacity: 1;
}

.chat-message.own .message-actions {
    left: auto;
    right: 10px;
}

.message-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--chat-border);
    background: var(--chat-card);
    cursor: pointer;
    font-size: 0.65rem;
    color: var(--chat-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.message-action-btn:hover {
    background: var(--chat-primary);
    color: #fff;
    border-color: var(--chat-primary);
}

.message-action-btn.delete-btn:hover {
    background: var(--chat-danger);
    border-color: var(--chat-danger);
}

.message-action-btn.report-btn:hover {
    background: var(--chat-warning);
    border-color: var(--chat-warning);
}

/* ═══════════════════════════════
   فرم ارسال
   ═══════════════════════════════ */

.chat-input-area {
    padding: 12px 15px;
    background: var(--chat-card);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.reply-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--chat-hover);
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    font-size: 0.8rem;
    color: var(--chat-muted);
    border-right: 3px solid var(--chat-primary);
}

.reply-indicator button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--chat-muted);
    font-size: 0.9rem;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--chat-hover);
    border-radius: 25px;
    padding: 5px 10px;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    font-family: inherit;
    color: var(--chat-text);
    max-height: 100px;
    min-height: 35px;
}

.chat-input::placeholder {
    color: var(--chat-muted);
}

.chat-send-btn {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.3s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ═══════════════════════════════
   مودال‌ها
   ═══════════════════════════════ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--chat-card);
    border-radius: 15px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { 
        opacity: 0; 
        transform: scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--chat-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--chat-muted);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ═══════════════════════════════
   فرم‌های مودال
   ═══════════════════════════════ */

.report-reasons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.report-reason-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.report-reason-item:hover {
    background: var(--chat-hover);
    border-color: var(--chat-primary);
}

.report-reason-item input[type="radio"] {
    cursor: pointer;
}

.modal-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--chat-border);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--chat-bg);
    color: var(--chat-text);
    resize: vertical;
    min-height: 80px;
}

.modal-textarea:focus {
    outline: none;
    border-color: var(--chat-primary);
}

/* ═══════════════════════════════
   دکمه‌ها
   ═══════════════════════════════ */

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-secondary {
    background: var(--chat-hover);
    color: var(--chat-text);
    border: 1px solid var(--chat-border);
}

.btn-secondary:hover {
    background: var(--chat-border);
}

.btn-danger {
    background: var(--chat-danger);
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-primary {
    background: var(--chat-primary);
    color: #fff;
}

.btn-primary:hover {
    background: #6d28d9;
}

/* ═══════════════════════════════
   Toast
   ═══════════════════════════════ */

.chat-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 10px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10000;
    display: none;
    animation: toastIn 0.3s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

@keyframes toastIn {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.chat-toast.success { background: #10b981; }
.chat-toast.error { background: #ef4444; }
.chat-toast.info { background: #3b82f6; }

/* ═══════════════════════════════
   ریسپانسیو - موبایل
   ═══════════════════════════════ */

@media (max-width: 768px) {
    .chat-card {
        height: calc(100vh - 100px);
        border-radius: 10px;
    }
    
    .chat-header {
        padding: 10px;
        flex-direction: column;
        gap: 8px;
    }
    
    .chat-tabs {
        width: 100%;
        justify-content: center;
    }
    
    .chat-tab {
        font-size: 0.75rem;
        padding: 6px 12px;
    }
    
    .chat-message {
        max-width: 90%;
    }
    
    .chat-messages-container {
        padding: 12px;
    }
    
    .message-actions {
        opacity: 1;
        top: -8px;
    }
    
    .message-action-btn {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
    }
    
    .modal-content {
        width: 95%;
        max-width: 350px;
    }
}