:root {
  --bg-main: #0b0f19;
  --bg-surface: #111827;
  --bg-card: #1e293b;
  --bg-elevated: #334155;
  --border-color: #1e293b;
  --border-subtle: #2d3748;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.35);
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --fb-blue: #1877f2;
  --fb-card-bg: #242526;
  --fb-text: #e4e6eb;
  --fb-sub: #b0b3b8;
  --fb-divider: #393a3b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background-color: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-zone {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: white;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.status-zone {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: 12px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.badge-pill.active .dot {
  background: var(--success);
}

.badge-pill.warning .dot {
  background: var(--warning);
}

.pulse {
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Workspace Grid */
.workspace {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
  padding: 24px 28px;
  flex: 1;
}

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

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.char-count, .preview-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg-card);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* AI Creative Box */
.ai-box {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-tag {
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.ai-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.ai-inputs {
  display: grid;
  grid-template-columns: 1.5fr 1fr auto;
  gap: 8px;
}

/* Template Shelf */
.template-shelf {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shelf-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.template-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.template-chips::-webkit-scrollbar {
  height: 4px;
}
.template-chips::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.chip-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--primary);
  color: #38bdf8;
}

/* Inputs & Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.input-field, .select-field, .composer-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  transition: border-color 0.2s;
}

.input-field:focus, .select-field:focus, .composer-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.composer-textarea {
  resize: vertical;
  line-height: 1.6;
}

/* Media Grid */
.media-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-text-action {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 11px;
  cursor: pointer;
}

.media-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  max-height: 170px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.media-thumb-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: #000;
  transition: all 0.2s;
}

.media-thumb-item:hover {
  transform: scale(1.04);
}

.media-thumb-item.selected {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.4);
}

.media-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  font-size: 9px;
  text-align: center;
  padding: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #1877f2, #2563eb);
  color: white;
  box-shadow: 0 4px 14px rgba(24, 119, 242, 0.4);
}

.btn-primary:hover {
  background: #166fe5;
  box-shadow: 0 6px 18px rgba(24, 119, 242, 0.6);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
}

.btn-ai {
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: white;
  padding: 8px 14px;
  font-size: 12px;
}

.btn-ai:hover {
  filter: brightness(1.1);
}

/* Publish Controls */
.publish-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.mode-toggles {
  display: flex;
  gap: 20px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.strategy-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.strategy-selector label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* FACEBOOK FEED CARD MOCKUP */
.preview-panel {
  display: flex;
  flex-direction: column;
  background: #0f172a;
}

.fb-card-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px;
}

.fb-card {
  width: 100%;
  max-width: 500px;
  background: var(--fb-card-bg);
  color: var(--fb-text);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  font-size: 14px;
}

.fb-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 8px;
}

.fb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255,255,255,0.1);
}

.fb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fb-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.fb-author-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fb-name {
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.fb-verified {
  background: #1877f2;
  color: white;
  border-radius: 50%;
  font-size: 9px;
  width: 13px;
  height: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.fb-time-row {
  font-size: 12px;
  color: var(--fb-sub);
}

.fb-card-menu {
  color: var(--fb-sub);
  cursor: pointer;
  font-weight: bold;
}

.fb-card-body {
  padding: 6px 16px 12px;
  white-space: pre-wrap;
  line-height: 1.5;
  color: #e4e6eb;
  font-size: 14px;
  word-break: break-word;
}

.fb-media-container {
  width: 100%;
  background: #000;
  max-height: 400px;
  overflow: hidden;
}

.fb-media-container img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  display: block;
}

.fb-link-box {
  background: #3a3b3c;
  padding: 10px 14px;
  border-top: 1px solid var(--fb-divider);
}

.fb-link-domain {
  font-size: 11px;
  color: var(--fb-sub);
  text-transform: uppercase;
}

.fb-link-title {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fb-reactions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--fb-sub);
  border-bottom: 1px solid var(--fb-divider);
}

.reaction-icons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fb-actions-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 4px 10px;
}

.fb-act-btn {
  background: none;
  border: none;
  color: var(--fb-sub);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.fb-act-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.target-page-meta {
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.target-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.target-link {
  color: #38bdf8;
  font-size: 12px;
  text-decoration: none;
}

.target-link:hover {
  text-decoration: underline;
}

/* Bottom Queue & History Section */
.bottom-section {
  padding: 0 28px 28px;
}

.tab-headers {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th, .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 30px !important;
}

/* Status Badges in Table */
.badge-status {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-status.published { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-status.pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-status.failed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-status.dry-run { background: rgba(56, 189, 248, 0.15); color: var(--accent-cyan); }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  width: 90%;
  max-width: 520px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.help-text {
  font-size: 11px;
  color: var(--text-dim);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  z-index: 110;
  animation: slide-up 0.3s ease-out;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

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