:root {
  --bg-app: #f4f5f7;
  --bg-sidebar: #f8f9fb;
  --bg-surface: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --brand-blue: #1075a8;
  --brand-blue-hover: #1075a8;
  --brand-blue-light: #e6f0fd;
  --success-green: #22c55e;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button,
input {
  font-family: inherit;
}

a {
  color: var(--brand-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Layout */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-top {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  background-color: var(--brand-blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-blue);
}

.brand-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.sidebar-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 8px 0;
}

.quick-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sample-question {
  text-align: left;
  background: none;
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sample-question:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.sample-question.active {
  background-color: var(--brand-blue-light);
  color: var(--brand-blue);
  border-color: rgba(29, 116, 245, 0.2);
  font-weight: 500;
}

.sidebar-bottom {
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.sidebar-action:hover {
  background-color: rgba(0, 0, 0, 0.03);
  color: var(--text-main);
}

.made-with {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 16px;
  padding-left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.visily-logo {
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Main Area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Important for flex children to not overflow */
}

/* Header */
.main-header {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

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

.mobile-menu-btn {
  display: none;
}

.header-titles h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.header-titles p {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

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

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background-color: #f0fdf4;
  color: var(--brand-blue);
  border: 1px solid #dcfce7;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill svg {
  color: var(--success-green);
}

.status-pill.error {
  background-color: #fef2f2;
  color: #ef4444;
  border-color: #fee2e2;
}

.status-pill.error svg {
  color: #ef4444;
}

.header-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 6px;
  transition: all 0.2s;
}

.icon-btn:hover {
  background-color: var(--bg-app);
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 8px;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
}

.user-role {
  font-size: 12px;
  color: var(--text-muted);
}

.user-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
}

.user-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-small {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.online-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background-color: var(--success-green);
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 24px;
  padding-right: 12px;
}

/* Custom Scrollbar for messages */
.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 850px;
  margin: 0 auto;
  width: 100%;
  gap: 8px;
}

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

.message.bot .message-meta {
  justify-content: flex-start;
  margin-left: 12px;
}

.message.user .message-meta {
  justify-content: flex-end;
  margin-right: 12px;
}

.avatar {
  width: 28px;
  height: 28px;
  background-color: var(--brand-blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.sender-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.time {
  font-size: 11px;
  color: var(--text-light);
}

.bubble {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}

.message.user .bubble {
  background-color: var(--brand-blue);
  color: white;
  border-color: var(--brand-blue);
  border-radius: 12px 12px 0 12px;
  align-self: flex-end;
}

.message.bot .bubble {
  border-radius: 12px 12px 12px 0;
  align-self: flex-start;
}

/* Table styling inside bubble */
.bubble.table-bubble {
  padding: 0;
  overflow: hidden;
  max-width: 100%;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.table-title h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.table-title p {
  font-size: 12px;
  color: var(--text-muted);
}

.table-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background-color: var(--bg-app);
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 12px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table th {
  background-color: #fafbfc;
  color: var(--text-muted);
  font-weight: 600;
}

.text-right {
  text-align: right !important;
}

.table-footer {
  padding: 12px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  background-color: #fafbfc;
  border-top: 1px dashed var(--border-color);
}

.date-separator {
  text-align: center;
  margin: 16px 0;
  position: relative;
}

.date-separator::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: var(--border-color);
  z-index: 1;
}

.date-separator span {
  background-color: var(--bg-app);
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 2;
}

/* Composer */
.composer-container {
  max-width: 850px;
  margin: 0 auto;
  width: 100%;
  padding-top: 16px;
}

.composer {
  display: flex;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 8px 8px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.composer input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-main);
  background: transparent;
}

.composer input::placeholder {
  color: var(--text-light);
}

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

.vertical-divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-color);
  margin: 0 4px;
}

.text-muted {
  color: var(--text-muted);
}

.send-btn {
  background-color: var(--bg-sidebar);
  color: var(--text-main);
  padding: 8px;
}

.send-btn:hover {
  background-color: var(--border-color);
}

.composer-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 12px;
}

.composer-hint .dot {
  margin: 0 6px;
}

/* Responsiveness */
@media (max-width: 900px) {
  .sidebar {
    position: absolute;
    transform: translateX(-100%);
    z-index: 10;
    height: 100%;
    transition: transform 0.3s;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .header-titles p {
    display: none;
  }

  .user-info {
    display: none;
  }
}