/* AITY 创意世界 - 全局样式 */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-dark: #1e293b;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* Layout */
.app-header {
  background: var(--bg-dark);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.app-header .logo {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header .logo span { color: var(--primary); }

.header-nav { display: flex; align-items: center; gap: 16px; }
.header-nav a { color: #94a3b8; font-size: 14px; transition: color 0.2s; }
.header-nav a:hover, .header-nav a.active { color: white; }
.header-user { color: #94a3b8; font-size: 14px; }

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Auth Pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}

.auth-card h2 { text-align: center; margin-bottom: 8px; font-size: 24px; }
.auth-card p.subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.auth-card .switch-link { text-align: center; margin-top: 16px; font-size: 14px; }

/* Form Elements */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 14px; color: var(--text-secondary); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-group textarea.tall { min-height: 200px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Quick Tags for AI deduction */
.quick-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.quick-tag:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}
.quick-tag:active {
  transform: translateY(0);
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 16px; }

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Tags / Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.badge-friendly { background: #dcfce7; color: #166534; }
.badge-hostile { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Image */
.img-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.img-cover {
  width: 100%; height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
}
.img-thumb {
  width: 80px; height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  gap: 0;
}
.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.2s;
  user-select: none;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Tab content */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 12px;
  width: 600px;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-secondary); padding: 0 4px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Toast */
.toast-container { position: fixed; top: 72px; right: 24px; z-index: 300; }
.toast {
  background: var(--bg-dark);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
  animation: slideIn 0.3s ease;
  max-width: 360px;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Stat cards */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  text-align: center;
}
.stat-card .stat-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Table-like list */
.item-list { list-style: none; }
.item-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.item-list li:last-child { border-bottom: none; }

/* Affection bar */
.affection-bar {
  width: 100px; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.affection-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Relation type */
.relation-friendly { color: #16a34a; }
.relation-hostile { color: #dc2626; }
.relation-neutral { color: #64748b; }

/* Storyboard card */
.sb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.sb-card .sb-seq {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 600;
  margin-right: 8px;
}
.sb-card .sb-shot { color: var(--primary); font-weight: 500; }
.sb-card .sb-field { margin-top: 8px; font-size: 13px; }
.sb-card .sb-field strong { color: var(--text-secondary); font-size: 12px; }
.sb-card .sb-prompt {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-size: 12px;
  margin-top: 8px;
  word-break: break-all;
  cursor: pointer;
  position: relative;
}
.sb-card .sb-prompt:hover { border-color: var(--primary); }
.sb-card .sb-prompt::after {
  content: '点击复制';
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 11px;
  color: var(--primary);
}

/* Project card */
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.project-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.project-card h3 { font-size: 16px; margin-bottom: 8px; }
.project-card .desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.project-card .meta { font-size: 12px; color: var(--text-secondary); }

/* Character card */
.char-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 12px;
}
.char-card .char-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: var(--primary);
}
.char-card .char-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.char-card .char-info h4 { font-size: 15px; margin-bottom: 2px; }
.char-card .char-info .char-meta { font-size: 12px; color: var(--text-secondary); }
.char-card .char-info .char-personality { font-size: 13px; margin-top: 4px; color: var(--text); }

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
  font-size: 14px;
}
.upload-area:hover { border-color: var(--primary); color: var(--primary); }
.upload-area input[type="file"] { display: none; }

/* Page title */
.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title h1 { font-size: 22px; }
.page-title h2 { font-size: 18px; }

/* Inline editing */
.editable { cursor: pointer; border-bottom: 1px dashed var(--primary); }
.editable:hover { background: var(--primary-light); }

/* Script paste area */
.script-paste {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.8;
  resize: vertical;
  font-family: inherit;
}
.script-paste:focus {
  outline: none;
  border-color: var(--primary);
}

/* AI result */
.ai-result {
  background: #fafbff;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.ai-result h4 { color: var(--primary); margin-bottom: 8px; }

/* Responsive */
@media (max-width: 640px) {
  .app-container { padding: 12px; }
  .modal { width: 100%; }
  .btn-group { flex-direction: column; }
  .btn-full-mobile { width: 100%; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
