/* ==========================================================================
   Apple Human Interface Guidelines (HIG) Design System
   MyChatAgent Web Frontend
   ========================================================================== */

:root {
  /* Apple Dynamic Color Palette (Light Mode) */
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: rgba(255, 255, 255, 0.72);
  --bg-elevated: rgba(255, 255, 255, 0.85);
  --bg-sidebar: rgba(246, 246, 248, 0.82);
  
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --text-quaternary: #aeaeb2;
  
  --accent-color: #0071e3;
  --accent-color-hover: #0077ed;
  --accent-color-active: #0062c4;
  --accent-tint: rgba(0, 113, 227, 0.12);
  
  --bubble-user-bg: linear-gradient(135deg, #0071e3 0%, #0077ed 100%);
  --bubble-user-text: #ffffff;
  --bubble-ai-bg: rgba(255, 255, 255, 0.95);
  --bubble-ai-border: rgba(0, 0, 0, 0.06);
  --bubble-ai-text: #1d1d1f;
  
  --border-light: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.12);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur: blur(24px) saturate(180%);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.09), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-window: 0 24px 64px rgba(0, 0, 0, 0.14), 0 0 1px rgba(0, 0, 0, 0.2);
  
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;
  
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Mode Palette (macOS / iOS Dark Theme) */
[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #161618;
  --bg-tertiary: rgba(28, 28, 30, 0.75);
  --bg-elevated: rgba(36, 36, 38, 0.88);
  --bg-sidebar: rgba(22, 22, 24, 0.85);
  
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #86868b;
  --text-quaternary: #636366;
  
  --accent-color: #2997ff;
  --accent-color-hover: #40a9ff;
  --accent-color-active: #1482e6;
  --accent-tint: rgba(41, 151, 255, 0.18);
  
  --bubble-user-bg: linear-gradient(135deg, #0a84ff 0%, #0071e3 100%);
  --bubble-user-text: #ffffff;
  --bubble-ai-bg: rgba(36, 36, 38, 0.92);
  --bubble-ai-border: rgba(255, 255, 255, 0.08);
  --bubble-ai-text: #f5f5f7;
  
  --border-light: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --glass-border: rgba(255, 255, 255, 0.12);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.7);
  --shadow-window: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 1px rgba(255, 255, 255, 0.15);
}

/* Reset & Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-stack);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  user-select: none;
}

/* Application Container - macOS Window Frame */
.app-window {
  display: flex;
  width: 100vw;
  height: 100vh;
  background-color: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Sidebar (macOS Visual Effect View)
   ========================================================================== */
.app-sidebar {
  width: 290px;
  min-width: 290px;
  height: 100%;
  background: var(--bg-sidebar);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal), width var(--transition-normal);
  z-index: 10;
}

/* Window Traffic Lights */
.sidebar-header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.traffic-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  position: relative;
  transition: filter 0.15s ease;
}

.traffic-dot.close { background-color: #ff5f56; border: 1px solid #e0443e; }
.traffic-dot.minimize { background-color: #ffbd2e; border: 1px solid #dea123; }
.traffic-dot.zoom { background-color: #27c93f; border: 1px solid #1aab29; }

.traffic-dot:hover {
  filter: brightness(0.9);
}

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

.brand-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #0071e3 0%, #42a5f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.35);
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* New Chat Button */
.sidebar-action-wrap {
  padding: 8px 16px 14px;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.btn-new-chat:hover {
  background: var(--bg-elevated);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-medium);
}

.btn-new-chat:active {
  transform: translateY(0);
}

/* Session List (macOS List view) */
.session-list-section {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
}

.session-list-section::-webkit-scrollbar {
  width: 5px;
}
.session-list-section::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}
[data-theme="dark"] .session-list-section::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
  padding: 8px 12px 6px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background var(--transition-fast), color var(--transition-fast);
  position: relative;
}

.session-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}
[data-theme="dark"] .session-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.session-item.active {
  background: var(--accent-tint);
  color: var(--accent-color);
  font-weight: 600;
}

.session-item-content {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.session-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.8;
}

.session-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.session-delete-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.session-item:hover .session-delete-btn {
  opacity: 0.7;
}

.session-delete-btn:hover {
  opacity: 1 !important;
  color: #ff453a;
  background: rgba(255, 69, 58, 0.1);
}

/* Sidebar Footer / User Profile Card */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
  overflow: hidden;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.user-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-tag {
  font-size: 10.5px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.role-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 600;
  background: var(--border-medium);
  color: var(--text-secondary);
}

.role-badge.admin {
  background: rgba(255, 149, 0, 0.15);
  color: #ff9500;
}

.sidebar-settings-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-settings-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

/* ==========================================================================
   Main Chat Area (Apple Messages / Canvas)
   ========================================================================== */
.app-main {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  position: relative;
  overflow: hidden;
}

/* Top Navigation Bar */
.chat-navbar {
  height: 56px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-elevated);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 5;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.nav-sidebar-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.chat-header-info {
  display: flex;
  flex-direction: column;
}

.current-session-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.agent-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #34c759;
  box-shadow: 0 0 8px rgba(52, 199, 89, 0.6);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.nav-btn.primary {
  background: var(--accent-color);
  color: #ffffff;
  border-color: transparent;
}

.nav-btn.primary:hover {
  background: var(--accent-color-hover);
}

/* ==========================================================================
   Chat Messages Scroll Area
   ========================================================================== */
.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 140px;
  scroll-behavior: smooth;
  user-select: text;
}

.chat-scroll-area::-webkit-scrollbar {
  width: 6px;
}
.chat-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}
[data-theme="dark"] .chat-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

.messages-wrapper {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Empty State / Welcome Screen */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  max-width: 620px;
  margin: 0 auto;
  animation: appleFadeIn 0.6s var(--ease-spring);
}

.welcome-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #0071e3 0%, #68d8d6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 12px 28px rgba(0, 113, 227, 0.28);
  margin-bottom: 22px;
}

.welcome-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.welcome-subtitle {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 34px;
}

/* Apple Feature Cards / Prompts Grid */
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  width: 100%;
}

.prompt-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: var(--glass-blur);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
  box-shadow: var(--shadow-md);
  background: var(--bg-secondary);
}

.prompt-card-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.prompt-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.prompt-card-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* Message Item */
.message-row {
  display: flex;
  width: 100%;
  animation: appleSlideUp 0.3s var(--ease-spring);
}

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

.message-row.assistant {
  justify-content: flex-start;
}

.message-container {
  display: flex;
  gap: 12px;
  max-width: 82%;
}

.message-row.user .message-container {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 4px;
}

.message-avatar.user-av {
  background: linear-gradient(135deg, #0071e3, #42a5f5);
  color: white;
}

.message-avatar.ai-av {
  background: linear-gradient(135deg, #1d1d1f, #434344);
  color: white;
}

/* Chat Bubbles (Apple Messages Style) */
.message-bubble {
  padding: 12px 18px;
  border-radius: 20px;
  font-size: 14.5px;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.22);
}

.message-row.assistant .message-bubble {
  background: var(--bubble-ai-bg);
  color: var(--bubble-ai-text);
  border: 1px solid var(--bubble-ai-border);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow-sm);
}

.message-meta {
  font-size: 10.5px;
  color: var(--text-quaternary);
  margin-top: 4px;
  padding: 0 4px;
}

.message-row.user .message-meta {
  text-align: right;
}

/* Markdown Rendering Inside Assistant Bubble */
.message-bubble p {
  margin-bottom: 8px;
}
.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4 {
  margin-top: 14px;
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.message-bubble ul, .message-bubble ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble code {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .message-bubble code {
  background: rgba(255, 255, 255, 0.1);
}

.message-bubble pre {
  margin: 12px 0;
  border-radius: var(--radius-sm);
  background: #1e1e1e !important;
  color: #f8f8f2;
  overflow-x: auto;
  position: relative;
  font-family: var(--font-mono);
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message-bubble pre code {
  background: transparent;
  padding: 14px;
  display: block;
  overflow-x: auto;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #2d2d2d;
  font-size: 11px;
  color: #a0a0a0;
  border-top-left-radius: var(--radius-sm);
  border-top-right-radius: var(--radius-sm);
}

.btn-copy-code {
  background: transparent;
  border: none;
  color: #a0a0a0;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}

.btn-copy-code:hover {
  color: #ffffff;
}

/* Typing Indicator (iOS 3 Bouncing Dots) */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: appleBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

/* ==========================================================================
   Bottom Input Area (Apple Floating Pill Bar)
   ========================================================================== */
.chat-input-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 24px 24px;
  background: linear-gradient(180deg, transparent 0%, var(--bg-secondary) 30%);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.input-pill-wrapper {
  pointer-events: auto;
  max-width: 820px;
  width: 100%;
  background: var(--bg-elevated);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-end;
  padding: 8px 10px 8px 18px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-pill-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 12px 36px rgba(0, 113, 227, 0.16), 0 0 0 1px var(--accent-color);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-stack);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-primary);
  resize: none;
  max-height: 140px;
  min-height: 24px;
  padding: 6px 0;
  user-select: text;
}

.chat-textarea::placeholder {
  color: var(--text-quaternary);
}

.input-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 10px;
}

.btn-send-message {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.4);
}

.btn-send-message:disabled {
  background: var(--border-medium);
  color: var(--text-quaternary);
  cursor: not-allowed;
  box-shadow: none;
  transform: none !important;
}

.btn-send-message:not(:disabled):hover {
  background: var(--accent-color-hover);
  transform: scale(1.05);
}

.btn-send-message:not(:disabled):active {
  transform: scale(0.95);
}

/* ==========================================================================
   Modals & Sheets (Apple HIG Sheet Style)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 440px;
  max-width: 90vw;
  background: var(--bg-elevated);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-window);
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

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

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close-btn {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .modal-close-btn {
  background: rgba(255, 255, 255, 0.1);
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

/* Apple Segmented Control */
.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  position: relative;
}

[data-theme="dark"] .segmented-control {
  background: rgba(255, 255, 255, 0.08);
}

.segment-btn {
  flex: 1;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.segment-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Apple Styled Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.apple-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: all var(--transition-fast);
  user-select: text;
}

.apple-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.btn-block-action {
  width: 100%;
  padding: 11px;
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.28);
}

.btn-block-action:hover {
  background: var(--accent-color-hover);
}

.btn-block-action:active {
  transform: scale(0.99);
}

/* User Admin Table */
.admin-modal-card {
  width: 940px;
  max-width: 96vw;
  max-height: 90vh;
}

.admin-modal-card .modal-body {
  overflow-y: auto;
}

.admin-modal-subtitle {
  margin: 5px 0 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.admin-create-form {
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}

.admin-create-heading,
.admin-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-create-heading {
  margin-bottom: 12px;
}

.admin-create-heading strong,
.admin-list-heading strong {
  color: var(--text-primary);
  font-size: 13px;
}

.admin-create-heading span {
  color: var(--text-tertiary);
  font-size: 11.5px;
}

.admin-create-fields {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(190px, 1.25fr) 130px 112px;
  gap: 10px;
  align-items: center;
}

.admin-create-fields .apple-input,
.admin-create-button {
  margin: 0;
  min-height: 40px;
}

.admin-role-select,
.admin-inline-select {
  appearance: auto;
}

.admin-list-heading {
  margin: 0 2px 10px;
}

.admin-refresh-button,
.admin-action-button {
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 9px;
  transition: all var(--transition-fast);
}

.admin-refresh-button:hover,
.admin-action-button:hover:not(:disabled) {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.admin-action-button.danger {
  color: #ff453a;
}

.admin-action-button.success {
  color: #248a3d;
}

.admin-action-button:disabled,
.btn-block-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.admin-table-container {
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.admin-table {
  width: 100%;
  min-width: 790px;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.admin-table th {
  background: var(--bg-tertiary);
  padding: 10px 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.admin-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

.admin-table-message {
  padding: 24px !important;
  text-align: center;
  color: var(--text-tertiary) !important;
}

.admin-table-message.error {
  color: #ff453a !important;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 700;
}

.status-badge.enabled {
  background: rgba(52, 199, 89, 0.14);
  color: #248a3d;
}

.status-badge.disabled {
  background: rgba(255, 69, 58, 0.12);
  color: #ff453a;
}

.admin-inline-select {
  min-width: 92px;
  padding: 6px 8px;
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 11.5px;
}

.admin-row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

/* ==========================================================================
   Apple iOS Pill Toast Notification
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.apple-toast {
  padding: 10px 18px;
  border-radius: var(--radius-full);
  background: rgba(30, 30, 32, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  animation: toastPop 0.35s var(--ease-spring);
  pointer-events: auto;
}

.apple-toast.error {
  background: rgba(255, 59, 48, 0.92);
}

.apple-toast.success {
  background: rgba(52, 199, 89, 0.92);
}

/* Animations */
@keyframes appleFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes appleBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes toastPop {
  0% { transform: scale(0.8) translateY(-20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Responsive Mobile Layout */
@media (max-width: 768px) {
  .app-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  
  .app-sidebar.open {
    transform: translateX(0);
  }
  
  .chat-scroll-area {
    padding: 16px 16px 130px;
  }
  
  .message-container {
    max-width: 92%;
  }

  .admin-modal-card {
    max-height: 94vh;
  }

  .admin-modal-card .modal-body {
    padding: 16px;
  }

  .admin-create-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-create-fields {
    grid-template-columns: 1fr;
  }
}
