/* ═══════════════════════════════════════════════════════════
   蘿泥蔔說 - Facebook 同步管理介面
   Design System: Dark theme, glassmorphism, modern UI
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Color Palette */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --bg-glass: rgba(22, 27, 34, 0.85);

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;

  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-orange: #d29922;
  --accent-purple: #bc8cff;

  --border-primary: #30363d;
  --border-secondary: #21262d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.15);

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ─── Reset & Base ──────────────────────────────────────── */

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ─── Screens ───────────────────────────────────────────── */

.screen {
  min-height: 100vh;
}

#app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Auth Screen ───────────────────────────────────────── */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(88, 166, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(188, 140, 255, 0.06) 0%, transparent 50%);
}

.auth-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: fadeInUp 0.6s ease;
}

.auth-logo {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.auth-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.auth-form {
  text-align: left;
}

.auth-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.auth-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.auth-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

.error-text {
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* ─── Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #238636, #2ea043);
  color: #fff;
  border-color: rgba(63, 185, 80, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2ea043, #3fb950);
  box-shadow: 0 0 15px rgba(63, 185, 80, 0.3);
}

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  color: var(--accent-red);
  border-color: rgba(248, 81, 73, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 81, 73, 0.25);
}

.btn-warning {
  background: rgba(210, 153, 34, 0.15);
  color: var(--accent-orange);
  border-color: rgba(210, 153, 34, 0.3);
}

.btn-warning:hover:not(:disabled) {
  background: rgba(210, 153, 34, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-primary);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* ─── App Header ────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 0.75rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s infinite;
}

/* ─── Tabs ──────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  padding: 0 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-blue);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-tertiary);
  border-radius: 10px;
  color: var(--text-secondary);
}

.tab.active .badge {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent-blue);
}

/* ─── Content Area ──────────────────────────────────────── */

.content-area {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── Post List (Left Panel) ────────────────────────────── */

.post-list {
  width: 340px;
  min-width: 300px;
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-secondary);
  font-size: 0.85rem;
}

.select-all {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.list-info {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.list-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

/* Post Item */
.post-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: 2px;
}

.post-item:hover {
  background: var(--bg-hover);
}

.post-item.active {
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.post-item input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--accent-blue);
}

.post-item-body {
  flex: 1;
  min-width: 0;
}

.post-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.post-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.post-item-preview {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
}

.post-item-images {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Editor Panel (Right) ──────────────────────────────── */

.editor-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}

.editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.field-group {
  margin-bottom: 1.5rem;
}

.field-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.field-group input[type="text"],
.field-group textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

.field-group textarea {
  resize: vertical;
  min-height: 60px;
}

.category-selects {
  display: flex;
  gap: 0.75rem;
}

.category-selects select {
  flex: 1;
  padding: 0.65rem 0.9rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}

#regenerate-title-btn {
  margin-top: 0.4rem;
}

/* ─── SEO Score ─────────────────────────────────────────── */

.seo-score {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.seo-score h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.seo-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.3rem 0;
}

.seo-item.pass { color: var(--accent-green); }
.seo-item.warn { color: var(--accent-orange); }
.seo-item.fail { color: var(--accent-red); }

/* ─── Content Preview ───────────────────────────────────── */

.content-preview {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.7;
}

/* ─── Images Preview ────────────────────────────────────── */

.images-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.images-preview img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
  transition: transform var(--transition-fast);
}

.images-preview img:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

/* ─── Meta Info ─────────────────────────────────────────── */

.meta-info {
  display: flex;
  gap: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 1rem;
  border-top: 1px solid var(--border-secondary);
}

/* ─── Action Bar ────────────────────────────────────────── */

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-primary);
}

.action-left {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.action-right {
  display: flex;
  gap: 0.75rem;
}

/* ─── Modal ─────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 550px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.3s ease;
}

.modal h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.modal-body {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-body .publish-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-secondary);
}

.modal-body .publish-item:last-child {
  border-bottom: none;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ─── Loading Overlay ───────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-primary);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ─── Toast ─────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 80px;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 3000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s ease;
  max-width: 400px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }

/* ─── Scrollbar ─────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Animations ────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ─── Responsive ────────────────────────────────────────── */

@media (max-width: 768px) {
  .content-area {
    flex-direction: column;
  }

  .post-list {
    width: 100%;
    min-width: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-primary);
  }

  .editor-panel {
    padding: 1rem;
  }



  .category-selects {
    flex-direction: column;
  }

  .header-subtitle {
    display: none;
  }

  .action-bar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .action-right {
    width: 100%;
    justify-content: flex-end;
  }
}
