/* ================== ROOT ================== */
:root {
  --card: #ffffff;
  --bg: #ffffff;
  --text: #222;
  --border-color: #ddd;
  --accent: #3b82f6;

  --msg-user-bg: linear-gradient(90deg, #3b82f6, #60a5fa);
  --msg-user-text: #fff;

  --msg-bot-bg: #ffffff;
  --msg-bot-text: #222;

  --header-bg: #f3f3f3;
  --sidebar-bg: #fafafa;

  --mobile-logo-h: 56px; /* chiều cao logo mobile */
}

.dark {
  --card: #1f1f1f;
  --bg: #1e1e1e;
  --text: #eaeaea;
  --border-color: #444;

  --msg-user-bg: linear-gradient(90deg, #2563eb, #3b82f6);
  --msg-user-text: #fff;

  --msg-bot-bg: #2a2a2a;
  --msg-bot-text: #eaeaea;

  --header-bg: #2a2a2a;
  --sidebar-bg: #1f1f1f;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
}

html, body {
  height: 100%;
}

/* ================== APP ================== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ================== SIDEBAR ================== */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.logo {
  width: 100px;
  height: auto;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-wrap h2 {
  font-size: 16px;
  margin: 0;
}

.nav-list {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-list button {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--card);
  cursor: pointer;
  color: var(--text);
}

/* ================== MAIN ================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--header-bg);
  white-space: nowrap;
}

.title {
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ================== CHAT AREA ================== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
}

.msg {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  word-wrap: break-word;
}

/* User bên phải */
.msg.user {
  margin-left: auto;
  background: var(--msg-user-bg);
  color: var(--msg-user-text);
}

/* Bot bên trái */
.msg.bot {
  margin-right: auto;
  background: var(--msg-bot-bg);
  color: var(--msg-bot-text);
}

/* ================== COMPOSER ================== */
.composer {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--card);
  align-items: center;
}

textarea {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  resize: none;
  background: var(--bg);
  color: var(--text);
}

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

.composer-actions button {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

/* ================== TOAST ================== */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  opacity: .95;
}

/* ================== DESKTOP ================== */
@media (min-width: 769px) {
  .mobile-logo {
    display: none;
  }
}

/* ================== MOBILE ================== */
@media (max-width: 768px) {

  .app {
    flex-direction: column;
  }

  /* === fixed logo mobile === */
  .mobile-logo {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--mobile-logo-h);
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    z-index: 10050;
  }

  .mobile-logo img {
    width: 50px;
    height: auto;
  }

  .mobile-logo h2 {
    font-size: 16px;
    white-space: nowrap;
  }

  /* === fixed header ngay dưới logo === */
  .main-header {
    position: fixed;
    top: var(--mobile-logo-h);
    left: 0;
    width: 100%;
    z-index: 10040;
    box-sizing: border-box;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
  }

  /* === fixed composer dưới đáy === */
  .composer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 10045;
    padding: 10px 12px;
  }

  .composer textarea {
    height: 44px;
    padding: 10px;
  }

  /* === chat-area scroll độc lập === */
  .chat-area {
    margin-top: calc(var(--mobile-logo-h) + 56px);
    padding: 14px;
    padding-bottom: 90px;
    height: calc(100vh - (var(--mobile-logo-h) + 56px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .messages {
    max-width: 100%;
    padding: 0 8px;
  }

  .msg {
    max-width: 90%;
  }

  /* hide sidebar */
  .sidebar {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    border: none !important;
  }
  .sidebar .logo-wrap,
  .sidebar .nav-list {
    display: none !important;
  }
}
