/* ==========================================================================
   NOTION & CHATGPT CLEAN WHITE THEME (NOTO SANS THAI)
   ========================================================================== */

:root {
  /* Notion & ChatGPT Palette */
  --bg-main: #ffffff;
  --bg-surface: #f7f7f8;
  --bg-card: #ffffff;
  --bg-hover: #efeff1;
  --bg-input: #f4f4f4;
  
  --border-light: #e5e5ea;
  --border-card: #e5e7eb;
  --border-focus: #0d0d0d;

  --text-primary: #0d0d0d;
  --text-body: #37352f;
  --text-muted: #737373;
  --text-subtle: #a1a1aa;

  --accent-black: #0d0d0d;
  --accent-hover: #262626;
  
  --success-green: #10a37f;
  --success-bg: #e6f6ee;
  
  /* Notion Pastel Badges */
  --badge-hazel-bg: #e0f2fe;
  --badge-hazel-text: #0369a1;
  --badge-ruby-bg: #fee2e2;
  --badge-ruby-text: #b91c1c;
  --badge-daisy-bg: #fef3c7;
  --badge-daisy-text: #b45309;
  --badge-luna-bg: #ede9fe;
  --badge-luna-text: #6d28d9;
  --badge-lyla-bg: #d1fae5;
  --badge-lyla-text: #047857;
  --badge-gray-bg: #f3f4f6;
  --badge-gray-text: #4b5563;

  /* Typography: Noto Sans Thai */
  --font-family: 'Noto Sans Thai', 'Noto Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   LOGIN SCREEN (Minimalist Notion Style)
   ========================================= */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background-color: var(--bg-surface);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  text-align: center;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--badge-gray-bg);
  color: var(--badge-gray-text);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 20px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--success-green);
  display: inline-block;
}

.auth-title {
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.input-group input:focus {
  background: var(--bg-main);
  border-color: var(--border-focus);
}

.auth-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fee2e2;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent-black);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: var(--bg-main);
  color: var(--text-body);
  border: 1px solid var(--border-light);
}
.btn-outline:hover {
  background: var(--bg-surface);
}

.btn-block {
  width: 100%;
  padding: 12px;
}

.btn-icon {
  padding: 8px;
  color: var(--text-muted);
}
.btn-icon:hover {
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* =========================================
   TOP NAV (Notion Clean Bar)
   ========================================= */
.app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-main);
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-black);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.brand-info h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

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

/* =========================================
   SEGMENTED TAB BAR (ChatGPT Style)
   ========================================= */
.tab-bar-wrapper {
  padding: 12px 20px 0 20px;
  background: var(--bg-main);
}

.tab-bar {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
  max-width: 380px;
  width: 100%;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--bg-main);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-black);
  color: #ffffff;
}

/* =========================================
   TAB CONTENT
   ========================================= */
.tab-content {
  display: none;
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.tab-content.active {
  display: block;
}

/* =========================================
   STAT GRID (Notion Minimal)
   ========================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-main);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.stat-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.stat-value.text-success {
  color: var(--success-green);
}
.stat-sub {
  font-size: 0.72rem;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* =========================================
   DASHBOARD CARDS (Clean White Notion Style)
   ========================================= */
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-card {
  background: var(--bg-main);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-left h3 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Notion Badges */
.badge-hazel { background: var(--badge-hazel-bg); color: var(--badge-hazel-text); }
.badge-ruby { background: var(--badge-ruby-bg); color: var(--badge-ruby-text); }
.badge-daisy { background: var(--badge-daisy-bg); color: var(--badge-daisy-text); }
.badge-luna { background: var(--badge-luna-bg); color: var(--badge-luna-text); }
.badge-lyla { background: var(--badge-lyla-bg); color: var(--badge-lyla-text); }
.badge-leo { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-gray { background: var(--badge-gray-bg); color: var(--badge-gray-text); }

.status-chip {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
}
.status-chip.chip-live {
  color: var(--success-green);
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.card-body {
  padding: 16px 18px;
}

/* TASKS LIST */
.task-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f2f2f4;
}
.task-item:last-child {
  border-bottom: none;
}
.task-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}
.task-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.task-priority {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.priority-high { background: #fee2e2; color: #b91c1c; }
.priority-normal { background: #f3f4f6; color: #4b5563; }

/* PAGES LIST */
.page-status-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.page-row {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.page-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.page-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
}
.tag-palaed { background: #fee2e2; color: #b91c1c; }
.tag-sab { background: #fef3c7; color: #b45309; }
.tag-kuay { background: #ede9fe; color: #6d28d9; }

.page-time {
  font-size: 0.72rem;
  color: var(--text-subtle);
}
.page-caption {
  font-size: 0.86rem;
  color: var(--text-body);
  line-height: 1.5;
}

/* LOGS CONTAINER */
.log-container {
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.log-entry {
  padding: 6px 0;
  border-bottom: 1px solid #f2f2f4;
  display: flex;
  gap: 8px;
}
.log-time { color: var(--text-subtle); white-space: nowrap; font-size: 0.75rem; }
.log-action { color: #0284c7; font-weight: 600; white-space: nowrap; }
.log-text { color: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* HEALTH */
.health-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-body);
}
.dot.green {
  width: 7px;
  height: 7px;
  background: var(--success-green);
  border-radius: 50%;
}

.analytics-metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.85rem;
}
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #f2f2f4;
}
.metric-row:last-child {
  border-bottom: none;
}

/* =========================================
   CHAT ROOM VIEW (ChatGPT Minimal Style)
   ========================================= */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 150px);
  background: var(--bg-main);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-tag-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  white-space: nowrap;
}

.tag-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.tag-chips {
  display: flex;
  gap: 6px;
}

.chip {
  padding: 4px 10px;
  font-family: var(--font-family);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
  background: var(--bg-main);
  color: var(--text-body);
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover {
  background: var(--bg-surface);
  border-color: var(--border-focus);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.system-welcome-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-bottom: 8px;
}
.system-welcome-card h4 {
  font-size: 0.92rem;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 600;
}
.system-welcome-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.system-welcome-card code {
  background: #e5e5ea;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.8rem;
}

.chat-row {
  display: flex;
  width: 100%;
  margin-bottom: 4px;
}

.chat-row.assistant {
  align-items: flex-start;
  gap: 10px;
}

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

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.message-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* User Message (ChatGPT Gray Pill) */
.message-bubble.user {
  background: var(--bg-input);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

/* Assistant Message (Clean White Card) */
.message-bubble.assistant {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-subtle);
}

.msg-sender {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.msg-sender.hazel { color: #0284c7; }
.msg-sender.sasha { color: #db2777; }
.msg-sender.ruby { color: #dc2626; }
.msg-sender.daisy { color: #d97706; }
.msg-sender.luna { color: #7c3aed; }
.msg-sender.lyla { color: #059669; }
.msg-sender.leo { color: #10b981; font-weight: 700; }

.chip.chip-leo {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
  font-weight: 600;
}
.chip.chip-leo:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

/* Leo Portfolio Banner & Cards */
.portfolio-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
}
.portfolio-stat {
  display: flex;
  flex-direction: column;
}
.p-label {
  font-size: 0.75rem;
  color: #166534;
  font-weight: 500;
}
.p-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: #14532d;
}
.leo-features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 600px) {
  .leo-features-grid {
    grid-template-columns: 1fr;
  }
}
.leo-feature-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.lf-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.lf-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.lf-desc code {
  background: var(--bg-card);
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  font-family: monospace;
}

/* ChatGPT Pill Input Bar */
.chat-input-bar {
  padding: 12px 18px;
  background: var(--bg-main);
  border-top: 1px solid var(--border-light);
}

.chat-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  padding: 4px 6px 4px 16px;
  transition: all 0.2s ease;
}

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

.chat-input-box input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-family);
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  padding: 8px 0;
}

.btn-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-black);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

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

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* =========================================
   RESPONSIVE DESIGN (MOBILE)
   ========================================= */
@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .tab-content {
    padding: 14px 10px;
  }
  .tab-bar-wrapper {
    padding: 10px 10px 0 10px;
  }
  .chat-wrapper {
    height: calc(100vh - 128px);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
