/* ===== Base ===== */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Tahoma, 'Segoe UI', 'Vazirmatn', sans-serif;
    background: #f3f4f6;
    direction: rtl;
    text-align: right;
}

/* ===== Layout ===== */
.chat-container {
    max-width: 900px; margin: 2rem auto;
    border: 1px solid #e5e7eb; border-radius: 16px;
    overflow: hidden; display: flex; flex-direction: column;
    height: 80vh; box-shadow: 0 10px 30px rgba(0,0,0,.08); background: #fff;
}
.chat-header {
    background: linear-gradient(135deg,#6366f1,#8b5cf6);
    color: #fff; padding: 1.1rem 1.5rem; text-align: center;
}
.chat-header h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.chat-header p { margin: .25rem 0 0; font-size: .85rem; opacity: .85; }

.chat-messages {
    flex: 1; overflow-y: auto; padding: 1.25rem;
    background: #f9fafb; display: flex; flex-direction: column; gap: 1rem;
}

/* ===== Messages (both aligned to the right in RTL) ===== */
.message {
    padding: .9rem 1.1rem; border-radius: 14px; max-width: 85%;
    line-height: 1.7; font-size: .92rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    direction: rtl; text-align: right;
    align-self: flex-start;          /* both user and bot sit on the right */
    margin-left: 0;
    margin-right: 0;
}
.message.user {
    background: #6366f1; color: #fff;
    border-bottom-right-radius: 4px;   /* tail on the right */
    border-bottom-left-radius: 14px;
}
.message.bot {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-right-radius: 4px;   /* tail on the right */
    border-bottom-left-radius: 14px;
}
.message.bot strong { display: block; margin-bottom: .4rem; color: #111827; }
.message.bot details { margin: .6rem 0; }
.message.bot summary { cursor: pointer; color: #6366f1; font-weight: 500; font-size: .85rem; }
.message.bot pre {
    background: #1e1e2e; color: #cdd6f4;
    padding: .9rem 1rem; border-radius: 10px;
    overflow-x: auto; font-size: .82rem; margin: .5rem 0 0;
    font-family: 'Fira Code', 'Consolas', monospace;
    direction: ltr; text-align: left;
}

/* ===== Modern Table ===== */
.result-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    margin-top: .75rem; font-size: .85rem;
    border-radius: 10px; overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    direction: rtl;
}
.result-table thead th {
    background: #6366f1; color: #fff; font-weight: 600;
    padding: 10px 12px; text-align: right; white-space: nowrap;
}
.result-table tbody td {
    padding: 9px 12px; border-bottom: 1px solid #eef0f4;
    text-align: right; color: #374151;
}
.result-table tbody tr:nth-child(even) { background: #f8f9fc; }
.result-table tbody tr:last-child td { border-bottom: none; }
.result-table tbody tr:hover { background: #eef2ff; transition: background .15s; }
.result-table tbody td.num {
    font-variant-numeric: tabular-nums;
    direction: ltr; text-align: right;
    unicode-bidi: plaintext;
}

/* ===== Suggestions ===== */
.suggestions-block {
    margin-top: 1rem; padding-top: .85rem;
    border-top: 1px dashed #d1d5db;
    direction: rtl; text-align: right;
}
.suggestions-title {
    display: block; font-size: .8rem; font-weight: 600;
    color: #6b7280; margin-bottom: .55rem;
}
.suggestions-list { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-start; }
.suggestion-btn {
    background: #eef2ff; color: #4f46e5;
    border: 1px solid #c7d2fe; border-radius: 999px;
    padding: 6px 14px; font-size: .82rem; cursor: pointer;
    transition: all .15s; font-family: inherit;
}
.suggestion-btn:hover {
    background: #6366f1; color: #fff;
    border-color: #6366f1; transform: translateY(-1px);
}

/* ===== Metric ===== */
.metric-value {
    font-size: 44px; font-weight: 700; color: #6366f1;
    text-align: center; padding: 18px 0;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

/* ===== Input ===== */
.chat-input-area {
    display: flex; padding: .85rem 1rem;
    border-top: 1px solid #e5e7eb; background: #fff; gap: .5rem;
    direction: rtl;
}
.chat-input-area input {
    flex: 1; padding: .8rem 1rem;
    border: 1px solid #d1d5db; border-radius: 10px;
    outline: none; font-size: .92rem;
    transition: border-color .15s, box-shadow .15s;
    direction: rtl; text-align: right;
    font-family: inherit;
}
.chat-input-area input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.chat-input-area button {
    padding: .8rem 1.6rem; background: #6366f1; color: #fff;
    border: none; border-radius: 10px; cursor: pointer;
    font-weight: 500; transition: background .15s;
    font-family: inherit;
}
.chat-input-area button:hover:not(:disabled) { background: #4f46e5; }
.chat-input-area button:disabled { background: #c7d2fe; cursor: not-allowed; }

.loading-indicator {
    text-align: center; color: #6b7280; font-size: .85rem; padding: .5rem;
    direction: rtl;
}