/* ============================================================
   UTT AMIS Chat UI
   Brand colours: Navy #003473 | Orange #F47920
   ============================================================ */

:root {
  --navy:        #003473;
  --navy-mid:    #004499;
  --navy-light:  #0057c2;
  --navy-dark:   #002055;
  --orange:      #F47920;
  --orange-dark: #d4681a;
  --bg:          #f4f6f9;
  --white:       #ffffff;
  --text:        #1a1d2e;
  --text-mid:    #4b5563;
  --text-light:  #9ca3af;
  --border:      #e5e7eb;
  --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.1);
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   18px;
  --transition:  0.18s ease;
  --sidebar-w:   265px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ----- App shell: sidebar + main side by side ----- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition);
}

.sidebar.collapsed { width: 0; overflow: hidden; }

.sidebar-header {
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
  filter: brightness(0) invert(1);  /* white-out on navy background */
}

.new-chat-btn {
  margin: 14px 12px 8px;
  padding: 10px 16px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.new-chat-btn:hover  { background: var(--orange-dark); }
.new-chat-btn:active { transform: scale(.97); }

.sessions-section {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sessions-label {
  padding: 10px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  flex-shrink: 0;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.session-list::-webkit-scrollbar { width: 4px; }
.session-list::-webkit-scrollbar-track { background: transparent; }
.session-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.session-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.session-item i {
  flex-shrink: 0;
  font-size: 12px;
  opacity: .6;
}

.session-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item:hover   { background: rgba(255,255,255,.1); color: #fff; }
.session-item.active  {
  background: rgba(244,121,32,.22);
  color: #fff;
  font-weight: 500;
}
.session-item.active i { opacity: 1; color: var(--orange); }

.session-loading {
  color: rgba(255,255,255,.4);
  font-size: 12px;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  line-height: 1.5;
}

.sidebar-footer-tagline {
  font-size: 10px;
  color: rgba(244,121,32,.7);
  margin-top: 3px;
  font-style: italic;
}

/* ===== CHAT MAIN ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
}

/* ----- Header ----- */
.chat-header {
  flex-shrink: 0;
  height: 60px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-mid);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background var(--transition);
  display: none;   /* visible on small screens via media query */
}
.sidebar-toggle:hover { background: var(--bg); }

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

.chat-header-avatar {
  width: 36px;
  height: 36px;
  background: var(--navy);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.chat-header-status {
  font-size: 11px;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ----- Messages area ----- */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
}

.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ----- Empty state ----- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 65vh;
  text-align: center;
  padding: 32px 16px;
}

.empty-logo {
  width: 160px;
  height: auto;
  margin-bottom: 24px;
  opacity: .9;
}

.empty-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px;
}

.empty-subtitle {
  font-size: 14px;
  color: var(--text-mid);
  max-width: 440px;
  line-height: 1.7;
  margin-bottom: 28px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.chip {
  padding: 9px 16px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.chip:hover {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* ----- Message bubbles ----- */
.bubble {
  display: flex;
  flex-direction: column;
  margin-bottom: 18px;
  max-width: 78%;
  animation: fadeUp .2s ease;
}

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

.bubble.user {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble.bot,
.bubble.thinking {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 4px;
  padding: 0 4px;
}

.bubble-content {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.bubble.user .bubble-content {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}

.bubble.bot .bubble-content {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  box-shadow: var(--shadow-sm);
}

/* Thinking indicator */
.bubble.thinking .bubble-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  padding: 14px 20px;
}

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

.thinking-dots span {
  width: 8px;
  height: 8px;
  background: var(--navy);
  border-radius: 50%;
  animation: dotBounce 1.2s infinite ease-in-out both;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s;    }
.thinking-dots span:nth-child(2) { animation-delay: .15s;  }
.thinking-dots span:nth-child(3) { animation-delay: .3s;   }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1;   }
}

/* ----- Input area ----- */
.input-area {
  flex-shrink: 0;
  padding: 16px 28px 20px;
  background: var(--white);
  border-top: 1px solid var(--border);
}

.input-form { width: 100%; }

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px 10px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap:focus-within {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(0,52,115,.1);
}

.message-textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  outline: none;
  max-height: 140px;
  overflow-y: auto;
}

.message-textarea::placeholder { color: var(--text-light); }

.send-btn {
  width: 36px;
  height: 36px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  transition: background var(--transition), transform var(--transition);
}

.send-btn:hover   { background: var(--navy-light); }
.send-btn:active  { transform: scale(.92); }
.send-btn:disabled { background: var(--text-light); cursor: not-allowed; }

.input-hint {
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-light);
  text-align: right;
}

.input-hint kbd {
  background: var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 720px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(0);
    transition: transform var(--transition);
  }

  .sidebar.collapsed {
    width: var(--sidebar-w);
    transform: translateX(-100%);
    overflow: hidden;
  }

  .messages-area { padding: 16px; }
  .input-area     { padding: 12px 16px 16px; }
  .bubble         { max-width: 92%; }
}
