/* ============================================
   笙闆 IP 工作室 - 全站共用 CSS
   主色：鏽橘 #C6613F  輔色：暖米白 / 深褐
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ---- CSS Variables ---- */
:root {
  --primary:       #C6613F;
  --primary-dark:  #A04E30;
  --primary-light: #E07A55;
  --primary-pale:  #F5E8E3;

  --bg:            #FAFAF8;
  --bg-card:       #FFFFFF;
  --bg-sidebar:    #1C1917;
  --bg-sidebar-hover: #292524;

  --text:          #1C1917;
  --text-2:        #57534E;
  --text-3:        #A8A29E;
  --text-inv:      #FAFAF8;

  --border:        #E7E5E4;
  --border-2:      #D6D3D1;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow:        0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.12);

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;

  --sidebar-w:     220px;
  --topbar-h:      56px;

  /* Platform colors */
  --ig-orange:     #C6613F;
  --threads-purple:#7C3AED;
  --feed-pink:     #EC4899;
  --reels-blue:    #2563EB;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Noto Sans TC', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }
img { max-width: 100%; }

/* ---- Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: var(--text-inv);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon svg { width: 18px; height: 18px; }
.sidebar-logo .logo-text { font-size: 13px; font-weight: 600; line-height: 1.3; }
.sidebar-logo .logo-text span { color: var(--primary-light); }

.sidebar-section { padding: 16px 10px 4px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 0 8px;
  margin-bottom: 4px;
}
.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: rgba(255,255,255,0.65);
  transition: all 0.15s;
}
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.sidebar-nav a:hover {
  background: var(--bg-sidebar-hover);
  color: rgba(255,255,255,0.9);
}
.sidebar-nav a.active {
  background: rgba(198, 97, 63, 0.25);
  color: #E8A882;
}
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.page-body { padding: 24px; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.card-header .card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 16px 20px; }

/* ---- Stat Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.stat-card .stat-icon svg { width: 18px; height: 18px; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-card .stat-change { font-size: 12px; margin-top: 6px; }
.stat-card .stat-change.up { color: #16A34A; }
.stat-card .stat-change.down { color: #DC2626; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--border); }
.btn-ghost {
  color: var(--text-2);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Platform Badges ---- */
.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}
.platform-badge.ig-channel { background: rgba(198,97,63,0.12); color: var(--ig-orange); }
.platform-badge.threads    { background: rgba(124,58,237,0.1);  color: var(--threads-purple); }
.platform-badge.ig-feed    { background: rgba(236,72,153,0.1);  color: var(--feed-pink); }
.platform-badge.reels      { background: rgba(37,99,235,0.1);   color: var(--reels-blue); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}
.status-badge.draft     { background: #FEF9C3; color: #854D0E; }
.status-badge.scheduled { background: #DBEAFE; color: #1D4ED8; }
.status-badge.published { background: #DCFCE7; color: #166534; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color 0.15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(198,97,63,0.12);
}
.form-textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

/* ---- Tab Nav ---- */
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 0 0 0;
  margin-bottom: 20px;
}
.tab-btn {
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Table ---- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.data-table td {
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #FAFAF8; }
.data-table .post-title {
  font-weight: 500;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Compose Layout ---- */
.compose-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

/* ---- AI Panel ---- */
.ai-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ai-panel-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-panel-header svg { width: 18px; height: 18px; }
.ai-panel-header .ai-title { font-size: 14px; font-weight: 600; }
.ai-panel-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.topic-chip {
  padding: 6px 8px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg);
  transition: all 0.15s;
  text-align: left;
  line-height: 1.3;
}
.topic-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); }
.topic-chip.selected { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); font-weight: 500; }

.structure-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.structure-chip {
  padding: 5px 10px;
  border: 1px solid var(--border-2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg);
  transition: all 0.15s;
}
.structure-chip:hover { border-color: var(--primary); color: var(--primary); }
.structure-chip.selected { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); font-weight: 500; }

/* ---- RefineBox ---- */
.refine-box {
  background: var(--primary-pale);
  border: 1px solid rgba(198,97,63,0.25);
  border-radius: var(--radius);
  padding: 14px;
  display: none;
}
.refine-box.visible { display: block; }
.refine-box-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.refine-box-label svg { width: 14px; height: 14px; }
.refine-box textarea {
  width: 100%;
  border: 1px solid rgba(198,97,63,0.3);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  background: white;
  color: var(--text);
  resize: none;
  height: 70px;
  margin-bottom: 8px;
}
.refine-box textarea:focus { outline: none; border-color: var(--primary); }

/* ---- FeedbackBubble ---- */
#feedback-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}
.fb-trigger {
  width: 44px; height: 44px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}
.fb-trigger:hover { transform: scale(1.08); background: var(--primary-dark); }
.fb-trigger svg { width: 20px; height: 20px; }
.fb-panel {
  position: absolute;
  bottom: 52px; right: 0;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: none;
}
.fb-panel.open { display: block; animation: fadeUp 0.15s ease; }
.fb-panel-title { font-size: 13.5px; font-weight: 600; margin-bottom: 10px; }
.fb-panel textarea {
  width: 100%;
  height: 80px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  resize: none;
  margin-bottom: 8px;
  color: var(--text);
}
.fb-panel textarea:focus { outline: none; border-color: var(--primary); }
.fb-close {
  position: absolute;
  top: 8px; right: 8px;
  color: var(--text-3);
  padding: 4px;
}
.fb-close:hover { color: var(--text); }
.fb-close svg { width: 14px; height: 14px; }

/* ---- Loading Spinner ---- */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-dark {
  border: 2px solid var(--border-2);
  border-top-color: var(--primary);
}

/* ---- Calendar ---- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-day-header {
  background: var(--bg);
  text-align: center;
  padding: 8px 4px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.cal-cell {
  background: var(--bg-card);
  min-height: 90px;
  padding: 6px;
  vertical-align: top;
  cursor: pointer;
  transition: background 0.1s;
}
.cal-cell:hover { background: #FAFAF8; }
.cal-cell.today .cal-num {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}
.cal-cell.other-month .cal-num { color: var(--text-3); }
.cal-num { font-size: 12.5px; font-weight: 500; margin-bottom: 4px; }
.cal-event {
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cal-event.ig-channel { background: rgba(198,97,63,0.15); color: #7A3A22; }
.cal-event.threads    { background: rgba(124,58,237,0.12); color: #4C1D95; }
.cal-event.ig-feed    { background: rgba(236,72,153,0.12); color: #831843; }
.cal-event.reels      { background: rgba(37,99,235,0.12);  color: #1E3A8A; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; display: block; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ---- Phase 2 Placeholder ---- */
.phase2-placeholder {
  background: repeating-linear-gradient(
    -45deg,
    var(--bg),
    var(--bg) 10px,
    #F5F4F2 10px,
    #F5F4F2 20px
  );
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-3);
}
.phase2-placeholder svg { width: 32px; height: 32px; margin: 0 auto 10px; display: block; opacity: 0.35; }
.phase2-placeholder p { font-size: 13px; }
.phase2-placeholder strong { color: var(--text-2); }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-sidebar);
  color: var(--text-inv);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
}
.toast.success { border-left: 3px solid #22C55E; }
.toast.error   { border-left: 3px solid #EF4444; }
.toast.info    { border-left: 3px solid var(--primary-light); }

/* ---- Animations ---- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- Mobile Toggle ---- */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}
.sidebar-toggle svg { width: 22px; height: 22px; }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ---- Divider ---- */
.divider { height: 1px; background: var(--border); margin: 12px 0; }

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .page-body { padding: 16px; }
  .topbar { padding: 0 16px; }
  .data-table { display: block; overflow-x: auto; }
  .cal-cell { min-height: 60px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }
  .topic-grid { grid-template-columns: 1fr; }
}
