/* Tanka Design System - Shared Styles */
:root {
  --primary: #006DFF;
  --primary-hover: #3289FE;
  --primary-pressed: #035FDB;
  --primary-bg: rgba(0, 94, 255, 0.05);
  --text-primary: #020617;
  --text-secondary: #8794A6;
  --text-tertiary: #ACB4BF;
  --text-danger: #FF606A;
  --bg-primary: #F3F4F6;
  --bg-white: #FFFFFF;
  --bg-hover: #F5F6F8;
  --border-light: #F3F4F6;
  --border-line: #E7E9ED;
  --success: #10B35B;
  --warning: #FFBB20;
  --danger: #FF606A;
  --sidebar-width: 65px;
  --sidebar-bg: #FAFBFC;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
}

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

body {
  font-family: "SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.4;
}

/* Left Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  z-index: 100;
}
.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px;
  border-radius: 8px;
  cursor: pointer;
  width: 56px;
  text-align: center;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  text-decoration: none;
}
.sidebar-item:hover { background: rgba(15, 41, 77, 0.05); }
.sidebar-item.active {
  background: rgba(15, 41, 77, 0.1);
  color: var(--text-primary);
}
.sidebar-item .icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.sidebar-spacer { flex: 1; }
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #C4C4C4;
  margin-top: 8px;
}

/* Main Layout */
.main-content {
  margin-left: var(--sidebar-width);
  height: 100vh;
  display: flex;
}

/* Chat List Panel */
.chat-list {
  width: 280px;
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
}
.chat-list-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 18px;
  font-weight: 600;
}
.chat-list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
}
.chat-list-item:hover { background: var(--bg-hover); }
.chat-list-item.active { background: var(--primary-bg); }
.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  font-weight: 600;
}
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
}
.chat-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-light);
}
.chat-header-title {
  font-size: 16px;
  font-weight: 600;
}
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}
.chat-input-area {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border-light);
}
.chat-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: 15px;
  outline: none;
  background: var(--bg-white);
}
.chat-input:focus { border-color: var(--primary); }

/* Message Bubbles */
.message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  font-weight: 600;
}
.message-body { max-width: 480px; }
.message-sender {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.message-bubble {
  padding: 10px 14px;
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg-primary);
}

/* Bot Badge */
.bot-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: var(--primary);
  color: white;
  text-transform: uppercase;
}

/* Right Panel (Group Info / Settings) */
.right-panel {
  width: 300px;
  background: var(--bg-white);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.right-panel-header {
  display: flex;
  padding: 0;
  border-bottom: 1px solid var(--border-light);
}
.right-panel-tab {
  flex: 1;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
}
.right-panel-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

/* Settings List Items */
.settings-list { padding: 0; }
.settings-item {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.settings-item:hover { background: var(--bg-hover); }
.settings-item .item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
}
.settings-item .item-label { flex: 1; font-size: 15px; }
.settings-item .item-chevron {
  color: var(--text-tertiary);
  font-size: 14px;
}
.settings-item .item-value {
  font-size: 13px;
  color: var(--text-secondary);
}
.settings-item.danger .item-label { color: var(--text-danger); }

/* Section Header */
.section-header {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 16px 20px 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Buttons */
.btn {
  height: 40px;
  padding: 0 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
}
.btn-secondary:hover { background: var(--border-line); }
.btn-danger {
  background: transparent;
  color: var(--text-danger);
  border: 1px solid var(--text-danger);
}
.btn-danger:hover { background: rgba(255, 96, 106, 0.05); }
.btn-sm { height: 32px; padding: 0 16px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-ghost {
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover { background: var(--primary-bg); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-primary);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.modal-close:hover { background: var(--border-line); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 12px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Form Elements */
.form-group { margin-bottom: 16px; }
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}
.form-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  background: var(--bg-white);
}
.form-input:focus { border-color: var(--primary); }
.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Copy Field */
.copy-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.copy-field code {
  flex: 1;
  font-family: "SF Mono", Monaco, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--text-primary);
}
.copy-btn {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--border-line);
  background: var(--bg-white);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-primary);
}
.copy-btn:hover { background: var(--bg-hover); }

/* Bot List Item */
.bot-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
}
.bot-list-item:hover { background: var(--bg-hover); }
.bot-list-item .bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}
.bot-list-item .bot-info { flex: 1; }
.bot-list-item .bot-name {
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bot-list-item .bot-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Option Card (for modal selections) */
.option-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 0.15s;
}
.option-card:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.option-card .option-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.option-card .option-info { flex: 1; }
.option-card .option-title {
  font-size: 15px;
  font-weight: 500;
}
.option-card .option-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.option-card .option-arrow { color: var(--text-tertiary); }

/* Settings Page (full page) */
.settings-page {
  margin-left: var(--sidebar-width);
  height: 100vh;
  display: flex;
}
.settings-page-content {
  width: 560px;
  margin: 0;
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
}
.settings-page-header {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-size: 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-light);
}
.settings-page-item {
  display: flex;
  align-items: center;
  height: 72px;
  padding: 0 24px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
}
.settings-page-item:hover { background: var(--bg-hover); }
.settings-page-item .spi-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 20px;
}
.settings-page-item .spi-label {
  flex: 1;
  font-size: 16px;
}
.settings-page-item .spi-chevron {
  color: var(--text-tertiary);
}
.settings-page-item.active-highlight {
  background: rgba(0, 109, 255, 0.04);
}
.settings-page-item.danger .spi-label {
  color: var(--text-danger);
}

/* Plan Banner */
.plan-banner {
  margin: 16px 24px;
  padding: 16px 20px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
}
.plan-banner-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.plan-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--text-primary);
  color: white;
}
.plan-banner-info {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}
.plan-banner-info .value {
  font-weight: 600;
  font-style: italic;
  color: var(--text-primary);
}

/* Detail Page */
.detail-page {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  background: var(--bg-white);
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.detail-back {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-primary);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.detail-back:hover { background: var(--border-line); }
.detail-title {
  font-size: 20px;
  font-weight: 600;
}
.detail-section {
  margin-bottom: 28px;
}
.detail-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Scope Checkboxes */
.scope-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.scope-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.scope-item input[type="checkbox"] {
  accent-color: var(--primary);
}
.scope-item label {
  font-size: 13px;
  font-family: "SF Mono", Monaco, Menlo, monospace;
  cursor: pointer;
}
.scope-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
}

/* App Card in list */
.app-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}
.app-card:hover { background: var(--bg-hover); }
.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}
.app-info { flex: 1; }
.app-name { font-size: 15px; font-weight: 500; }
.app-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.app-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.app-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.app-status.active .dot { background: var(--success); }
.app-status.active { color: var(--success); }

/* OAuth Page */
.oauth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}
.oauth-card {
  width: 420px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  text-align: center;
}
.oauth-app-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: white;
}
.oauth-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}
.oauth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.oauth-scopes {
  text-align: left;
  margin-bottom: 24px;
}
.oauth-scopes-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.oauth-scope-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 14px;
}
.oauth-scope-item .scope-icon { color: var(--primary); }
.oauth-actions {
  display: flex;
  gap: 10px;
}
.oauth-actions .btn { flex: 1; height: 44px; font-size: 15px; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  padding: 0 24px;
}
.tab {
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}
.tab:hover:not(.active) { color: var(--text-primary); }

/* App Settings Layout (Slack-style sidebar) */
.app-settings {
  margin-left: var(--sidebar-width);
  height: 100vh;
  display: flex;
}
.app-settings-sidebar {
  width: 220px;
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  padding: 16px 0;
  flex-shrink: 0;
}
.app-settings-sidebar .app-name {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 16px;
  font-size: 14px;
  font-weight: 600;
}
.app-settings-sidebar .app-name .app-dot {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--primary);
}
.app-settings-sidebar .menu-section {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 16px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.app-settings-sidebar .menu-item {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.app-settings-sidebar .menu-item:hover {
  background: var(--bg-hover);
}
.app-settings-sidebar .menu-item.active {
  background: var(--primary);
  color: white;
  border-radius: 0;
  border-left: 3px solid var(--primary);
}
.app-settings-sidebar .menu-item .tag {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 6px;
  font-weight: 600;
}
.app-settings-sidebar .menu-item .tag-new {
  background: #10B35B;
  color: white;
}
.app-settings-sidebar .menu-item .tag-legacy {
  background: var(--border-line);
  color: var(--text-secondary);
}
.app-settings-content {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
  background: var(--bg-white);
}
.app-settings-content h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
}
.app-settings-content .field-group {
  margin-bottom: 20px;
}
.app-settings-content .field-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.app-settings-content .field-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.app-settings-content .field-value {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", Monaco, Menlo, monospace;
  font-size: 13px;
}
.app-settings-content .field-value .show-btn {
  margin-left: auto;
  padding: 2px 10px;
  border: 1px solid var(--border-line);
  border-radius: 4px;
  background: var(--bg-white);
  font-size: 12px;
  cursor: pointer;
}
.app-settings-content .toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.toggle-switch {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #10B35B;
  position: relative;
  cursor: pointer;
}
.toggle-switch::after {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 2px;
  right: 2px;
}
.toggle-switch.off {
  background: var(--border-line);
}
.toggle-switch.off::after {
  right: auto;
  left: 2px;
}
.app-settings-content .info-box {
  padding: 14px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.app-settings-content .scope-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0;
}
.app-settings-content .scope-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-line);
  font-weight: 500;
}
.app-settings-content .scope-table td {
  padding: 8px 12px;
  border: 1px solid var(--border-line);
}
.app-settings-content .event-tag {
  display: inline-flex;
  padding: 4px 10px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  font-size: 12px;
  margin: 2px 4px 2px 0;
}
.app-settings-content .webhook-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  font-family: "SF Mono", Monaco, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}
.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #10B35B;
  font-size: 13px;
  font-weight: 500;
}

/* Utility */
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--text-danger); }
.text-sm { font-size: 13px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
