/* ============================================
   My Chatbot World - My Page (home.css)
   Per-persona management layout
   ============================================ */

/* === Layout === */
:root {
  --sidebar-width: 260px;
}

.manage-layout {
  display: flex;
  min-height: 100vh;
  background: #0d0d12;
}

.manage-sidebar {
  width: var(--sidebar-width);
  background: #16161c;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 2rem 1.5rem;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.manage-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 3rem 4rem;
}

/* === Sidebar === */
.brand-section {
  margin-bottom: 3rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-400);
  display: flex;
  align-items: center;
  gap: 10px;
}

.manage-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.manage-nav-item {
  padding: 12px 16px;
  color: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
}

.manage-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.manage-nav-item.active {
  background: var(--primary-500);
  color: white;
}

/* === Tab Content === */
.manage-tab-content {
  display: none;
}

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

/* === Manage Card === */
.manage-card {
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 800px;
}

.section-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.25rem;
  color: white;
}

/* === Form === */
.form-row {
  margin-bottom: 1.5rem;
}

.form-label-dark {
  display: block;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.5rem;
}

.form-input-static {
  font-size: 1.1rem;
  color: white;
  font-weight: 600;
  padding: 10px 0;
}

.form-control-dark {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  color: white;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control-dark:focus {
  border-color: var(--primary-400);
}

.form-control-dark::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

textarea.form-control-dark {
  resize: vertical;
  min-height: 80px;
}

/* === Bot List === */
.bot-manage-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.bots-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.bots-header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: white;
  margin: 0;
}

/* === Bot Card === */
.bot-card {
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color 0.2s;
}

.bot-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.bot-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding: 1.5rem 2rem;
}

.bot-info {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.bot-icon {
  width: 50px;
  height: 50px;
  background: var(--gradient-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.bot-meta h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}

.bot-meta p {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

.bot-meta .bot-date {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
}

/* === Draft Card (작성 중) === */
.draft-card {
  border: 1px dashed rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.05);
}

.draft-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-left: 8px;
  vertical-align: middle;
}

/* === URL Panel === */
.url-panel {
  display: none;
  padding: 12px 2rem;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  gap: 8px;
  flex-direction: column;
}

.url-panel.open {
  display: flex;
}

.url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.url-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  min-width: 100px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.url-input {
  flex: 1;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  font-family: monospace;
  outline: none;
  cursor: pointer;
}

.url-input:focus {
  border-color: var(--primary-400);
}

.url-copy-btn {
  padding: 5px 12px;
  background: var(--primary-500);
  color: white;
  border-radius: var(--radius-md);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.url-copy-btn:hover {
  background: var(--primary-600);
}

/* === Bot Settings Panel (bot level) === */
.bot-settings-panel {
  display: none;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  animation: panelSlideDown 0.25s ease-out;
}

.bot-settings-panel.open {
  display: block;
}

/* === Persona List === */
.persona-list {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.persona-list-footer {
  padding: 1rem 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.btn-add-persona {
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(99, 102, 241, 0.08);
  color: var(--primary-400);
  border: 1px dashed rgba(99, 102, 241, 0.3);
  width: 100%;
  text-align: center;
}

.btn-add-persona:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary-400);
}

/* === Persona Manage Card (each persona within a bot) === */
.persona-manage-card {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.persona-manage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: rgba(255, 255, 255, 0.02);
}

.persona-manage-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.persona-manage-name {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.persona-manage-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary-400);
  background: rgba(99, 102, 241, 0.12);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.persona-manage-role {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
}

/* === Tool Bar (under each persona) === */
.tool-bar {
  display: flex;
  gap: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tool-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  background: transparent;
  position: relative;
}

.tool-btn:last-child {
  border-right: none;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.8);
}

.tool-btn.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-400);
}

.tool-btn .tool-icon {
  font-size: 0.9rem;
}

/* === Tool Panel (accordion body) === */
.tool-panel {
  display: none;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 2rem;
  background: rgba(0, 0, 0, 0.15);
  animation: panelSlideDown 0.25s ease-out;
}

.tool-panel.open {
  display: block;
}

@keyframes panelSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tool-panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === KB Panel === */
.kb-section {
  margin-bottom: 1.5rem;
}

.kb-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Q&A Pair List */
.qa-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.qa-item {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: start;
}

.qa-item input,
.qa-item textarea {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.85rem;
  outline: none;
}

.qa-item input:focus,
.qa-item textarea:focus {
  border-color: var(--primary-400);
}

.qa-remove-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  background: transparent;
  font-size: 1rem;
}

.qa-remove-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error-500);
}

/* File Upload Zone */
.file-upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
}

.file-upload-zone:hover {
  border-color: var(--primary-400);
  color: var(--primary-400);
  background: rgba(99, 102, 241, 0.05);
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

/* === Skill Panel === */
.skill-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.skill-column h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.skill-grid::-webkit-scrollbar {
  width: 4px;
}

.skill-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.skill-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  transition: all 0.2s;
}

.skill-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.skill-card-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.skill-card-info {
  flex: 1;
  min-width: 0;
}

.skill-card-info .skill-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: white;
  margin-bottom: 2px;
}

.skill-card-info .skill-desc {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-card-info .skill-meta {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 2px;
}

.skill-action-btn {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.skill-install-btn {
  background: var(--primary-500);
  color: white;
}

.skill-install-btn:hover {
  background: var(--primary-600);
}

.skill-remove-btn {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error-500);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.skill-remove-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

.skill-category-filter {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.category-chip {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid transparent;
}

.category-chip:hover {
  color: rgba(255, 255, 255, 0.8);
}

.category-chip.active {
  background: var(--primary-500);
  color: white;
}

/* === Log Panel === */
.log-stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.log-stat-card {
  flex: 1;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  text-align: center;
}

.log-stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary-400);
}

.log-stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 4px;
}

.log-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}

.log-messages::-webkit-scrollbar {
  width: 4px;
}

.log-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.log-msg {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 85%;
}

.log-msg.user {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-300);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.log-msg.assistant {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.log-msg-time {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 4px;
}

/* === Settings Panel === */
.settings-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1rem;
}

.iq-eq-slider {
  width: 100%;
  margin: 0.5rem 0;
  accent-color: var(--primary-500);
}

.iq-eq-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.3);
}

.delete-bot-zone {
  padding: 1.5rem;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-lg);
  background: rgba(239, 68, 68, 0.05);
}

.delete-bot-zone h4 {
  color: var(--error-500);
  margin-bottom: 0.5rem;
}

.delete-bot-zone p {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 1rem;
}

.btn-danger {
  background: var(--error-500);
  color: white;
  padding: 8px 20px;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: #dc2626;
}

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

/* === School Panel === */
.school-feature-list {
  list-style: none;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.school-feature-list li {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
}

/* === Community Activity === */
.community-activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 4px;
}

.community-activity-list::-webkit-scrollbar {
  width: 4px;
}

.community-activity-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.community-activity-item {
  display: flex;
  align-items: start;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  transition: background 0.2s;
}

.community-activity-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.activity-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

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

.activity-text {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
}

.activity-time {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 4px;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: rgba(255, 255, 255, 0.4);
}

.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.75rem;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 2rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* === Misc === */
.btn-sm-dark {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-sm-dark:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.btn-sm-primary {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--primary-500);
  color: white;
}

.btn-sm-primary:hover {
  background: var(--primary-600);
}

.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--success-500);
  opacity: 0;
  transition: opacity 0.3s;
}

.save-indicator.show {
  opacity: 1;
}

/* === QR Code in URL Panel === */
.url-qr-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 8px;
}

.url-qr-code {
  display: flex;
  justify-content: center;
}

.url-qr-code img {
  background: white;
  padding: 4px;
  border-radius: 8px;
}

/* === Persona Form Modal (addPersona) === */
.persona-form-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.persona-form-modal {
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: panelSlideDown 0.25s ease-out;
}

.persona-form-modal h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1.5rem;
}

/* === Responsive === */
@media (max-width: 1024px) {
  .skill-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .manage-sidebar {
    display: none;
  }

  .manage-content {
    margin-left: 0;
    padding: 2rem 1.5rem;
  }

  .bot-card-header {
    flex-direction: column;
    gap: 1rem;
  }

  .persona-manage-header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .tool-bar {
    flex-wrap: wrap;
  }

  .tool-btn {
    flex: 1 1 calc(33.33% - 1px);
  }

  .qa-item {
    grid-template-columns: 1fr;
  }

  .skill-layout {
    grid-template-columns: 1fr;
  }

  .log-stats {
    flex-direction: column;
  }
}
