/* File: public_html/assets/css/chat.css */

/**
 * TaskChat - WhatsApp Web Exact Copy
 * نسخة مطابقة تماماً لواتساب ويب
 */

/* ===== ROOT VARIABLES ===== */
:root {
    /* WhatsApp Exact Colors */
    --wa-green: #00a884;
    --wa-green-dark: #008069;
    --wa-green-light: #d9fdd3;
    --wa-teal: #025d4b;
    
    /* Backgrounds */
    --wa-bg-main: #f0f2f5;
    --wa-bg-sidebar: #ffffff;
    --wa-bg-chat: #efeae2;
    --wa-bg-panel: #f8f9fa;
    --wa-bg-input: #ffffff;
    --wa-bg-message-out: #d9fdd3;
    --wa-bg-message-in: #ffffff;
    --wa-bg-hover: #f5f6f6;
    --wa-bg-selected: #e9edef;
    
    /* Text Colors */
    --wa-text-primary: #111b21;
    --wa-text-secondary: #667781;
    --wa-text-muted: #8696a0;
    --wa-text-white: #ffffff;
    
    /* Borders */
    --wa-border: #e9edef;
    --wa-border-light: #f0f2f5;
    
    /* Shadows */
    --wa-shadow-1: 0 1px 1px rgba(0,0,0,0.06), 0 2px 5px rgba(0,0,0,0.2);
    --wa-shadow-2: 0 1px 3px rgba(0,0,0,0.08);
    --wa-shadow-3: 0 4px 14px rgba(0,0,0,0.12);
    
    /* Fonts */
    --wa-font: "Segoe UI", "Helvetica Neue", Helvetica, "Lucida Grande", Arial, Ubuntu, Cantarell, "Fira Sans", sans-serif;
}

/* ===== RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--wa-font);
    background-color: var(--wa-bg-main);
    color: var(--wa-text-primary);
    overflow: hidden;
    direction: rtl;
}

/* ===== MAIN CONTAINER ===== */
.chat-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    background-color: var(--wa-bg-main);
    position: relative;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 320px;
    background-color: var(--wa-bg-sidebar);
    border-left: 1px solid var(--wa-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

/* Header */
.sidebar-header {
    background-color: var(--wa-bg-panel);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--wa-border);
    min-height: 59px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 13px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--wa-text-muted);
    color: var(--wa-text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
}

.user-name {
    font-size: 16px;
    font-weight: 400;
    color: var(--wa-text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s ease;
}

.icon-btn:hover {
    background-color: var(--wa-bg-hover);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* User Menu */
.user-menu-container {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--wa-bg-sidebar);
    border: 1px solid var(--wa-border);
    border-radius: 3px;
    box-shadow: var(--wa-shadow-3);
    min-width: 200px;
    z-index: 1000;
    display: none;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.15s ease;
}

.dropdown-menu.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.menu-item {
    display: block;
    padding: 12px 24px;
    color: var(--wa-text-primary);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: right;
    cursor: pointer;
    font-size: 14.2px;
    line-height: 1.3;
    transition: background-color 0.1s ease;
}

.menu-item:hover {
    background-color: var(--wa-bg-hover);
}

.menu-divider {
    height: 1px;
    background-color: var(--wa-border);
    margin: 5px 0;
}

/* Search */
.search-container {
    padding: 12px 12px 6px 12px;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: var(--wa-bg-panel);
    border-radius: 8px;
    padding: 8px 12px;
    gap: 12px;
    border: 1px solid transparent;
    transition: border-color 0.1s ease;
}

.search-box:focus-within {
    border-color: var(--wa-green);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--wa-text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 15px;
    color: var(--wa-text-primary);
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--wa-text-muted);
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--wa-text-muted) transparent;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background-color: var(--wa-text-muted);
    border-radius: 3px;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--wa-border-light);
    gap: 15px;
    transition: background-color 0.1s ease;
    position: relative;
}

.chat-item:hover {
    background-color: var(--wa-bg-hover);
}

.chat-item.active {
    background-color: var(--wa-bg-selected);
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--wa-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.group-icon {
    font-size: 20px;
}

.chat-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-header-line {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 2px;
}

.chat-name {
    font-size: 17px;
    font-weight: 400;
    color: var(--wa-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-badge {
    background-color: var(--wa-green-light);
    color: var(--wa-green-dark);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
}

.chat-time {
    font-size: 12px;
    color: var(--wa-text-muted);
    flex-shrink: 0;
    line-height: 1.3;
}

.chat-bottom-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-last-message {
    font-size: 14px;
    color: var(--wa-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    line-height: 1.3;
}

.no-messages {
    color: var(--wa-text-muted);
    font-style: italic;
}

.unread-badge {
    background-color: var(--wa-green);
    color: var(--wa-text-white);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
    line-height: 1.3;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--wa-text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 300;
    margin-bottom: 8px;
    color: var(--wa-text-primary);
}

.empty-state p {
    font-size: 14px;
    margin: 0;
    color: var(--wa-text-secondary);
}

/* ===== CHAT AREA ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--wa-bg-chat);
    position: relative;
    height: 100vh;
    overflow: hidden;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c6ddd1' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Chat Header */
.chat-header {
    background-color: var(--wa-bg-panel);
    border-bottom: 1px solid var(--wa-border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 59px;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 13px;
}

.chat-header .chat-avatar {
    width: 40px;
    height: 40px;
}

.chat-details {
    display: flex;
    flex-direction: column;
}

.chat-title {
    font-size: 16px;
    font-weight: 400;
    color: var(--wa-text-primary);
    margin: 0;
    line-height: 1.3;
}

.chat-subtitle {
    font-size: 13px;
    color: var(--wa-text-secondary);
    margin: 0;
    line-height: 1.3;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--wa-text-muted) transparent;
    position: relative;
}

.messages-area::-webkit-scrollbar {
    width: 6px;
}

.messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
    background-color: var(--wa-text-muted);
    border-radius: 3px;
}

.messages-container {
    padding: 20px 80px 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 100%;
}

/* Messages */
.message {
    display: flex;
    margin-bottom: 2px;
    position: relative;
}

.message.own {
    justify-content: flex-end;
}

.message.other {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 65%;
    padding: 6px 7px 8px 9px;
    border-radius: 7.5px;
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--wa-shadow-2);
}

.message.own .message-bubble {
    background-color: var(--wa-bg-message-out);
    color: var(--wa-text-primary);
}

.message.other .message-bubble {
    background-color: var(--wa-bg-message-in);
    color: var(--wa-text-primary);
}

.message-sender {
    font-size: 12.8px;
    font-weight: 500;
    color: var(--wa-green);
    margin-bottom: 3px;
    line-height: 1.3;
}

.message-content {
    font-size: 14.2px;
    line-height: 1.4;
    margin-bottom: 2px;
    word-break: break-word;
}

.message-time {
    font-size: 11px;
    color: var(--wa-text-muted);
    text-align: left;
    direction: ltr;
    line-height: 1.3;
}

/* Empty Chat */
.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.empty-title {
    font-size: 32px;
    font-weight: 300;
    color: var(--wa-text-primary);
    margin-bottom: 8px;
}

.empty-subtitle {
    font-size: 14px;
    color: var(--wa-text-secondary);
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--wa-border);
    border-top: 3px solid var(--wa-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    color: var(--wa-text-muted);
    font-size: 14px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== MESSAGE INPUT ===== */
.message-input-area {
    background-color: var(--wa-bg-panel);
    border-top: 1px solid var(--wa-border);
    padding: 9px 16px;
}

.message-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background-color: var(--wa-bg-input);
    border-radius: 21px;
    padding: 5px 5px 5px 15px;
    border: 1px solid transparent;
    transition: border-color 0.1s ease;
}

.message-input-container:focus-within {
    border-color: var(--wa-green);
}

.attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: none;
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s ease;
    flex-shrink: 0;
}

.attach-btn:hover {
    background-color: var(--wa-bg-hover);
}

.attach-btn svg {
    width: 24px;
    height: 24px;
}

.message-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 20px;
}

.message-input {
    width: 100%;
    border: none;
    background: none;
    outline: none;
    font-size: 15px;
    color: var(--wa-text-primary);
    padding: 9px 0;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    font-family: inherit;
}

.message-input::placeholder {
    color: var(--wa-text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--wa-green);
    border: none;
    color: var(--wa-text-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s ease;
    flex-shrink: 0;
    margin-left: 3px;
}

.send-btn:hover {
    background-color: var(--wa-green-dark);
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

.send-btn:disabled {
    background-color: var(--wa-text-muted);
    cursor: not-allowed;
}

/* ===== NO CHAT SELECTED ===== */
.no-chat-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background-color: var(--wa-bg-panel);
    text-align: center;
    padding: 40px;
}

.no-chat-selected .empty-state {
    padding: 0;
}

.no-chat-selected img {
    max-width: 360px;
    opacity: 0.95;
    margin-bottom: 32px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
    
    .messages-container {
        padding: 20px 60px 20px 40px;
    }
}

@media (max-width: 768px) {
    .chat-container {
        flex-direction: row; /* Keep side by side on mobile */
    }
    
    .sidebar {
        width: 280px;
        position: relative;
        z-index: 10;
    }
    
    .chat-area {
        flex: 1;
        z-index: 1;
    }
    
    .messages-container {
        padding: 20px 20px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
}

/* ===== LOADING STATES ===== */
.loading-messages {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.spinner circle {
    stroke: var(--wa-green);
    stroke-linecap: round;
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% { stroke-dashoffset: 80; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -80; }
}