:root {
  --li-blue: #0693e3;        /* site blue (dominant) */
  --li-blue-dark: #057bbf;   /* darker blue for hovers */
  --bg: #ffffff;             /* white background */
  --card: #ffffff;
  --text: #15181c;           /* near-black text, highly readable */
  --muted: #5b6470;
  --border: #dde3ea;
  --green: #057642;
  --green-bg: #ddf5e7;
  --orange: #915907;
  --orange-bg: #fdf3e2;
  --blue-bg: #e3f2fd;        /* light tint of the site blue */
  --red: #ff0000;            /* site red (accent) */
  --red-bg: #ffeaea;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 14px 28px; position: sticky; top: 0; z-index: 20;
}
.brand-block { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 42px; height: 42px; border-radius: 8px; background: var(--li-blue);
  color: #fff; font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
}
.topbar h1 { margin: 0; font-size: 19px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.field select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #fff; min-width: 200px; color: var(--text);
}
.mode-badge {
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}
.mode-badge.sim { background: var(--orange-bg); color: var(--orange); border-color: #f0d9a8; }
.mode-badge.live { background: var(--green-bg); color: var(--green); border-color: #b3e6c9; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; position: sticky; top: 71px; z-index: 15;
  background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
}
.toolbar-left { display: flex; align-items: center; gap: 20px; }
.checkall { font-size: 14px; display: flex; align-items: center; gap: 7px; cursor: pointer; }
.stats { color: var(--muted); font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 24px; padding: 10px 20px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: filter .15s, background .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--li-blue); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--li-blue-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #e4ebf1; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.pill {
  background: rgba(255,255,255,.28); border-radius: 12px; padding: 1px 9px;
  font-size: 12px; margin-left: 4px;
}

/* ---------- Grid & cards ---------- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 20px; padding: 8px 28px 60px;
}
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.card.selected { border-color: var(--li-blue); box-shadow: 0 0 0 2px var(--li-blue) inset, var(--shadow); }
.card-media { position: relative; aspect-ratio: 16 / 9; background: #e7edf2; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-check {
  position: absolute; top: 10px; left: 10px; width: 24px; height: 24px;
  cursor: pointer; accent-color: var(--li-blue);
  box-shadow: 0 0 0 3px rgba(255,255,255,.85); border-radius: 4px;
}
.badge {
  position: absolute; top: 10px; right: 10px;
  padding: 4px 10px; border-radius: 16px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
}
.badge.to-post { background: var(--blue-bg); color: var(--li-blue); }
.badge.posted  { background: var(--green-bg); color: var(--green); }
.badge.wait    { background: var(--orange-bg); color: var(--orange); }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.chip { background: #e6f4fd; color: var(--li-blue); border-radius: 12px; padding: 2px 9px; font-weight: 600; font-size: 11px; }
.card-title { margin: 0; font-size: 16px; line-height: 1.3; cursor: pointer; }
.card-title:hover { color: var(--li-blue); }
.card-summary { margin: 0; font-size: 13.5px; color: #3b434a; line-height: 1.45; }

.card-content {
  font-size: 13.5px; line-height: 1.6; color: #2b3238; white-space: pre-wrap;
  border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 10px;
}
.card-content.hidden { display: none; }
.expand-toggle {
  background: none; border: none; color: var(--li-blue); font-size: 13px;
  font-weight: 600; cursor: pointer; padding: 0; text-align: left; align-self: flex-start;
}

.card-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border);
}
.posted-info { font-size: 11.5px; color: var(--muted); }
.icon-link { color: var(--li-blue); font-size: 12.5px; text-decoration: none; font-weight: 600; }
.icon-link:hover { text-decoration: underline; }
.btn-del {
  background: none; border: 1px solid #ffc9c9; color: var(--red);
  border-radius: 18px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-del:hover { background: #ffeaea; }
.footer-actions { display: flex; align-items: center; gap: 8px; }
.btn-edit {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 18px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-edit:hover { background: var(--li-blue); color: #fff; border-color: var(--li-blue); }

/* ---------- Edit modal ---------- */
.modal-edit {
  max-width: 640px; text-align: left;
  display: flex; flex-direction: column; max-height: 90vh;
}
.modal-edit-body { overflow-y: auto; flex: 1 1 auto; margin-right: -6px; padding-right: 6px; }
.modal-edit .modal-actions {
  flex: none; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border);
}
.edit-field { display: block; margin-top: 14px; }
.edit-field > span {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px;
}
.edit-field input,
.edit-field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; resize: vertical; line-height: 1.5;
}
.edit-field input:focus,
.edit-field textarea:focus { outline: none; border-color: var(--li-blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.edit-field textarea { white-space: pre-wrap; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 14px; padding: 24px; max-width: 460px; width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-list { font-size: 13.5px; color: var(--text); margin: 8px 0 4px; padding-left: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast {
  background: #1d2226; color: #fff; padding: 12px 16px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 360px;
  animation: slidein .2s ease; border-left: 4px solid var(--li-blue);
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--orange); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { padding: 60px 28px; text-align: center; color: var(--muted); }

/* ---------- Logout link ---------- */
.logout-link {
  font-size: 12.5px; font-weight: 600; color: var(--muted); text-decoration: none;
  border: 1px solid var(--border); border-radius: 18px; padding: 6px 12px;
}
.logout-link:hover { background: #e4ebf1; color: var(--text); }
.logout-link.hidden { display: none; }

/* ---------- Login page ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.login-card h1 { margin: 6px 0 0; font-size: 20px; }
.login-sub { margin: 0 0 6px; color: var(--muted); font-size: 13.5px; }
.login-card input {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 13px; font-size: 15px; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--li-blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.login-card .btn { width: 100%; }
.login-error {
  width: 100%; background: #ffeaea; color: var(--red); border: 1px solid #ffc9c9;
  border-radius: 8px; padding: 8px 12px; font-size: 13px;
}

/* ---------- Preview button (card) ---------- */
.btn-preview {
  align-self: flex-start; background: #e6f4fd; color: var(--li-blue);
  border: 1px solid #b9e2f9; border-radius: 18px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-preview:hover { background: var(--li-blue); color: #fff; border-color: var(--li-blue); }

/* ---------- Edit: image section ---------- */
.edit-image { display: flex; align-items: center; gap: 14px; }
.edit-image-preview {
  width: 110px; height: 110px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); background: #eef3f7; flex: none;
}
.edit-image-empty {
  width: 110px; height: 110px; display: grid; place-items: center; flex: none;
  border: 1px dashed var(--border); border-radius: 8px; color: var(--muted);
  font-size: 12.5px; background: #f5f8fb;
}
.edit-image-actions { display: flex; flex-direction: column; gap: 8px; }
.edit-image-actions .btn { padding: 8px 14px; font-size: 13px; }
.btn-file { cursor: pointer; display: inline-block; text-align: center; }
.edit-image-url {
  margin-top: 10px; width: 100%; border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; font-family: inherit;
  color: var(--text);
}
.edit-image-url:focus { outline: none; border-color: var(--li-blue); box-shadow: 0 0 0 2px var(--blue-bg); }

/* ---------- Preview modal (LinkedIn post look) ---------- */
.pv-card {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3); position: relative;
  max-height: 88vh; overflow-y: auto; padding: 16px 16px 8px;
}
.pv-close {
  position: absolute; top: 8px; right: 12px; border: none; background: none;
  font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer;
}
.pv-close:hover { color: var(--text); }
.pv-head {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  margin-bottom: 12px; padding-right: 26px;
}
.pv-logo { height: 30px; width: auto; display: block; }
.pv-headinfo { display: flex; flex-direction: column; }
.pv-headinfo strong { font-size: 15px; }
.pv-sub { font-size: 12px; color: var(--muted); }
.pv-text {
  font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-wrap;
  word-wrap: break-word; overflow-wrap: anywhere; margin-bottom: 12px;
}
.pv-media { margin: 0 -16px; background: #e7edf2; }
.pv-media img { width: 100%; display: block; }
.pv-bar {
  text-align: center; color: var(--muted); font-size: 13px; font-weight: 600;
  border-top: 1px solid var(--border); margin-top: 8px; padding: 12px 0 8px;
}

/* ---------- Logo REAUTOMATICO ---------- */
.logo-img { height: 40px; width: auto; display: block; }

/* ---------- Search & filters ---------- */
.search {
  border: 1px solid var(--border); border-radius: 20px; padding: 7px 14px;
  font-size: 13.5px; font-family: inherit; background: #fff; min-width: 200px; color: var(--text);
}
.search:focus { outline: none; border-color: var(--li-blue); box-shadow: 0 0 0 2px var(--blue-bg); }
.filter-select {
  border: 1px solid var(--border); border-radius: 20px; padding: 7px 12px;
  font-size: 13.5px; background: #fff; color: var(--text); cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--li-blue); }

/* Status filter: segmented pills */
.seg { display: inline-flex; background: #e7edf2; border-radius: 20px; padding: 3px; gap: 2px; }
.seg-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 12.5px; font-weight: 600; padding: 6px 13px; border-radius: 16px;
  transition: background .15s, color .15s; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: #fff; color: var(--li-blue); box-shadow: var(--shadow); }

/* Edit select field (category) */
#edit-category {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; cursor: pointer;
}
#edit-category:focus { outline: none; border-color: var(--li-blue); box-shadow: 0 0 0 2px var(--blue-bg); }

/* ---------- Broken image message ---------- */
.img-broken {
  background: #ffeaea; color: var(--red); border: 1px solid #ffc9c9;
  border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.4; font-weight: 600;
}

/* ---------- Bouton "View on LinkedIn" ---------- */
.btn-li {
  background: #e6f4fd; border: 1px solid #b9e2f9; color: var(--li-blue);
  border-radius: 18px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn-li:hover { background: var(--li-blue); color: #fff; border-color: var(--li-blue); }
