:root {
  /* Smart Premium Green Glow Accent System */
  --primary: #00b159;
  --primary-glow: rgba(0, 177, 89, 0.15);
  --primary-accent: #10b981;
  
  /* Modern Clean Dark/Light Blends */
  --bg-page: #ffffff;
  --bg-chat: #ffffff;
  --surface: #f8fafc;
  --surface-strong: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #f1f5f9;
  
  /* Soft Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 40px rgba(0, 177, 89, 0.2);

  /* Design System Radii */
  --radius-md: 16px;
  --radius-sm: 12px;
  
  /* Fonts */
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Poppins', sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset for Fullscreen */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

html, body { 
  height: 100%; 
  width: 100%; 
  background-color: var(--bg-page); 
  color: var(--text-main); 
  font-family: var(--font-body); 
  overflow: auto; 
  -webkit-font-smoothing: antialiased;
}

/* Cire duka tazarar gefe (No Margins, No Paddings) */
body { 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  padding: 0; 
}

/* Page Container takes 100% of Viewport */
.page { 
  position: relative; 
  width: 100vw; 
  min-height: 100vh; 
  background-color: var(--bg-chat); 
  overflow: hidden; 
}

/* --- ONBOARDING / LANGUAGE SCREEN --- */
.language-screen { 
  position: absolute; 
  inset: 0; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  padding: 24px 16px; 
  background: radial-gradient(circle at center, #ffffff 0%, #f8fafc 100%); 
  z-index: 40; 
  opacity: 1; 
  overflow-y: auto; 
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease; 
}

.language-screen.hidden { 
  transform: scale(1.02); 
  opacity: 0; 
  pointer-events: none; 
}

.lang-inner { 
  text-align: center; 
  padding: 28px; 
  max-width: 460px; 
  width: min(92vw, 460px); 
  margin: auto 0; 
  background: rgba(255,255,255,0.92); 
  border: 1px solid rgba(15, 23, 42, 0.06); 
  border-radius: 28px; 
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.08); 
  backdrop-filter: blur(12px);
}

.logo-wrapper {
  margin-bottom: 24px;
  display: inline-block;
}

.logo { 
  width: 100px; 
  height: 100px; 
  border-radius: 32px; 
  object-fit: cover; 
  border: 4px solid #ffffff; 
  box-shadow: var(--shadow-glow);
}

.logo.animate-pulse-slow { 
  animation: pulse-slow 3s infinite ease-in-out; 
}

@keyframes pulse-slow { 
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 15px rgba(0, 177, 89, 0.2)); } 
  50% { transform: scale(1.04); filter: drop-shadow(0 0 25px rgba(0, 177, 89, 0.4)); } 
}

.title { 
  font-family: var(--font-title); 
  font-size: clamp(28px, 4vw, 34px); 
  font-weight: 800; 
  color: var(--text-main); 
  margin-bottom: 8px; 
  letter-spacing: -0.5px; 
}

.subtitle { 
  font-size: 14px; 
  color: var(--text-muted); 
  line-height: 1.7; 
  margin-bottom: 24px; 
}

.name-form { 
  display: flex; 
  flex-direction: column; 
  gap: 16px; 
  text-align: left; 
}

.auth-tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}

.auth-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

.auth-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.auth-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(0, 177, 89, 0.2);
}

.hidden {
  display: none;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.name-form label { 
  font-size: 12px; 
  font-weight: 600; 
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted); 
}

.name-form input,
.name-form select { 
  width: 100%; 
  min-height: 50px; 
  border: 1.5px solid #dbe7e0; 
  background-color: #ffffff; 
  color: var(--text-main); 
  border-radius: 14px; 
  padding: 15px 16px; 
  font-size: 15px; 
  outline: none; 
  transition: var(--transition); 
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.name-form input::placeholder {
  color: #94a3b8;
}

.name-form input:focus,
.name-form select:focus { 
  border-color: var(--primary); 
  background-color: #ffffff;
  box-shadow: 0 0 0 4px var(--primary-glow); 
  transform: translateY(-1px);
}

.start-btn { 
  width: 100%; 
  min-height: 52px; 
  border: none; 
  border-radius: 14px; 
  background: linear-gradient(135deg, var(--primary), var(--primary-accent));
  color: white; 
  padding: 15px 16px; 
  font-size: 15px;  
  font-weight: 700; 
  cursor: pointer; 
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(0, 177, 89, 0.25);
  transition: var(--transition);
}

.start-btn:hover { 
  background: linear-gradient(135deg, var(--primary-accent), var(--primary));
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 177, 89, 0.3);
}

/* --- MAIN INTERFACE SCREEN --- */
.chat-screen { 
  position: absolute; 
  inset: 0; 
  display: flex; 
  flex-direction: column; 
  opacity: 0; 
  pointer-events: none; 
  transition: opacity 0.3s ease; 
  z-index: 20; 
}

.chat-screen.visible { 
  opacity: 1; 
  pointer-events: auto; 
}

.chat-layout, .chat-main { 
  display: flex; 
  flex-direction: column; 
  height: 100%; 
  width: 100%; 
}

/* App Header styling */
.chat-header { 
  height: 64px; 
  background: rgba(255, 255, 255, 0.85); 
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  padding: 0 24px; 
}

.chat-header .left { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
}

.ai-avatar { 
  width: 38px; 
  height: 38px; 
  border-radius: 12px; 
  overflow: hidden; 
  border: 1px solid var(--border); 
}

.ai-avatar img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
}

.header-texts { display: flex; flex-direction: column; }
.header-title { font-family: var(--font-title); font-size: 15px; font-weight: 700; }
.header-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }

.dot { 
  width: 6px; 
  height: 6px; 
  background-color: var(--primary); 
  border-radius: 50%; 
  box-shadow: 0 0 10px var(--primary);
}

.header-pill { 
  background: var(--primary-glow); 
  color: var(--primary); 
  padding: 6px 12px; 
  border-radius: 999px; 
  font-size: 11px; 
  font-weight: 600; 
}

/* Chat Shell and History Panel */
.chat-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.history-panel {
  width: 300px;
  max-width: 92vw;
  border-right: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 5;
}

.history-panel.hidden {
  display: none;
}

.history-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.history-panel-head h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}

.history-panel-head p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.history-close,
.header-action {
  border: none;
  background: transparent;
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.header-action:hover,
.history-close:hover {
  background: var(--surface);
  color: var(--primary);
}

.header-action.danger:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.header-action .material-symbols-outlined,
.history-close .material-symbols-outlined {
  font-size: 20px;
}

.right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
}

.history-item {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 14px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(0, 177, 89, 0.08);
  transform: translateY(-1px);
}

.history-item strong {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.4;
}

.history-item span {
  font-size: 11px;
  color: var(--text-muted);
}

.history-empty {
  padding: 14px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: #fff;
}

.chat-body { 
  flex: 1; 
  overflow-y: auto; 
  padding: 32px 24px; 
  display: flex; 
  flex-direction: column; 
  gap: 24px; 
  scroll-behavior: smooth; 
  min-width: 0;
}

.chat-main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.94));
}

.chat-body::-webkit-scrollbar { width: 5px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: var(--surface-strong); border-radius: 999px; }

/* Dashboard Welcome Grid card */
.welcome-card { 
  max-width: 600px; 
  margin: auto; 
  background-color: var(--surface);
  border-radius: var(--radius-md); 
  padding: 32px; 
  text-align: center; 
  animation: fadeIn 0.4s ease-out; 
}

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

.welcome-card h2 { 
  font-family: var(--font-title); 
  color: var(--text-main); 
  margin-bottom: 10px; 
  font-size: 22px; 
  font-weight: 700;
}

.welcome-card p { 
  color: var(--text-muted); 
  font-size: 14px; 
  line-height: 1.6; 
}

/* Message Node Configurations */
.messages { 
  max-width: 800px; 
  width: 100%; 
  margin: 0 auto; 
  display: flex; 
  flex-direction: column; 
  gap: 20px; 
}

.message { 
  display: flex; 
  width: 100%; 
  animation: msgIn 0.25s ease-out; 
}

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

.message.user { justify-content: flex-end; }
.message.ai { justify-content: flex-start; }

.bubble { 
  max-width: 75%; 
  padding: 14px 18px; 
  border-radius: 20px; 
  font-size: 14.5px; 
  line-height: 1.6; 
  word-wrap: break-word; 
}

.message.user .bubble { 
  background-color: var(--text-main); 
  color: #ffffff; 
  border-bottom-right-radius: 4px; 
}

/* Smart Green Highlights for AI Text */
.message.ai .bubble { 
  background-color: var(--surface); 
  color: var(--text-main); 
  border-bottom-left-radius: 4px; 
}

.bubble strong { color: var(--primary); font-weight: 600; }
.message.user .bubble strong { color: var(--primary-accent); }

/* Typing indicator */
.bubble.typing { display: flex; align-items: center; gap: 4px; padding: 16px 22px; }
.typing-dot { width: 6px; height: 6px; background-color: var(--primary); border-radius: 50%; animation: typeBounce 1.4s infinite ease-in-out both; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typeBounce { 
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; } 
  40% { transform: scale(1.2); opacity: 1; } 
}

/* Chips Section */
.suggested-questions-container { 
  padding: 8px 24px 0; 
  background-color: var(--bg-chat); 
}

.suggested-questions { 
  max-width: 800px; 
  margin: 0 auto; 
  display: flex; 
  gap: 8px; 
  overflow-x: auto;
  padding-bottom: 8px;
}
.suggested-questions::-webkit-scrollbar { display: none; }

.suggest-chip { 
  background-color: var(--surface); 
  border: 1px solid var(--border);
  color: var(--text-main); 
  font-size: 13px; 
  font-weight: 500; 
  padding: 10px 16px; 
  border-radius: 999px; 
  cursor: pointer; 
  white-space: nowrap; 
  transition: var(--transition); 
}

.suggest-chip:hover { 
  background-color: var(--primary-glow); 
  border-color: var(--primary);
  color: var(--primary);
}

/* Input Area Setup */
.chat-input-area { 
  padding: 16px 24px 24px; 
  background-color: var(--bg-chat); 
}

.input-wrap { 
  max-width: 800px; 
  margin: 0 auto; 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  background-color: var(--surface); 
  border: 1px solid var(--border);
  border-radius: 28px; 
  padding: 8px 8px 8px 20px; 
  transition: var(--transition); 
}

.input-wrap:focus-within { 
  border-color: var(--primary); 
  background-color: var(--bg-chat);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.chat-input { 
  flex: 1; 
  background: transparent; 
  border: none; 
  color: var(--text-main); 
  font-family: var(--font-body); 
  font-size: 14.5px; 
  resize: none; 
  outline: none; 
  max-height: 140px; 
}
.chat-input::placeholder { color: var(--text-muted); }

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

.icon-btn.primary { 
  background-color: var(--primary); 
  color: #ffffff; 
}
.icon-btn.primary:hover:not(:disabled) { 
  background-color: var(--primary-accent);
  transform: scale(1.04);
}
.icon-btn.primary:disabled { 
  opacity: 0.15; 
  background-color: var(--text-muted);
  cursor: not-allowed; 
}

/* Responsive Scaling for Responsive Screens */
@media (max-width: 768px) { 
  body {
    align-items: stretch;
  }

  .page {
    min-height: 100vh;
  }

  .lang-inner {
    padding: 22px 18px;
    border-radius: 22px;
  }

  .title { font-size: 26px; }
  .subtitle { font-size: 13px; }
  .auth-tabs { margin-bottom: 14px; }
  .auth-tab { padding: 9px 12px; font-size: 14px; }
  .chat-header { padding: 0 14px; height: 58px; }
  .chat-body { padding: 18px 14px 20px; } 
  .bubble { max-width: 88%; }
  .chat-input-area { padding: 10px 14px 14px; }
  .suggested-questions-container { padding: 6px 14px 0; }
  .history-panel {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(90vw, 300px);
    height: 100%;
    box-shadow: 16px 0 40px rgba(15, 23, 42, 0.08);
  }
}

@media (min-width: 1024px) {
  .lang-inner {
    max-width: 520px;
    padding: 36px;
  }

  .chat-header {
    padding: 0 28px;
  }

  .chat-body {
    padding: 36px 28px 28px;
  }

  .chat-input-area,
  .suggested-questions-container {
    padding-left: 28px;
    padding-right: 28px;
  }
}

@media (max-width: 480px) {
  .auth-tabs {
    flex-direction: column;
  }

  .auth-tab {
    width: 100%;
  }

  .chat-header .right {
    gap: 6px;
  }

  .header-pill {
    display: none;
  }

  .bubble {
    max-width: 100%;
    border-radius: 16px;
  }
}
