/* ==========================================================================
   ĐẠI CHÚNG PROPERTIES — APPLE MINIMALIST DESIGN SYSTEM
   ========================================================================== */

:root {
  --font-apple: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Plus Jakarta Sans", "Inter", sans-serif;
  --bg-app: #fbfbfd;
  --bg-card: #ffffff;
  --bg-subtle: #f5f5f7;
  --bg-user-msg: #f3f0ff;
  
  --primary-navy: #1e1b4b;
  --primary-indigo: #2563eb;
  --accent-purple: #6366f1;
  --text-main: #1d1d1f;
  --text-muted: #86868b;
  --border-light: #e5e5ea;
  --border-subtle: #f2f2f7;
  
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.03);
  --shadow-dock: 0 8px 30px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  font-family: var(--font-apple);
  background: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-root-container {
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   TOP HEADER (APPLE CLEAN BAR)
   ========================================================================== */
.app-header {
  height: 60px;
  min-height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-light);
  z-index: 100;
  flex-shrink: 0;
}

.header-inner {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-monogram {
  width: 36px;
  height: 36px;
  background: #1e293b;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.brand-monogram span {
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text h1 {
  font-size: 0.98rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

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

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
}

.pill-btn:hover, .pill-btn:active {
  background: #f3f4f6;
  border-color: #d1d5db;
  transform: translateY(-1px);
}

.highlight-pill {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #5b21b6;
}

.icon-circle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.icon-circle-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* ==========================================================================
   MAIN CHAT LAYOUT
   ========================================================================== */
.chat-main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-app);
}

.chat-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 16px;
}

.chat-category-tag {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 16px 4px 8px;
  text-transform: uppercase;
}

.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   HERO ASSISTANT CARD (APPLE STYLE)
   ========================================================================== */
.hero-assistant-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 4px;
}

.hero-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.assistant-avatar-outline {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 50%;
  background: #f5f3ff;
  border: 1.5px solid #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-greeting-text h2 {
  font-size: 1.18rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.hero-greeting-text p {
  font-size: 0.92rem;
  color: #475569;
  line-height: 1.45;
}

.hero-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.hero-quick-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.hero-quick-btn:hover, .hero-quick-btn:active {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.quick-icon {
  font-size: 1.25rem;
}

.quick-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.3;
}

/* ==========================================================================
   CHAT MESSAGES (APPLE iMESSAGE STYLE)
   ========================================================================== */
.chat-msg {
  display: flex;
  width: 100%;
  animation: msgPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.chat-msg.user {
  justify-content: flex-end;
}

.chat-msg.user .msg-content-wrap {
  background: #ede9fe;
  color: #1e1b4b;
  border-radius: var(--radius-lg);
  border-bottom-right-radius: 4px;
  padding: 12px 16px;
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg.user .msg-text {
  font-size: 0.95rem;
  line-height: 1.5;
  font-weight: 500;
}

.chat-msg.user .msg-meta-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: #7c3aed;
  opacity: 0.85;
}

/* Bot Message Card */
.chat-msg.bot {
  justify-content: flex-start;
}

.chat-msg.bot .msg-card-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  max-width: 92%;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bot-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bot-avatar-mini {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: #f5f3ff;
  border: 1px solid #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bot-title-head h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.bot-title-head p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.bot-body-text {
  font-size: 0.92rem;
  line-height: 1.62;
  color: #334155;
}

.bot-body-text strong {
  color: #0f172a;
  font-weight: 700;
}

.bot-body-text p {
  margin-bottom: 8px;
}

.bot-body-text ul, .bot-body-text ol {
  margin: 8px 0 8px 18px;
}

.bot-body-text li {
  margin-bottom: 4px;
}

.bot-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.action-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #4338ca;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.bot-speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bot-speak-btn.speaking {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a5b4fc;
  animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* ==========================================================================
   BOTTOM FLOATING DOCK (APPLE STYLE)
   ========================================================================== */
.bottom-floating-dock {
  width: calc(100% - 32px);
  max-width: 648px;
  margin: 0 auto 10px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-dock);
  padding: 8px 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  z-index: 50;
  flex-shrink: 0;
}

.dock-tab-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.dock-tab-btn:active {
  transform: scale(0.96);
}

.dock-icon-box {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.dock-icon-box.active-icon {
  background: #1e1b4b;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(30, 27, 75, 0.25);
}

.dock-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
  text-align: center;
  line-height: 1.2;
}

.dock-tab-btn.active .dock-label {
  color: #1e1b4b;
  font-weight: 700;
}

/* ==========================================================================
   CHAT INPUT BAR
   ========================================================================== */
.app-chat-footer {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px calc(12px + env(safe-area-inset-bottom));
  flex-shrink: 0;
  z-index: 50;
}

.chat-input-wrapper {
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 6px 8px 6px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease;
}

.chat-input-wrapper:focus-within {
  border-color: #6366f1;
}

.chat-textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-apple);
  font-size: 0.92rem;
  color: var(--text-main);
  outline: none;
  resize: none;
  max-height: 100px;
  padding: 6px 0;
}

.chat-textarea::placeholder {
  color: #94a3b8;
}

.chat-voice-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-voice-btn.listening {
  background: #fee2e2;
  color: #dc2626;
  animation: pulse 1s infinite alternate;
}

.chat-send-action-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-send-action-btn:hover, .chat-send-action-btn:active {
  background: #1d4ed8;
  transform: scale(1.05);
}

/* ==========================================================================
   MODAL SHEET (APPLE STYLE)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 999;
}

.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 540px;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.modal-title p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #64748b;
  cursor: pointer;
}

.personality-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.personality-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.personality-item.active {
  background: #f5f3ff;
  border-color: #8b5cf6;
}

.personality-item .p-icon {
  font-size: 1.6rem;
}

.personality-item strong {
  display: block;
  font-size: 0.95rem;
  color: #0f172a;
  margin-bottom: 2px;
}

.personality-item p {
  font-size: 0.82rem;
  color: #64748b;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}

.toast-msg {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: toastIn 0.2s ease;
}

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

/* Mobile responsive */
@media (max-width: 480px) {
  .hero-quick-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .hero-quick-btn {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
  }
  .quick-title {
    font-size: 0.85rem;
  }
}
