/* ================================================================
   Amitim Agent — stylesheet
   RTL, blue professional theme, responsive
   ================================================================ */

/* ---------- Reset / scope ---------------------------------------- */
.amitim-agent-root *,
.amitim-agent-root *::before,
.amitim-agent-root *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

.amitim-agent-root {
	direction: rtl;
	font-family: 'Segoe UI', 'Arial Hebrew', Arial, sans-serif;
	font-size: 15px;
	line-height: 1.6;
	color: #1e293b;
	max-width: 860px;
	margin: 0 auto;
}

/* ---------- Welcome screen --------------------------------------- */
.aa-welcome {
	background: #ffffff;
	border: 1px solid #dde6f0;
	border-radius: 16px;
	padding: 32px 28px 24px;
	box-shadow: 0 4px 24px rgba(26, 58, 107, 0.08);
}

.aa-welcome-header {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 24px;
}

.aa-logo-wrap svg {
	display: block;
	flex-shrink: 0;
}

.aa-h1 {
	font-size: 1.6rem;
	font-weight: 700;
	color: #1a3a6b;
	margin-bottom: 2px;
}

.aa-subtitle {
	font-size: 0.9rem;
	color: #64748b;
}

.aa-greeting-box {
	background: #f0f6ff;
	border-right: 4px solid #2563eb;
	border-radius: 8px;
	padding: 16px 20px;
	margin-bottom: 24px;
}

.aa-greeting-box p {
	margin-bottom: 6px;
	color: #1e3a5f;
}

.aa-greeting-box p:last-child {
	margin-bottom: 0;
}

.aa-choose-prompt {
	font-weight: 600;
	color: #1a3a6b !important;
}

/* Fund selection */
.aa-fund-selection {
	display: flex;
	flex-direction: column;
	gap: 20px;
	margin-bottom: 24px;
}

.aa-fund-group {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	padding: 18px 20px;
}

.aa-fund-group-header {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 14px;
}

.aa-badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 20px;
	font-size: 0.82rem;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.aa-badge-blue  { background: #dbeafe; color: #1d4ed8; }
.aa-badge-navy  { background: #e0e7ff; color: #3730a3; }

.aa-badge-desc {
	font-size: 0.8rem;
	color: #64748b;
}

.aa-fund-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.aa-fund-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	background: #ffffff;
	border: 2px solid #cbd5e1;
	border-radius: 10px;
	padding: 10px 18px;
	font-size: 1rem;
	font-family: inherit;
	color: #1e293b;
	cursor: pointer;
	transition: border-color 0.18s, background 0.18s, transform 0.12s;
}

.aa-fund-btn:hover,
.aa-fund-btn:focus-visible {
	border-color: #2563eb;
	background: #eff6ff;
	transform: translateY(-1px);
	outline: none;
}

.aa-fund-btn:active {
	transform: translateY(0);
}

.aa-fund-icon {
	font-size: 1.2em;
}

.aa-fund-name {
	font-weight: 600;
	color: #1a3a6b;
}

/* Disclaimer */
.aa-disclaimer {
	font-size: 0.82rem;
	color: #64748b;
	background: #fffbeb;
	border: 1px solid #fde68a;
	border-radius: 8px;
	padding: 10px 14px;
	line-height: 1.5;
}

.aa-disclaimer a {
	color: #2563eb;
}

.aa-disclaimer-btns {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 10px;
}

.aa-disc-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #1a3a6b;
	color: #ffffff;
	padding: 6px 14px;
	border-radius: 8px;
	font-size: 0.82rem;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s;
}

.aa-disc-btn:hover {
	background: #2563eb;
	color: #ffffff;
}

/* ---------- Chat screen ------------------------------------------ */
.aa-chat {
	display: flex;
	flex-direction: column;
	background: #ffffff;
	border: 1px solid #dde6f0;
	border-radius: 16px;
	box-shadow: 0 4px 24px rgba(26, 58, 107, 0.08);
	overflow: hidden;
	height: 680px;
}

/* Chat header */
.aa-chat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	background: #1a3a6b;
	color: white;
	padding: 12px 16px;
	flex-shrink: 0;
}

.aa-back-btn {
	display: flex;
	align-items: center;
	gap: 6px;
	background: rgba(255,255,255,0.12);
	border: 1px solid rgba(255,255,255,0.25);
	color: white;
	padding: 6px 12px;
	border-radius: 8px;
	font-size: 0.85rem;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s;
	flex-shrink: 0;
}

.aa-back-btn:hover {
	background: rgba(255,255,255,0.22);
}

.aa-chat-fund-info {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1;
}

.aa-chat-fund-icon {
	font-size: 1.3rem;
}

.aa-chat-fund-name {
	font-size: 1.05rem;
	font-weight: 700;
}

.aa-chat-fund-method {
	font-size: 0.78rem;
	opacity: 0.75;
}

.aa-icon-btn {
	background: rgba(255,255,255,0.12);
	border: 1px solid rgba(255,255,255,0.2);
	color: white;
	border-radius: 8px;
	padding: 6px 8px;
	cursor: pointer;
	transition: background 0.15s;
	display: flex;
	align-items: center;
}

.aa-icon-btn:hover {
	background: rgba(255,255,255,0.22);
}

/* Messages area */
.aa-messages {
	flex: 1;
	overflow-y: auto;
	padding: 20px 16px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	scroll-behavior: smooth;
}

.aa-messages::-webkit-scrollbar { width: 6px; }
.aa-messages::-webkit-scrollbar-track { background: transparent; }
.aa-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Message bubbles */
.aa-msg {
	display: flex;
	gap: 10px;
	max-width: 88%;
	animation: aa-fade-in 0.22s ease;
}

@keyframes aa-fade-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.aa-msg-user {
	align-self: flex-start;
	flex-direction: row-reverse;
}

.aa-msg-assistant {
	align-self: flex-end;
}

.aa-msg-avatar {
	font-size: 1.4rem;
	flex-shrink: 0;
	padding-top: 2px;
}

.aa-bubble {
	border-radius: 14px;
	padding: 12px 16px;
	line-height: 1.65;
	font-size: 0.95rem;
}

.aa-bubble-user {
	background: #dbeafe;
	color: #1e3a5f;
	border-top-right-radius: 4px;
}

.aa-bubble-assistant {
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	color: #1e293b;
	border-top-left-radius: 4px;
	direction: rtl;
	unicode-bidi: embed;
	text-align: right;
}

/* Markdown-like formatting inside bubbles */
.aa-bubble h1,
.aa-bubble h2,
.aa-bubble h3,
.aa-bubble h4 {
	font-weight: 700;
	color: #1a3a6b;
	margin: 12px 0 6px;
}

/* Keep bot-bubble headings the same size as body text */
.amitim-bubble-bot h1,
.amitim-bubble-bot h2,
.amitim-bubble-bot h3 {
	font-size: 1rem;
	margin: 8px 0 4px;
}

.aa-bubble p { margin-bottom: 8px; }
.aa-bubble p:last-child { margin-bottom: 0; }

.aa-bubble ul, .aa-bubble ol {
	padding-right: 22px;
	margin: 6px 0;
}

.aa-bubble li { margin-bottom: 4px; }

.aa-bubble strong { color: #1a3a6b; }

.aa-bubble a {
	color: #2563eb;
	text-decoration: underline;
}

.aa-bubble a:hover { color: #1d4ed8; }

.aa-bubble code {
	background: #e2e8f0;
	padding: 1px 5px;
	border-radius: 4px;
	font-family: monospace;
	font-size: 0.88em;
}

/* Citation buttons (yellow) */
.aa-cite-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: #fef9c3;
	border: 1px solid #fbbf24;
	color: #92400e;
	padding: 2px 9px;
	border-radius: 5px;
	font-size: 0.82em;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	transition: background 0.14s, border-color 0.14s;
	vertical-align: middle;
	margin: 1px 2px;
}

.aa-cite-btn::before {
	content: '📄';
	font-size: 0.85em;
}

.aa-cite-btn:hover {
	background: #fde68a;
	border-color: #d97706;
}

/* Sources block */
.aa-sources {
	margin-top: 14px;
	padding-top: 10px;
	border-top: 1px dashed #cbd5e1;
	font-size: 0.85rem;
	color: #475569;
}

.aa-sources strong {
	color: #1a3a6b;
	font-size: 0.88rem;
}

.aa-sources ul {
	padding-right: 16px;
	margin-top: 4px;
}

.aa-sources li {
	margin-bottom: 3px;
}

/* Error message */
.aa-msg-error .aa-bubble {
	background: #fef2f2;
	border-color: #fca5a5;
	color: #991b1b;
}

/* Typing indicator */
.aa-typing {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 16px;
	flex-shrink: 0;
}

.aa-typing-avatar { font-size: 1.3rem; }

.aa-typing-dots {
	display: flex;
	gap: 5px;
	align-items: center;
}

.aa-typing-dots span {
	width: 8px;
	height: 8px;
	background: #94a3b8;
	border-radius: 50%;
	animation: aa-bounce 1.2s infinite;
}

.aa-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.aa-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aa-bounce {
	0%, 60%, 100% { transform: translateY(0); }
	30%           { transform: translateY(-6px); }
}

.aa-typing-label {
	font-size: 0.82rem;
	color: #64748b;
}

/* ---- Streaming cursor ------------------------------------------ */
.aa-cursor {
	display: inline-block;
	width: 2px;
	height: 1em;
	background: #1a3a6b;
	vertical-align: text-bottom;
	margin-right: 1px;
	animation: aa-blink 0.8s step-end infinite;
}

@keyframes aa-blink {
	0%, 100% { opacity: 1; }
	50%       { opacity: 0; }
}

/* ---- Quick question buttons ------------------------------------ */
.aa-quick-btns {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 10px 16px 2px;
}

.aa-quick-btn {
	background: #ffffff;
	border: 1.5px solid #2563eb;
	color: #2563eb;
	border-radius: 20px;
	padding: 5px 14px;
	font-size: 0.82rem;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
	white-space: nowrap;
}

.aa-quick-btn:hover,
.aa-quick-btn:focus-visible {
	background: #eff6ff;
	outline: none;
}

/* Input area */
.aa-input-area {
	border-top: 1px solid #e2e8f0;
	padding: 0 0 10px;
	flex-shrink: 0;
}

.aa-input-row {
	display: flex;
	gap: 10px;
	align-items: flex-end;
	padding: 10px 16px 0;
}

.aa-input {
	flex: 1;
	resize: none;
	border: 2px solid #cbd5e1;
	border-radius: 12px;
	padding: 10px 14px;
	font-family: inherit;
	font-size: 0.95rem;
	line-height: 1.5;
	color: #1e293b;
	background: #f8fafc;
	transition: border-color 0.18s;
	max-height: 140px;
	overflow-y: auto;
	direction: rtl;
}

.aa-input:focus {
	outline: none;
	border-color: #2563eb;
	background: #ffffff;
}

.aa-send-btn {
	background: #2563eb;
	border: none;
	border-radius: 10px;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s, transform 0.12s;
}

.aa-send-btn:hover  { background: #1d4ed8; transform: scale(1.05); }
.aa-send-btn:active { transform: scale(0.97); }

.aa-send-btn:disabled {
	background: #94a3b8;
	cursor: not-allowed;
	transform: none;
}

.aa-input-hint {
	font-size: 0.75rem;
	color: #94a3b8;
	text-align: center;
	margin-top: 6px;
}

/* ---------- PDF Modal -------------------------------------------- */
.aa-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.aa-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.65);
	backdrop-filter: blur(2px);
}

.aa-modal-container {
	position: relative;
	background: white;
	border-radius: 14px;
	width: 100%;
	max-width: 860px;
	height: 88vh;
	max-height: 860px;
	display: flex;
	flex-direction: column;
	box-shadow: 0 20px 60px rgba(0,0,0,0.35);
	overflow: hidden;
	animation: aa-modal-in 0.2s ease;
}

@keyframes aa-modal-in {
	from { opacity: 0; transform: scale(0.95); }
	to   { opacity: 1; transform: scale(1); }
}

.aa-modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: #1a3a6b;
	color: white;
	padding: 14px 18px;
	flex-shrink: 0;
}

.aa-modal-title {
	font-size: 1.05rem;
	font-weight: 700;
}

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

.aa-btn-outline {
	display: inline-block;
	background: rgba(255,255,255,0.12);
	border: 1px solid rgba(255,255,255,0.3);
	color: white;
	padding: 6px 14px;
	border-radius: 8px;
	font-size: 0.85rem;
	text-decoration: none;
	transition: background 0.15s;
}

.aa-btn-outline:hover { background: rgba(255,255,255,0.22); }

.aa-modal-close {
	background: rgba(255,255,255,0.12);
	border: 1px solid rgba(255,255,255,0.25);
	color: white;
	width: 32px;
	height: 32px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 1rem;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
}

.aa-modal-close:hover { background: rgba(255,255,255,0.3); }

.aa-modal-body {
	flex: 1;
	overflow: hidden;
}

.aa-pdf-frame {
	width: 100%;
	height: 100%;
	border: none;
}

/* ---------- Responsive ------------------------------------------- */
@media (max-width: 600px) {
	.aa-welcome { padding: 20px 16px 18px; }
	.aa-h1      { font-size: 1.3rem; }
	.aa-chat    { height: 92vh; border-radius: 10px; }
	.aa-fund-btn { padding: 8px 12px; font-size: 0.9rem; }
	.aa-msg     { max-width: 96%; }
	.aa-modal-container { height: 96vh; max-height: none; border-radius: 10px; }
}

/* ---------- Contact buttons (amitim-disclaimer) ------------------ */
.amitim-disclaimer {
	font-size: 0.82rem;
	color: #64748b;
	background: #fffbeb;
	border: 1px solid #fde68a;
	border-radius: 8px;
	padding: 10px 14px;
	line-height: 1.5;
	text-align: center;
}

.amitim-contact-btns {
	display: flex;
	gap: 8px;
	justify-content: center;
	margin-top: 8px;
	flex-wrap: wrap;
}

.amitim-contact-btns a {
	background: #003580;
	color: #fff;
	padding: 6px 14px;
	border-radius: 20px;
	text-decoration: none;
	font-size: 0.82rem;
	transition: background 0.2s;
}

.amitim-contact-btns a:hover {
	background: #0055b3;
}

/* ---------- Bot-bubble heading sizes ----------------------------- */
.amitim-bubble-bot h1,
.amitim-bubble-bot h2,
.amitim-bubble-bot h3 {
	font-size: 1rem !important;
	margin: 8px 0 4px;
}

/* ---------- Reference / citation links (Fix 2) ------------------- */
.amitim-ref-link {
	display: inline-flex;
	align-items: center;
	direction: rtl;
	unicode-bidi: embed;
	text-align: right;
	background: #fff3cd;
	border: 1px solid #f0b800;
	color: #7a5900;
	border-radius: 4px;
	padding: 2px 8px;
	font-size: 0.82rem;
	font-weight: bold;
	cursor: pointer;
	margin: 0 3px;
	text-decoration: none;
	vertical-align: middle;
}

.amitim-ref-link:hover {
	background: #ffe066;
	color: #5a4000;
}

/* ---------- Send button (Fix 4) ---------------------------------- */
#amitim-send-btn {
	background: #003580;
	color: #fff;
	border: none;
	border-radius: 10px;
	width: 52px;
	height: 52px;
	font-size: 1.5rem;
	cursor: pointer;
	transition: background 0.2s;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

#amitim-send-btn:hover    { background: #0055b3; }
#amitim-send-btn:disabled { background: #aaa; cursor: not-allowed; }

/* ---------- Full-page button (Fix 5) ----------------------------- */
.amitim-fullpage-btn {
	background: #003580;
	color: #fff;
	padding: 8px 20px;
	border-radius: 20px;
	text-decoration: none;
	font-size: 0.85rem;
	display: inline-block;
	margin-top: 8px;
}

.amitim-fullpage-btn:hover {
	background: #0055b3;
	color: #fff;
}

/* ---------- Fix 5 — RTL bot bubble --------------------------------- */
.amitim-bubble-bot {
	direction: rtl;
	unicode-bidi: embed;
	text-align: right;
}

/* ---------- Fix 6 — Typing indicator text -------------------------- */
.amitim-typing-text {
	font-size: 0.82rem;
	color: #666;
	margin-bottom: 6px;
	direction: rtl;
}

/* v10 — RTL fix for citation links */
.amitim-ref-link {
    direction: rtl !important;
    unicode-bidi: isolate !important;
    text-align: right !important;
}
