* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f5f5f5; --card: #fff; --text: #1a1a1a; --muted: #777;
  --border: #e0e0e0; --primary: #0a66c2; --primary-hover: #004182;
  --success: #0f8b42; --danger: #d32f2f; --warning: #f57c00;
  --badge-draft: #9e9e9e; --badge-approved: #0a66c2; --badge-scheduled: #7b1fa2;
  --badge-published: #0f8b42; --badge-failed: #d32f2f; --badge-publishing: #f57c00;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

nav { background: var(--primary); color: #fff; padding: 0 1.5rem; display: flex; align-items: center; height: 56px; gap: 2rem; }
nav .logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
nav .nav-links { display: flex; gap: 1rem; }
nav .nav-links a { color: rgba(255,255,255,.85); text-decoration: none; font-size: .9rem; }
nav .nav-links a:hover { color: #fff; }

main { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }
h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }
h2 { margin-bottom: 1rem; font-size: 1.2rem; }
a { color: var(--primary); }

.btn { display: inline-block; padding: .5rem 1rem; background: var(--primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: .9rem; }
.btn:hover { background: var(--primary-hover); }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-secondary { background: var(--muted); }
.btn-publish { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn.active { outline: 2px solid var(--text); outline-offset: 2px; }

.status-bar { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1.5rem; font-size: .9rem; }
.status-bar.connected { background: #e8f5e9; color: #1b5e20; }
.status-bar.disconnected { background: #fff3e0; color: #e65100; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--card); padding: 1.25rem; border-radius: 8px; text-align: center; border: 1px solid var(--border); }
.stat-num { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--muted); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
@media (max-width: 768px) { .two-col, .stats-grid { grid-template-columns: 1fr; } .form-row { flex-direction: column; } }

.post-card { background: var(--card); padding: 1rem; border-radius: 8px; border: 1px solid var(--border); margin-bottom: .75rem; }
.post-meta { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.post-preview { font-size: .9rem; color: var(--text); white-space: pre-line; }
.post-time { font-size: .8rem; color: var(--muted); }

.badge { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 600; background: var(--border); color: var(--text); text-transform: uppercase; }
.badge-draft { background: var(--badge-draft); color: #fff; }
.badge-approved { background: var(--badge-approved); color: #fff; }
.badge-scheduled { background: var(--badge-scheduled); color: #fff; }
.badge-published { background: var(--badge-published); color: #fff; }
.badge-failed { background: var(--badge-failed); color: #fff; }
.badge-publishing { background: var(--badge-publishing); color: #fff; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.filter-bar { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.posts-table-wrap { overflow-x: auto; }
.posts-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 8px; overflow: hidden; }
.posts-table th, .posts-table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .85rem; }
.posts-table th { background: #fafafa; font-weight: 600; }
.post-content-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { white-space: nowrap; display: flex; gap: .25rem; }

.post-form { max-width: 700px; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 6px; font-size: .9rem; font-family: inherit; }
.form-group textarea { resize: vertical; line-height: 1.6; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }
.char-count { font-size: .8rem; color: var(--muted); }

.settings-section { background: var(--card); padding: 1.5rem; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 1.5rem; }
.settings-form { max-width: 500px; }
.settings-section ol { padding-left: 1.5rem; }
.settings-section li { margin-bottom: .5rem; font-size: .9rem; }

.muted { color: var(--muted); font-size: .9rem; }
.error { color: var(--danger); font-weight: 600; margin-bottom: 1rem; }

.login-box { max-width: 360px; margin: 15vh auto; padding: 2rem; background: var(--card); border-radius: 12px; border: 1px solid var(--border); text-align: center; }
.login-box h1 { font-size: 1.3rem; }
.login-box input { width: 100%; padding: .6rem; margin: 1rem 0; border: 1px solid var(--border); border-radius: 6px; }
.login-box button { width: 100%; }

/* ── LinkedIn Preview Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #666;
  z-index: 1;
  line-height: 1;
}
.modal-close:hover { color: #000; }

/* LinkedIn card inside modal */
.li-card { padding: 16px; }
.li-header { display: flex; gap: 10px; margin-bottom: 14px; }
.li-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #0a66c2;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.2rem;
  flex-shrink: 0;
}
.li-info { flex: 1; min-width: 0; }
.li-name { font-weight: 600; font-size: .95rem; color: #000; }
.li-title { font-size: .8rem; color: #666; line-height: 1.3; }
.li-meta { font-size: .75rem; color: #999; margin-top: 2px; }

.li-body {
  font-size: .9rem;
  line-height: 1.5;
  color: #191919;
  margin-bottom: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.li-body p { margin: 0 0 4px 0; }
.li-body br { display: block; content: ""; margin-top: 8px; }

.li-image {
  width: 100%;
  display: block;
  border-top: 1px solid #e0e0e0;
  border-bottom: 1px solid #e0e0e0;
}

.li-engagement {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: .78rem;
  color: #666;
}
.li-reactions-row { display: flex; gap: 2px; align-items: center; }

.li-divider {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 0;
}

.li-action-bar {
  display: flex;
  justify-content: space-around;
  padding: 4px 0;
}
.li-action-bar button {
  background: none;
  border: none;
  font-size: .82rem;
  color: #666;
  cursor: default;
  padding: 10px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* View button style */
.btn-view {
  background: #0a66c2 !important;
  color: #fff !important;
}
.btn-view:hover { background: #004182 !important; }

/* Image preview in edit form */
.current-image-preview {
  margin: 8px 0;
  max-width: 300px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

/* Approve button */
.btn-approve {
  background: #057642 !important;
  color: #fff !important;
}
.btn-approve:hover { background: #03572f !important; }

.badge-approved { background: #057642; }
.badge-scheduled { background: #0a66c2; }

/* ── Carousel viewer in preview ── */
.carousel-viewer {
  position: relative;
  width: 100%;
}
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.5);
  color: #fff;
  border: none;
  font-size: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }
.carousel-nav:hover { background: rgba(0,0,0,.7); }
.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 0;
}
.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
  cursor: pointer;
}
.carousel-dot.active { background: #0a66c2; }

/* ── Slide editor in form ── */
.slide-editor {
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.slide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.slide-editor input,
.slide-editor textarea {
  width: 100%;
  margin-bottom: 6px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  font-size: .9rem;
  box-sizing: border-box;
}
.slide-editor textarea { resize: vertical; }
