/* Agent Card (목록) */
.agent-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.agent-card:hover {
  background: var(--bg-hover);
  box-shadow: var(--shadow-sm);
}

.agent-card:active {
  transform: scale(0.99);
}

.agent-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.agent-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-shrink: 0;
}

.agent-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-card-info {
  min-width: 0;
}

.agent-card-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.agent-card-role {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.agent-card-docs {
  font-size: 12px;
  color: var(--text-muted);
}

/* Agent Detail */
.agent-detail {
  padding: 0;
}

.agent-detail-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-bottom: 16px;
}

.agent-detail-back:hover {
  text-decoration: underline;
}

/* 틴더 스타일 프로필 카드 */
.agent-profile-card {
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-secondary);
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.agent-profile-avatar {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 360px;
  overflow: hidden;
  background: var(--bg-tertiary, var(--bg-secondary));
}

.agent-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-profile-avatar:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--text-muted);
}

.agent-profile-info {
  padding: 16px 20px;
}

.agent-profile-name {
  font-size: 22px;
  font-weight: 700;
}

.agent-profile-role {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.agent-detail-loading {
  color: var(--text-muted);
  padding: 8px 0;
}

.agent-detail-section {
  margin-bottom: 24px;
}

.agent-detail-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.agent-detail-section-actions {
  display: flex;
  gap: 6px;
}

/* 프롬프트 읽기 모드 */
.agent-prompt-reader {
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.7;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  background: var(--bg-primary);
  cursor: default;
}

/* Doc 모달 읽기 모드 */
.doc-modal-reader {
  flex: 1;
  margin: 12px 16px;
  padding: 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.7;
  overflow-y: auto;
  min-height: 250px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  background: var(--bg-primary);
}

/* Shared agent buttons */
.agent-btn {
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.agent-btn-save {
  background: var(--accent);
  color: #fff;
}

.agent-btn-save:hover { background: var(--accent-hover); }
.agent-btn-save:disabled { opacity: 0.5; cursor: default; }

.agent-btn-add {
  background: var(--accent-light);
  color: var(--accent);
}

.agent-btn-add:hover { background: var(--accent); color: #fff; }

.agent-btn-edit {
  background: var(--accent-light);
  color: var(--accent);
}

.agent-btn-edit:hover { background: var(--accent); color: #fff; }

.agent-btn-cancel {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.agent-btn-cancel:hover { background: var(--bg-tertiary, var(--bg-secondary)); }

.agent-btn-delete {
  background: #FEE2E2;
  color: #DC2626;
}

.agent-btn-delete:hover { background: #DC2626; color: #fff; }

/* Prompt editor */
.agent-prompt-editor {
  width: 100%;
  min-height: 300px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: 'Pretendard', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.agent-prompt-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.agent-save-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

/* Docs list */
.agent-docs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.agent-docs-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px;
  text-align: center;
}

.agent-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}

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

.agent-doc-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.agent-doc-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-doc-meta {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Doc Modal */
.doc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.doc-modal {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
}

.doc-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 0;
}

.doc-modal-title {
  flex: 1;
  border: none;
  border-bottom: 2px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  padding: 6px 0;
  outline: none;
  background: transparent;
  color: var(--text-primary);
}

.doc-modal-title:focus {
  border-color: var(--accent);
}

.doc-modal-title:disabled {
  color: var(--text-secondary);
  border-color: transparent;
}

.doc-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.doc-modal-editor {
  flex: 1;
  margin: 12px 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: 'Pretendard', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  min-height: 250px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.doc-modal-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.doc-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
}

.doc-modal-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-modal-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* Scheduler person icon (목록) */
.agent-card-avatar--icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  color: var(--text-muted);
}

/* Scheduler person icon (상세 프로필) */
.agent-profile-avatar--icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-tertiary, var(--bg-secondary));
}

/* Agent detail body — 모바일: 세로 스택 (기본) */
.agent-detail-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.agent-detail-content {
  min-width: 0;
}

/* 데스크톱: 좌측 카드 + 우측 콘텐츠 가로 배치 */
@media (min-width: 768px) {
  .agent-detail-body {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
  }

  .agent-profile-card {
    flex-shrink: 0;
    width: 280px;
    position: sticky;
    top: 16px;
    margin-bottom: 0;
  }

  .agent-profile-avatar {
    aspect-ratio: 3 / 4;
    max-height: calc(100vh - 160px);
  }

  .agent-detail-content {
    flex: 1;
    min-width: 0;
  }
}

@media (min-width: 1024px) {
  .agent-profile-card {
    width: 320px;
  }
}


@media (max-width: 767px) {
  .agent-prompt-editor {
    min-height: 200px;
    font-size: 12px;
  }
  .agent-profile-avatar {
    max-height: 280px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .agent-card { width: 360px; }
}
