.ai-hub-card {
  padding: 24px 26px;
}

.ai-hub-fullwidth {
  margin-top: 24px;
}

.ai-hub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.card-title {
  font-size: 1.22rem;
  font-weight: 800;
}

.ai-status-badge {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.ai-hint {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* BỐ CỤC WORKSPACE 2 CỘT CHUẨN GEMINI / CHATGPT */
.ai-chat-workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  position: relative;
}

.ai-chat-workspace.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.ai-chat-workspace.sidebar-collapsed .ai-chat-sidebar {
  display: none;
}

.ai-chat-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 12px;
  height: 550px;
}

.ai-sidebar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-new-chat-full {
  flex: 1;
  justify-content: center;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.86rem;
}

.ai-sidebar-close-mobile {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.ai-sidebar-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 8px;
}

.ai-popover-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.ai-filter-btn {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.ai-filter-btn.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: var(--accent);
}

.ai-thread-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

.ai-thread-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  transition: background-color 0.15s ease;
}

.ai-thread-row:hover,
.ai-thread-row.active,
.ai-thread-row.menu-open {
  background: #e2e8f0;
}

.ai-thread-select-area {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 4px 0;
}

.ai-thread-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 600;
}

.ai-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.ai-thread-dots-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-thread-dots-btn:hover {
  background: rgba(15, 23, 42, 0.08);
}

.ai-rename-input {
  width: 100%;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.ai-thread-empty {
  padding: 18px 10px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* MENU NỔI 3 CHẤM KHÔNG BAO GIỜ BỊ CẮT */
.ai-floating-ctx-menu {
  position: fixed;
  width: 236px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 7px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-ctx-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.ai-ctx-item:hover {
  background: #f1f5f9;
}

.ai-ctx-item.danger {
  color: #e11d48;
}

.ai-ctx-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 4px 6px;
}

/* CỘT PHẢI: KHUNG CHAT CHÍNH */
.ai-chat-main-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ai-chat-main-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.ai-toggle-sidebar-btn {
  flex-shrink: 0;
  padding: 6px 11px;
  font-size: 0.82rem;
}

.ai-unread-count {
  background: var(--accent);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

.ai-active-thread-heading {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-sync-tag {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.ai-sync-tag.cloud {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #99f6e4;
}

.chat-messages {
  height: 450px;
  overflow-y: auto;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-row {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

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

.chat-row.bot {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-sender {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
  padding: 0 4px;
}

.chat-bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble.bot {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  border-bottom-right-radius: 4px;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.18);
}

.schedule-draft {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.draft-details {
  font-size: 0.88rem;
  color: var(--text-primary);
  margin-top: 2px;
}

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

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat-input {
  flex: 1;
  min-height: 54px;
  max-height: 220px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-page);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.chat-input:focus {
  border-color: var(--accent);
  background: #ffffff;
}

/* RESPONSIVE MOBILE: SIDEBAR TRỞ THÀNH DRAWER DỄ BẤM */
@media (max-width: 820px) {
  .ai-chat-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-chat-sidebar {
    display: none !important;
  }

  .ai-chat-sidebar.mobile-open {
    display: flex !important;
    position: fixed;
    top: 68px;
    left: 12px;
    right: 12px;
    bottom: 16px;
    max-height: calc(100dvh - 84px);
    height: auto;
    z-index: 950;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  }

  .ai-sidebar-close-mobile {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-hover);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
  }
}

/* GOOGLE CALENDAR SECTION */
.calendar-section-card {
  margin-top: 24px;
  padding: 28px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.calendar-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.calendar-user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.user-info-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

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

.calendar-events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.calendar-empty-state {
  grid-column: 1 / -1;
  padding: 22px;
  text-align: center;
  background: var(--bg-page);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.92rem;
}
