/* 右侧 Drawer 面板样式 */

.right-drawer {
  position: fixed;
  top: 0;
  right: -450px; /* 初始隐藏在右侧外 */
  width: 450px;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 999;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.right-drawer.open {
  right: 0;
}

/* Drawer Header */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.drawer-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 999px;
}

.drawer-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.2s;
  position: relative;
  flex: 1;
  justify-content: center;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.drawer-tab:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
}

.drawer-tab.active {
  background: white;
  color: var(--color-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.drawer-tab .tab-icon {
  font-size: 16px;
}

.drawer-tab .tab-label {
  font-weight: 600;
}

.drawer-tab .tab-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--color-primary);
  color: white;
  border-radius: 999px;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-tab.active .tab-badge {
  background: var(--color-primary);
  color: white;
}

.drawer-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Drawer Content */
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.drawer-tab-content {
  display: none;
}

.drawer-tab-content.active {
  display: block;
}

/* Section Styles */
.permission-section,
.todo-section {
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.section-header:hover {
  background: var(--bg-hover);
}

.section-header.collapsible .section-arrow {
  margin-left: auto;
  transition: transform 0.2s;
}

.section-header.collapsed .section-arrow {
  transform: rotate(-90deg);
}

.section-icon {
  font-size: 16px;
}

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

.section-count {
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: var(--color-primary);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-arrow {
  color: var(--text-secondary);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.section-arrow svg {
  width: 12px;
  height: 12px;
}

.section-body {
  margin-top: 8px;
  display: block;
}

.section-body.collapsed {
  display: none;
}

/* Permission Item */
.permission-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.permission-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}

.permission-item.expired {
  opacity: 0.6;
}

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

.permission-tool {
  font-weight: 600;
  color: var(--color-primary);
  font-size: 14px;
}

.permission-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.permission-input {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 12px;
  color: var(--text-primary);
  max-height: 100px;
  overflow-y: auto;
  word-break: break-all;
}

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

.permission-btn {
  flex: 1;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.permission-btn-approve {
  background: var(--color-primary);
  color: white;
}

.permission-btn-approve:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.permission-btn-deny {
  background: var(--purple-light);
  color: var(--color-primary);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.permission-btn-deny:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.permission-btn-session {
  background: var(--purple-light);
  color: var(--color-primary);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.permission-btn-session:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.permission-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.permission-countdown {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 4px;
}

.permission-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.permission-status.approved {
  background: #d1fae5;
  color: #065f46;
}

.permission-status.denied {
  background: #fee2e2;
  color: #991b1b;
}

.permission-status.expired {
  background: #fef3c7;
  color: #92400e;
}

.permission-warning {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.permission-item.outside-workdir {
  border-color: #fbbf24;
  background: rgba(254, 243, 199, 0.1);
}

/* Question Item (AskUserQuestion) */
.question-item-card {
  border-color: #8b5cf6;
}

.questions-container {
  margin: 12px 0;
}

.question-item {
  margin-bottom: 16px;
}

.question-header {
  display: inline-block;
  padding: 2px 8px;
  background: #ede9fe;
  color: #6b21a8;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
}

.question-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.question-option:hover {
  border-color: var(--color-primary);
  background: var(--purple-light);
}

.question-option input[type="radio"],
.question-option input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
}

.question-option-content {
  flex: 1;
}

.question-option-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.question-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.question-option-other .question-other-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  margin-top: 6px;
  transition: all 0.2s;
}

.question-option-other .question-other-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.question-option-other .question-other-input:disabled {
  background: var(--bg-secondary);
  cursor: not-allowed;
}

/* Todo Item */
.todo-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.todo-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.todo-content {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.5;
}

.todo-active-form {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.todo-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  margin-top: 4px;
}

.todo-status-badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.todo-status-badge.in_progress {
  background: #dbeafe;
  color: #1e40af;
}

.todo-status-badge.completed {
  background: #d1fae5;
  color: #065f46;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state-icon svg {
  width: 48px;
  height: 48px;
}

.empty-state-text {
  font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  .right-drawer {
    width: 100%;
    right: -100%;
  }

  .right-drawer.open {
    right: 0;
  }
}

/* Diff 预览样式 (Edit 工具) */
.permission-file-path {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-bottom: 12px;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  color: var(--text-primary);
}

.permission-file-path-icon {
  font-size: 16px;
}

.permission-diff-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary);
}

.permission-diff-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
}

.permission-diff-content {
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-tertiary, #fafafa);
}

.diff-line {
  display: block;
  padding: 2px 8px;
  margin: 1px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-line-removed {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}

.diff-line-added {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
}

.diff-line-truncated {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 6px 8px;
}

/* 改进 permission-input 样式 */
.permission-input {
  margin: 8px 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  overflow: hidden;
}

.permission-input pre {
  margin: 0;
  padding: 12px;
  background: var(--bg-tertiary, #fafafa);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

/* ==================== 授权管理样式 ==================== */

.allowed-intro {
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin: 12px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-left: 3px solid var(--color-primary);
}

.allowed-intro p {
  margin: 0;
}

.allowed-section {
  margin-bottom: 16px;
}

.allowed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.allowed-item:hover {
  background: var(--bg-hover);
}

.allowed-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.allowed-item-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.allowed-item-icon svg {
  width: 16px;
  height: 16px;
}

.allowed-item-name {
  font-size: 13px;
  color: var(--text-primary);
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

/* Toggle Switch 开关样式 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--color-primary, #7c3aed);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
