/* ==========================================
   語氣分析系統 — Design System: abby-brand-DESIGN.md
   ========================================== */

:root {
  /* Primary Brand */
  --primary: #FFB66E;
  --primary-dark: #E8973D;
  --primary-light: #FFF3E5;

  /* System Accent — Teal */
  --accent: #14B8A6;
  --accent-dark: #0D9488;
  --accent-light: #CCFBF1;

  /* Background & Surface */
  --bg: #FFF8F0;
  --card: #FFFFFF;

  /* Text */
  --text: #606060;
  --text-light: #8A8A8A;
  --text-muted: #B0B0B0;

  /* Border */
  --border: #E8E8E8;
  --disabled: #D4D4D4;

  /* Semantic */
  --success: #7BC47F;
  --warning: #F0AD4E;
  --danger: #D9534F;
  --info: #5BC0DE;

  /* Platform Colors */
  --fb-color: #1877F2;
  --ig-color: #E4405F;
  --threads-color: #000000;

  /* Shadows */
  --shadow-subtle: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-card: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-elevated: 0 8px 24px rgba(0,0,0,0.12);

  /* Layout */
  --sidebar-width: 220px;
}

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

body {
  font-family: "Noto Sans TC", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}
.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.sidebar-brand .tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.nav-links {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 20px 6px;
}
.nav-links li {
  padding: 10px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-light);
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-links li:hover {
  background: var(--accent-light);
  color: var(--text);
}
.nav-links li.active {
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 600;
  border-left-color: var(--accent);
}
.nav-links li .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.15s;
}
.sidebar-footer .back-link:hover {
  color: var(--accent-dark);
}
.sidebar-footer .back-link svg {
  flex-shrink: 0;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; }

/* Page Banner */
.page-banner {
  padding: 32px 32px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-banner h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}
.page-banner .subtitle {
  font-size: 14px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(20,184,166,0.3);
}
.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

/* ===== Stats Row ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 0 32px 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-subtle);
}
.stat-card .label {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  font-family: "Inter", sans-serif;
}

/* ===== Content Panels ===== */
.content-area {
  padding: 0 32px 32px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 24px;
}
.panel h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20,184,166,0.1);
}
textarea {
  resize: vertical;
  min-height: 120px;
}

/* Platform selector */
.platform-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.platform-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: 9999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  background: white;
}
.platform-option:hover {
  border-color: var(--accent);
}
.platform-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 600;
}
.platform-option .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ===== Analysis Record List ===== */
.record-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.record-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.15s;
  cursor: pointer;
}
.record-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.record-item .platform-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.record-item .platform-badge.fb { background: var(--fb-color); }
.record-item .platform-badge.ig { background: var(--ig-color); }
.record-item .platform-badge.threads { background: var(--threads-color); }
.record-item .record-info {
  flex: 1;
  min-width: 0;
}
.record-item .record-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.record-item .record-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.record-item .record-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.running { background: #FEF3C7; color: #D97706; }
.status-badge.done { background: #DCFCE7; color: #16A34A; }
.status-badge.error { background: #FEE2E2; color: #DC2626; }

/* ===== Writing Guide Display ===== */
.guide-section {
  margin-bottom: 24px;
}
.guide-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-dark);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent-light);
}
.guide-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.guide-tag {
  padding: 4px 12px;
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
}
.guide-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
}

/* ===== AI Writer ===== */
.writer-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.writer-output {
  min-height: 200px;
  padding: 20px;
  background: #FAFAF9;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
}
.writer-output.generating {
  opacity: 0.7;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}
.empty-state p {
  font-size: 15px;
  margin-bottom: 20px;
}

/* ===== Loading ===== */
.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.active {
  display: flex;
}
.modal-box {
  background: white;
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.16);
}
.modal-box h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ===== Progress ===== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page-banner { padding: 24px 16px 16px; }
  .page-banner h1 { font-size: 20px; }
  .stats-row { padding: 0 16px 16px; }
  .content-area { padding: 0 16px 24px; }
}
