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

:root {
  --bg:       #0d0f12;
  --bg2:      #13161b;
  --bg3:      #1a1e25;
  --border:   #252a33;
  --border2:  #2e3440;
  --accent:   #e8a020;
  --accent2:  #f0b840;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --text3:    #64748b;
  --danger:   #ef4444;
  --success:  #22c55e;
  --radius:   12px;
  --font:     'IBM Plex Sans Arabic', sans-serif;
  --mono:     'IBM Plex Mono', monospace;
}

html, body { height: 100%; overflow: hidden; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; }

.shell { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: 256px; min-width: 256px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px; gap: 20px;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-mark {
  width: 36px; height: 36px;
  background: var(--accent); color: #000;
  font-weight: 700; font-size: 17px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
}
.brand-name { font-size: 15px; font-weight: 600; display: block; }
.brand-sub  { font-size: 10px; color: var(--text3); display: block; text-transform: uppercase; letter-spacing: 0.08em; }

.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text3); padding: 0 6px; margin-bottom: -6px; }
.quick-links { display: flex; flex-direction: column; gap: 3px; }
.quick-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--text2); padding: 8px 10px;
  border-radius: 7px; cursor: pointer;
  text-align: left; font-family: var(--font); font-size: 13px;
  transition: all 0.15s;
}
.quick-btn:hover { background: var(--bg3); border-color: var(--border); color: var(--text); }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.clear-btn {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 9px 16px;
  border-radius: 8px; cursor: pointer;
  font-family: var(--font); font-size: 13px;
  transition: all 0.15s;
}
.clear-btn:hover { border-color: var(--accent); color: var(--accent); }
.connection-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text3); padding: 0 6px;
}

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 50px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0; background: var(--bg2);
}
.topbar-center { font-size: 14px; font-weight: 500; color: var(--text2); }
.menu-toggle { display: none; background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; }

/* STATUS DOT */
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(34,197,94,0.2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.2); }
  50%      { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* CHAT WINDOW */
.chat-window {
  flex: 1; overflow-y: auto;
  padding: 28px 20px;
  display: flex; flex-direction: column; gap: 20px;
  scroll-behavior: smooth;
}
.chat-window::-webkit-scrollbar { width: 5px; }
.chat-window::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* WELCOME */
.welcome { text-align: center; padding: 50px 20px; max-width: 500px; margin: 0 auto; }
.welcome-icon { font-size: 32px; color: var(--accent); margin-bottom: 16px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.welcome h1 { font-size: 26px; font-weight: 600; margin-bottom: 10px; }
.welcome p  { color: var(--text2); font-size: 14px; line-height: 1.7; margin-bottom: 20px; }
.welcome-hints { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.welcome-hints span {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); padding: 6px 12px; border-radius: 20px;
  font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.welcome-hints span:hover { border-color: var(--accent); color: var(--accent); }

/* MESSAGES */
.message { display: flex; gap: 12px; max-width: 860px; width: 100%; margin: 0 auto; animation: fadeUp 0.2s ease; }
.message.user { flex-direction: row-reverse; }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.avatar {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  font-family: var(--mono); font-weight: 600;
}
.message.user .avatar { background: var(--accent); color: #000; }
.message.ai   .avatar { background: var(--bg3); border: 1px solid var(--border); color: var(--accent); }

.bubble {
  max-width: calc(100% - 48px);
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.75;
}
.message.user .bubble { background: var(--bg3); border: 1px solid var(--border2); border-top-right-radius: 4px; }
.message.ai   .bubble { background: var(--bg2); border: 1px solid var(--border); border-top-left-radius: 4px; }

/* MARKDOWN inside bubbles */
.bubble strong { color: var(--accent2); font-weight: 600; }
.bubble h3 { color: var(--text); font-size: 15px; margin: 14px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }

.bubble table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; font-family: var(--mono); }
.bubble th { background: var(--bg3); padding: 7px 10px; text-align: left; border: 1px solid var(--border2); color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.bubble td { padding: 6px 10px; border: 1px solid var(--border); color: var(--text2); }
.bubble tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
.bubble tr:hover td { background: rgba(232,160,32,0.05); }

.bubble ul, .bubble ol { padding-left: 18px; margin: 6px 0; }
.bubble li { margin: 3px 0; color: var(--text2); }
.bubble code { background: var(--bg3); padding: 2px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; color: var(--accent2); }
.bubble pre { background: var(--bg3); border: 1px solid var(--border); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 8px 0; }
.bubble pre code { background: none; padding: 0; color: var(--text); }

/* CHART CONTAINER */
.chart-container {
  margin: 16px 0 4px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 20px;
  position: relative;
}
.chart-title {
  font-size: 13px; font-weight: 500;
  color: var(--text2); margin-bottom: 14px;
  text-align: center; letter-spacing: 0.03em;
}
.chart-canvas { max-height: 320px; }

/* TYPING */
.typing { display: flex; gap: 5px; align-items: center; padding: 4px 0; }
.typing span { width: 6px; height: 6px; background: var(--text3); border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity:0.2; transform:scale(0.8); } 40% { opacity:1; transform:scale(1); } }

/* INPUT */
.input-area { padding: 14px 20px 18px; border-top: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.input-row { display: flex; gap: 10px; align-items: flex-end; max-width: 860px; margin: 0 auto; }

textarea {
  flex: 1; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 10px; padding: 11px 15px;
  color: var(--text); font-family: var(--font); font-size: 14px;
  resize: none; outline: none; max-height: 150px;
  overflow-y: auto; line-height: 1.5; transition: border-color 0.15s;
}
textarea::placeholder { color: var(--text3); }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,160,32,0.1); }

.send-btn {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--accent); border: none; color: #000;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.send-btn:hover { background: var(--accent2); transform: scale(1.05); }
.send-btn:disabled { background: var(--bg3); color: var(--text3); cursor: not-allowed; transform: none; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { position: fixed; left:0; top:0; bottom:0; z-index:100; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  .menu-toggle { display: block; }
}
