/**
 * Crushpop Playground - 메인 스타일시트
 * 
 * 기능별로 분리된 스타일:
 * - buttons.css: 버튼 컴포넌트
 * - wizard.css: 페르소나 생성 위자드
 */

:root {
  --app-header-height: 72px;
}

body {
  margin: 0;
  font-family: var(--ui-font-family);
  /* background and color now come from common.css */
  min-height: 100vh;
  height: 100%;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: none;
}

html {
  height: 100%;
  overscroll-behavior-y: none;
  scroll-behavior: smooth;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
}

@media (min-width: 1600px) {
  .container {
    max-width: 1440px;
  }
}

.app-header {
  background: var(--ui-surface-raised);
  color: var(--ui-text);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.app-header .container {
  min-height: var(--app-header-height);
  display: flex;
  align-items: center;
}

.app-nav {
  background: var(--ui-bg);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 0 var(--ui-border);
}

.app-nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ui-text) !important;
  padding: 0.5rem 1rem 0.5rem 0 !important;
  margin-right: 0.5rem;
  border-right: 1px solid var(--ui-border);
}

.nav-brand:hover {
  background: transparent !important;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ui-text);
  font-size: 0.85rem;
}

.app-nav a {
  color: var(--ui-text-muted);
  margin-right: 0;
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.app-nav a:hover {
  background: var(--ui-surface-hover);
  color: var(--ui-text);
}

.app-nav a.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.app-main {
  padding: 0 0 2rem;
  display: grid;
  gap: 1rem;
  flex: 1;
}

/* Chat page: no padding, full height, no scroll */
body.chat-page {
  overflow: hidden;
  background: var(--ui-bg);
}

/* Only app-main container gets full width, nav stays centered */
body.chat-page .app-main.container {
  max-width: none;
  padding: 0;
  margin: 0;
  height: calc(100vh - 52px);
  overflow: hidden;
}

body.chat-page .app-layout {
  height: 100%;
  overflow: hidden;
  gap: 0;
}

body.chat-page .app-sidebar {
  height: 100%;
  overflow-y: auto;
}

body.chat-page .app-content {
  height: 100%;
  overflow: hidden;
}

.card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-md);
  padding: 1.75rem;
}

/* Override .card for chat page - complete reset */
body.chat-page .card {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  border: none;
  overflow: visible;
}

body.chat-page .card.chat-card {
  background: var(--chat-bg);
  overflow: hidden;
}

/* Override legacy light-mode chat styles for chat-page */
body.chat-page .chat-messages {
  border: none;
  border-radius: 0;
  max-height: none;
  height: auto;
  background: transparent;
  padding: 20px 24px;
}

body.chat-page .chat-message {
  box-shadow: none;
}

body.chat-page .chat-empty {
  padding: 40px 24px;
}

.card h2,
.card h3 {
  margin-top: 0;
}

.filters__locked {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--ui-border);
  border-radius: 0.75rem;
  background: var(--ui-surface-hover);
  color: var(--ui-text-muted);
}

.filters__locked-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ui-text-muted);
}

.filters__locked-value {
  font-weight: 600;
  color: var(--ui-text);
}
.muted {
  color: var(--ui-text-muted);
}

.small-text {
  font-size: 0.8rem;
  margin: 0;
}

.btn-link {
  color: var(--ui-primary-light);
  text-decoration: none;
  margin-left: 0.75rem;
  background: transparent;
  border: none;
  font-size: inherit;
  cursor: pointer;
}

.btn-link:hover {
  text-decoration: underline;
  color: var(--ui-primary);
}

.status {
  font-weight: 600;
}

.status--ok {
  color: var(--ui-success);
}

.status--error {
  color: var(--ui-error);
}

.status-details {
  background: var(--ui-surface-raised);
  color: var(--ui-text);
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.9rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0 0.5rem;
  align-items: flex-end;
}

.filters label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  color: var(--ui-text);
}

.filters input {
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--ui-border);
  font-size: 0.95rem;
  background: var(--ui-surface);
  color: var(--ui-text);
}

.filters button {
  padding: 0.55rem 1.25rem;
  border-radius: 0.75rem;
  border: none;
  background: var(--ui-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.filters button:hover {
  background: var(--ui-primary-dark);
}

.table-wrapper {
  margin-top: 1rem;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

table th,
table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--ui-border);
}

table th {
  background: var(--ui-surface-raised);
  font-weight: 600;
  color: var(--ui-text-muted);
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sort-btn:hover {
  color: var(--ui-text);
}

.sort-indicator::before {
  content: "";
  display: inline-block;
  font-size: 0.7rem;
  opacity: 0.7;
}

.sort-btn.is-asc .sort-indicator::before {
  content: "^";
}

.sort-btn.is-desc .sort-indicator::before {
  content: "v";
}

table tbody tr:hover {
  background: var(--ui-surface-hover);
}

.persona-thumb-header {
  width: 56px;
  text-align: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.persona-thumb-cell {
  text-align: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  vertical-align: middle;
  line-height: 0;
}

.persona-name-cell {
  padding-left: 0.5rem;
  vertical-align: middle;
}

.persona-thumb {
  width: 36px;
  height: 36px;
  display: block;
  margin: 0 auto;
  object-fit: cover;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
}

.persona-thumb--empty {
  background: var(--ui-surface-muted);
  border-color: var(--ui-border);
}

.text-center {
  text-align: center;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: var(--ui-error-bg);
  color: var(--ui-error);
  border: 1px solid var(--ui-error-border);
}

.alert-success {
  background: var(--ui-success-bg);
  color: var(--ui-success);
  border: 1px solid var(--ui-success-border);
}

.alert-caption {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: rgba(15, 23, 42, 0.8);
}

.alert-list {
  margin: 0.5rem 0 0 1rem;
  padding: 0;
  color: inherit;
}

.alert-details {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: inherit;
}

.alert-details summary {
  cursor: pointer;
}

.alert-details code {
  display: block;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 0.35rem;
  padding: 0.25rem 0.4rem;
  margin-top: 0.25rem;
  word-break: break-all;
}

.status-panel {
  margin-top: 1.5rem;
}

.status-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 1rem 0;
  padding: 0;
}

.status-list dt {
  font-size: 0.85rem;
  color: var(--ui-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-list dd {
  margin: 4px 0 0;
  font-weight: 600;
  color: var(--ui-text);
}

.status-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 1rem;
}

.status-check {
  border: 1px solid var(--ui-border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  background: var(--ui-surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.status-check.ok {
  border-left-color: var(--ui-success);
}

.status-check.fail {
  border-left-color: var(--ui-error);
  background: var(--ui-error-bg);
}

.status-check-name {
  font-weight: 600;
  color: var(--ui-text);
}

.status-check-indicator {
  font-size: 0.85rem;
  color: var(--ui-text-muted);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.checkbox-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  background: var(--ui-surface);
  font-size: 0.9rem;
  color: var(--ui-text);
}

.checkbox-card input {
  margin-bottom: 4px;
}

.persona-group-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.persona-group-card {
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow-md);
}

.persona-group-card header {
  margin-bottom: 0.75rem;
}

.creator-header {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ui-border);
}

.creator-header .header-meta {
  margin-top: 0.35rem;
}

.creator-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 1.5rem;
}

.summary-card {
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: var(--ui-surface-hover);
}

.summary-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--ui-text-muted);
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}

.creator-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (max-width: 1024px) {
  .creator-detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1360px) {
  .creator-detail-layout {
    grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
    gap: 2.5rem;
  }
}

.creator-detail-secondary {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.creator-detail-primary,
.creator-detail-secondary {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 1rem;
  box-shadow: var(--ui-shadow-md);
  padding: 1.5rem;
}

.creator-panel {
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  border-radius: 1.25rem;
}

.creator-panel + .creator-panel {
  margin-top: 1.5rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-heading h3 {
  margin: 0;
}

.section-heading .small-text {
  margin: 0;
}

.full-width-section {
  margin-top: 2rem;
}

.persona-link-box {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ui-border);
}

.persona-link-box h4 {
  margin: 0 0 0.75rem;
}

.group-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.group-meta {
  margin-top: 0.35rem;
  color: var(--ui-text-muted);
  font-size: 0.9rem;
}

.group-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-danger-outline {
  border: 1px solid var(--ui-error);
  color: var(--ui-error);
  background: transparent;
  border-radius: 0.65rem;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger-outline:hover {
  background: var(--ui-error-bg);
}

.creator-account-form h3 {
  margin-top: 0;
  margin-bottom: 1rem;
}

.app-layout {
  display: flex;
  gap: 1.5rem;
}

.app-sidebar {
  width: 280px;
  flex-shrink: 0;
}

.app-sidebar:empty {
  display: none;
}

.app-content {
  flex: 1;
}

.chat-sidebar {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 0.75rem;
  box-shadow: var(--ui-shadow-md);
  padding: 1.5rem;
  height: fit-content;
  position: sticky;
  top: 1.5rem;
}

.sidebar-section + .sidebar-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ui-border);
}

.sidebar-title {
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--ui-text);
}

.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.conversation-list li a {
  display: block;
  text-decoration: none;
  border: 1px solid var(--ui-border);
  border-radius: 0.65rem;
  padding: 0.75rem 0.9rem;
  color: var(--ui-text);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.conversation-list li a:hover {
  background: var(--ui-surface-hover);
  border-color: var(--ui-border-hover);
}

.conversation-list li.active a {
  border-color: var(--ui-primary);
  background: rgba(99, 102, 241, 0.1);
}

.conversation-list .conversation-name {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.conversation-list .conversation-meta {
  font-size: 0.85rem;
  color: var(--ui-text-muted);
}

.conversation-list li.empty {
  padding: 0.75rem;
  text-align: center;
  border: 1px dashed var(--ui-border);
  border-radius: 0.65rem;
  color: var(--ui-text-dim);
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-form select {
  margin-top: 0.35rem;
  border-radius: 0.5rem;
  border: 1px solid #cbd5f5;
  padding: 0.45rem 0.5rem;
  width: 100%;
}

.chat-form button {
  border: none;
  padding: 0.6rem 0.9rem;
  border-radius: 0.65rem;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.chat-form button:hover {
  background: #1d4ed8;
}

.chat-card {
  min-height: 480px;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chat-header-meta {
  text-align: right;
  font-size: 0.9rem;
  color: #475569;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.chat-messages {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  max-height: 520px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.chat-message {
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.chat-message--assistant {
  border-left: 4px solid #6366f1;
}

.chat-message--user {
  border-left: 4px solid #06b6d4;
}

.chat-message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #475569;
  margin-bottom: 0.5rem;
}

.chat-role {
  font-weight: 700;
}

.chat-mode {
  background: #eef2ff;
  color: #4338ca;
  border-radius: 999px;
  padding: 0.1rem 0.65rem;
  font-size: 0.75rem;
}

.chat-message-body {
  white-space: pre-wrap;
  line-height: 1.55;
}

.chat-empty {
  text-align: center;
  padding: 3rem 1rem;
}

.chat-input-disabled {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  border: 1px dashed #cbd5f5;
  background: #f8fafc;
}

.chat-send-form {
  margin-top: 1.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-send-form textarea {
  width: 100%;
  resize: vertical;
  border-radius: 0.65rem;
  border: 1px solid #cbd5f5;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
}

.chat-send-form select {
  margin-top: 0.25rem;
  border-radius: 0.5rem;
  border: 1px solid #cbd5f5;
  padding: 0.35rem 0.5rem;
}

.chat-send-form button {
  align-self: flex-end;
  border: none;
  background: #0f172a;
  color: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: 0.65rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-send-form button:hover {
  background: #1f2933;
}

.chat-send-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.chat-mode-description {
  flex: 1;
  font-size: 0.9rem;
  color: #475569;
}

/* ===================================================== */
/* 추가 기능별 스타일은 별도 파일 참조                    */
/* - buttons.css: 버튼 컴포넌트                           */
/* - wizard.css: 페르소나 생성 위자드                     */
/* ===================================================== */

/* ===================================================== */
/* Persona List Infinite Scroll Loading                  */
/* ===================================================== */

.persona-list-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 1.5rem;
  color: var(--ui-text-muted);
  font-size: 0.9rem;
}

.persona-list-loading .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--ui-border);
  border-top-color: var(--ui-primary);
  border-radius: 50%;
  animation: persona-spinner 0.8s linear infinite;
}

@keyframes persona-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* ===================================================== */
/* Persona List Controls                                 */
/* ===================================================== */

.list-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.list-controls .meta {
  margin: 0;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-control label {
  font-size: 0.85rem;
  color: var(--ui-text-muted);
}

.sort-select {
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 0.9rem;
  cursor: pointer;
}

.sort-select:hover {
  border-color: var(--ui-border-hover);
}

.sort-select:focus {
  outline: none;
  border-color: var(--ui-primary);
}

.table-actions .persona-multiverse-select {
  height: 32px;
  padding: 0 0.6rem;
  border-radius: 0;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: var(--ui-font-size-sm);
  line-height: 32px;
  width: 10rem;
  max-width: 12rem;
  min-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-actions .persona-multiverse-select:disabled {
  color: var(--ui-text-muted);
}
