/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f0f2f7; color: #0f172a; font-size: 14px; line-height: 1.5; }

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

/* ── Sidebar ── */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: #0f172a;
  display: flex; flex-direction: column;
  padding: 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.brand-icon { font-size: 20px; }
.brand-name { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.55);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-radius: 0;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.nav-item.active { background: rgba(99,102,241,0.2); color: #818cf8; }
.nav-icon { font-size: 13px; width: 16px; text-align: center; }

.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px 8px;
  font-size: 12px; color: rgba(255,255,255,0.45);
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #64748b; flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot.running { background: #22c55e; box-shadow: 0 0 6px #22c55e88; }
.status-dot.paused  { background: #f59e0b; }

.sidebar-controls { padding: 8px 14px 20px; display: flex; gap: 6px; }
.ctrl-btn {
  flex: 1; padding: 6px 0;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6); font-size: 12px; border-radius: 6px; cursor: pointer;
  transition: background 0.15s;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.13); color: #fff; }

/* ── Main ── */
.main { flex: 1; padding: 32px 36px; max-width: 1100px; }

/* ── Section ── */
.section { margin-bottom: 44px; }
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-header h2 { font-size: 17px; font-weight: 700; color: #0f172a; }
.section-sub { font-size: 13px; color: #64748b; margin-top: 2px; }
.section-badge {
  padding: 2px 9px; border-radius: 999px;
  background: #e2e8f0; color: #475569;
  font-size: 11px; font-weight: 600;
}

/* ── Create Card ── */
.create-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  overflow: hidden;
}

.mode-tabs {
  display: flex;
  border-bottom: 1px solid #f1f5f9;
  padding: 0 6px;
  gap: 2px;
}
.mode-tab {
  padding: 14px 18px;
  background: none; border: none;
  font-size: 13px; font-weight: 500;
  color: #94a3b8; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.mode-tab:hover { color: #475569; }
.mode-tab.active { color: #6366f1; border-bottom-color: #6366f1; }

.mode-panel { display: none; padding: 24px; flex-direction: column; gap: 16px; }
.mode-panel.active { display: flex; }
.mode-desc { font-size: 13px; color: #64748b; }

/* Primary button */
.btn-primary {
  align-self: flex-start;
  padding: 10px 22px;
  background: #6366f1; color: #fff;
  border: none; border-radius: 8px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, opacity 0.15s;
}
.btn-primary:hover { background: #4f46e5; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* Upload area */
.upload-area {
  border: 2px dashed #e2e8f0; border-radius: 10px;
  padding: 32px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative; overflow: hidden;
}
.upload-area:hover { border-color: #6366f1; background: #f5f5ff; }
.upload-area.has-file { border-style: solid; border-color: #6366f1; padding: 0; }

.upload-placeholder { display: flex; flex-direction: column; gap: 4px; align-items: center; color: #94a3b8; }
.upload-icon { font-size: 28px; color: #cbd5e1; margin-bottom: 4px; }
.upload-hint { font-size: 11px; }
.upload-preview { width: 100%; max-height: 260px; object-fit: cover; border-radius: 8px; display: block; }
.upload-preview.hidden { display: none; }

/* Folder grid */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: 280px; overflow-y: auto;
}
.folder-thumb {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  cursor: pointer; border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.1s;
  position: relative;
}
.folder-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.folder-thumb:hover { transform: scale(1.03); }
.folder-thumb.selected { border-color: #6366f1; }
.folder-thumb.selected::after {
  content: "✓";
  position: absolute; inset: 0;
  background: rgba(99,102,241,0.3);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700;
}

/* Brief textarea */
.brief-textarea {
  width: 100%; min-height: 90px;
  padding: 12px; border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  font-family: inherit; font-size: 13px; color: #0f172a;
  resize: vertical; transition: border-color 0.15s;
}
.brief-textarea:focus { outline: none; border-color: #6366f1; }

/* Create status bar */
.create-status {
  margin-top: 12px; padding: 12px 16px;
  border-radius: 10px; font-size: 13px;
  background: #eff6ff; color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.create-status.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.create-status.error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ── Posts grid ── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.post-card {
  background: #fff; border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.03);
  overflow: hidden; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.post-card-image {
  position: relative; aspect-ratio: 1;
  background: #f1f5f9;
  overflow: hidden;
}
.post-card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card-no-image {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #cbd5e1; font-size: 32px;
}
.post-card-status {
  position: absolute; top: 8px; right: 8px;
}
.post-card-body { padding: 12px; }
.post-card-theme {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #6366f1; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.post-card-caption {
  font-size: 12px; color: #475569; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}
.post-card-date { font-size: 11px; color: #94a3b8; }
.platform-badges { display: flex; gap: 4px; }
.platform-badge {
  padding: 2px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 700;
}
.platform-badge.fb { background: #dbeafe; color: #1d4ed8; }
.platform-badge.ig { background: #fae8ff; color: #7e22ce; }

/* ── Status pills ── */
.pill {
  display: inline-block;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.pill-posted   { background: #dcfce7; color: #166534; }
.pill-pending  { background: #dbeafe; color: #1e40af; }
.pill-failed   { background: #fee2e2; color: #991b1b; }
.pill-waiting  { background: #fef9c3; color: #854d0e; }
.pill-skipped  { background: #f1f5f9; color: #64748b; }

.theme-tag {
  display: inline-block;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: #ede9fe; color: #5b21b6;
}

/* ── Tables ── */
.table-wrap {
  background: #fff; border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  background: #f8fafc; padding: 11px 16px;
  text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}
.data-table tbody tr { border-bottom: 1px solid #f8fafc; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody td { padding: 10px 16px; font-size: 13px; color: #374151; vertical-align: top; }
td.wrap { white-space: normal; max-width: 220px; line-height: 1.4; }

/* ── Capabilities ── */
.cap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.cap-card {
  background: #fff; border-radius: 14px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex; flex-direction: column; gap: 6px;
}
.cap-icon { font-size: 22px; }
.cap-card h3 { font-size: 14px; font-weight: 600; }
.cap-card p { font-size: 13px; color: #64748b; line-height: 1.55; }
.cap-card code { font-size: 11px; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 18px;
  width: min(820px, 100%); max-height: 90vh; overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: #f1f5f9; border: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 18px; cursor: pointer; color: #64748b;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover { background: #e2e8f0; color: #0f172a; }
.modal-body { display: flex; }
.modal-image-wrap {
  flex: 0 0 360px; min-height: 300px;
  background: #f1f5f9; border-radius: 18px 0 0 18px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.modal-image-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-no-image { color: #cbd5e1; font-size: 14px; }
.modal-info { flex: 1; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-date { font-size: 12px; color: #94a3b8; }
.modal-info h3 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #94a3b8; }
#modal-caption {
  white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 13px; line-height: 1.65; color: #374151;
  background: #f8fafc; border-radius: 8px; padding: 14px;
  flex: 1; overflow-y: auto; max-height: 300px;
}
.modal-links { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-links a {
  padding: 6px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600; text-decoration: none;
  background: #f1f5f9; color: #374151; transition: background 0.15s;
}
.modal-links a:hover { background: #e2e8f0; }

/* ── Helpers ── */
.hidden { display: none !important; }
.empty-state { color: #94a3b8; padding: 24px; text-align: center; font-size: 13px; }
a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }

@media (max-width: 700px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px; }
  .modal-body { flex-direction: column; }
  .modal-image-wrap { flex: none; border-radius: 18px 18px 0 0; min-height: 220px; }
  .posts-grid { grid-template-columns: 1fr 1fr; }
}
