/* ===== CHAT PAGE ===== */

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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #0d4d44;
    direction: rtl;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== HEADER ========== */
header {
    background: #fff;
    padding: 12px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-logo { height: 85px; width: auto; object-fit: contain; }

.header-nav { display: flex; align-items: center; gap: 4px; }
.header-nav a {
    color: #0d4d44;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0 10px;
    transition: color 0.2s;
}
.header-nav a:hover { color: #d63031; }
.nav-sep { color: #ccc; }

/* ========== LAYOUT ========== */
.chat-main {
    flex: 1;
    max-width: 760px;
    width: 100%;
    margin: 40px auto;
    padding: 0 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ========== CARD ========== */
.chat-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-top-bar {
    background: #d63031;
    height: 7px;
    width: 100%;
    flex-shrink: 0;
}

/* ========== CHAT HEADER (inside card) ========== */
.chat-card-header {
    padding: 20px 28px 16px;
    border-bottom: 2px solid #f4f7f6;
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-card-header .chat-icon {
    width: 46px;
    height: 46px;
    background: #0d4d44;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.chat-card-header h2 {
    color: #0d4d44;
    font-size: 1.25rem;
    font-weight: 700;
}

.chat-card-header .chat-subtitle {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

/* ========== CHAT WINDOW ========== */
#chat-window {
    flex: 1;
    height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 22px;
    background: #f4f7f6;
}

/* Scrollbar styling */
#chat-window::-webkit-scrollbar { width: 6px; }
#chat-window::-webkit-scrollbar-track { background: transparent; }
#chat-window::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
#chat-window::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ========== MESSAGES ========== */
.message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
    animation: msgIn 0.2s ease-out;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* הודעות שלי – ימין (RTL start) */
.mine {
    background: #d4edda;
    color: #1a3a20;
    align-self: flex-start;
    border-bottom-right-radius: 4px;
}

/* הודעות של הצד השני – שמאל (RTL end) */
.theirs {
    background: #fff;
    color: #333;
    align-self: flex-end;
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.msg-sender {
    font-size: 0.73rem;
    font-weight: 700;
    color: #0d4d44;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.theirs .msg-sender { color: #888; }

.msg-text { display: block; }

.msg-time {
    display: block;
    font-size: 0.68rem;
    color: #aaa;
    text-align: left;
    margin-top: 5px;
}

/* ========== EMPTY / LOADING STATES ========== */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #aaa;
    gap: 10px;
    padding: 40px 20px;
}

.chat-empty-icon { font-size: 2.6rem; }

.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    color: #888;
    font-size: 0.88rem;
}

.dot-bounce {
    width: 8px; height: 8px;
    background: #0d4d44;
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}
.dot-bounce:nth-child(2) { animation-delay: 0.2s; }
.dot-bounce:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ========== INPUT AREA ========== */
.chat-input-area {
    padding: 16px 22px;
    border-top: 2px solid #f4f7f6;
    background: #fff;
}

#messageForm {
    display: flex;
    gap: 10px;
    align-items: center;
}

#msgInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #dde3e2;
    border-radius: 24px;
    font-size: 0.95rem;
    font-family: inherit;
    direction: rtl;
    background: #fafafa;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: none;
}

#msgInput:focus {
    border-color: #0d4d44;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(13,77,68,0.09);
}

#msgInput::placeholder { color: #bbb; }

#btn-send {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: #0d4d44;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s, transform 0.15s;
}

#btn-send:hover   { background: #d63031; transform: scale(1.08); }
#btn-send:active  { transform: scale(0.95); }
#btn-send:disabled { background: #b0bec5; cursor: default; transform: none; }

/* ========== TOAST ========== */
#toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(70px);
    background: #0d4d44;
    color: #fff;
    padding: 12px 26px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.92rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
}
#toast.show  { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.error { background: #d63031; }

/* ========== RESPONSIVE ========== */
@media (max-width: 560px) {
    .chat-main { margin: 12px auto; padding: 0 10px 20px; }
    .chat-card-header { padding: 16px 16px 12px; }
    #chat-window { height: 340px; padding: 14px 12px; }
    .chat-input-area { padding: 12px 14px; }
    .message { max-width: 85%; }
}
