/* ==========================================================================
   AI Social Media Management Platform — design system
   Warm neutral ground, dark ink sidebar, coral accent. Built on Bootstrap 5.
   ========================================================================== */

:root {
  --ink: #17161f;
  --ink-2: #24222f;
  --ink-3: #34313f;
  --ground: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --line: #e8e5dd;
  --line-strong: #d8d4c9;
  --text: #1f1d27;
  --muted: #6d6a78;
  --faint: #9a97a3;

  --accent: #f0532f;
  --accent-hover: #d9441f;
  --accent-soft: #fff1ec;
  --accent-ring: rgba(240, 83, 47, .22);

  --success: #1b8f63;
  --success-soft: #e7f6ef;
  --warning: #b7780b;
  --warning-soft: #fcf3de;
  --danger: #cc3d3d;
  --danger-soft: #fcecec;
  --info: #3659c9;
  --info-soft: #ebf0fd;

  --facebook: #1877f2;
  --instagram: #d62976;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(23, 22, 31, .05);
  --shadow: 0 1px 2px rgba(23, 22, 31, .04), 0 6px 20px rgba(23, 22, 31, .06);
  --sidebar-w: 264px;

  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--text);
  --bs-body-bg: var(--ground);
  --bs-border-color: var(--line);
  --bs-link-color: var(--accent);
  --bs-link-color-rgb: 240, 83, 47;
  --bs-link-hover-color: var(--accent-hover);
  --bs-link-hover-color-rgb: 217, 68, 31;
  --bs-primary: var(--accent);
  --bs-primary-rgb: 240, 83, 47;
}

html { font-size: 15px; }
body {
  font-family: var(--bs-body-font-family);
  background: var(--ground);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
}
h1, h2, h3, h4, h5, h6 { color: var(--ink); font-weight: 700; letter-spacing: -.015em; }
.tabular { font-variant-numeric: tabular-nums; }
.text-muted, .text-secondary { color: var(--muted) !important; }
a { text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- App shell ----------------------------------------------------------- */
.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--ink);
  color: #cfccd8;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 1040;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.25rem 1.25rem 1rem;
  color: #fff;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: conic-gradient(from 210deg, #f0532f, #ff8a3d, #d62976, #f0532f);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: .95rem;
  box-shadow: 0 4px 14px rgba(240, 83, 47, .35);
}
.brand-name { font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.brand-name small { display: block; font-weight: 500; color: #8f8b9c; font-size: .72rem; letter-spacing: .02em; }

.nav-section { padding: .35rem .75rem; }
.nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: #7b7788; padding: .9rem .6rem .35rem; font-weight: 600;
}
.side-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .52rem .65rem; border-radius: 9px;
  color: #cfccd8; font-weight: 500; font-size: .92rem;
  position: relative;
  transition: background .15s, color .15s;
}
.side-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: #9793a5; }
.side-link:hover { background: var(--ink-2); color: #fff; }
.side-link:hover i { color: #fff; }
.side-link.active { background: var(--ink-3); color: #fff; }
.side-link.active i { color: var(--accent); }
.side-link.active::before {
  content: ""; position: absolute; left: -.75rem; top: .45rem; bottom: .45rem;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.side-link.sub { padding-left: 2.55rem; font-size: .88rem; }
.side-link.disabled { color: #6f6b7c; cursor: default; pointer-events: none; }
.side-link.disabled i { color: #5b5868; }
.soon-tag {
  margin-left: auto; font-size: .62rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: #8f8b9c; border: 1px solid #3b3847;
  border-radius: 999px; padding: .08rem .45rem;
}
.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem 1.25rem; font-size: .75rem; color: #7b7788; border-top: 1px solid #262430; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 1030;
  background: rgba(246, 245, 241, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1.75rem;
  min-height: 64px;
}
.topbar .page-title { font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--ink); }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: inline-grid; place-items: center; color: var(--text);
}

.content { padding: 1.75rem; max-width: 1320px; width: 100%; }

/* ---- Company switcher ---------------------------------------------------- */
.company-switcher .dropdown-toggle {
  display: flex; align-items: center; gap: .6rem;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: .35rem .7rem .35rem .4rem;
  box-shadow: var(--shadow-sm); max-width: 290px;
  color: var(--text);
}
.company-switcher .dropdown-toggle:hover { border-color: var(--line-strong); }
.company-switcher .dropdown-toggle::after { margin-left: .35rem; color: var(--faint); }
.switcher-text { min-width: 0; text-align: left; line-height: 1.15; }
.switcher-text .label { font-size: .66rem; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.switcher-text .name { font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.company-switcher .dropdown-menu { min-width: 300px; padding: .4rem; border-radius: 12px; border-color: var(--line); box-shadow: var(--shadow); }
.company-option {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  border: 0; background: transparent; text-align: left;
  padding: .45rem .5rem; border-radius: 8px; color: var(--text);
}
.company-option:hover { background: var(--surface-2); }
.company-option.current { background: var(--accent-soft); }
.company-option .meta { font-size: .75rem; color: var(--muted); }

.avatar {
  --size: 32px;
  width: var(--size); height: var(--size); flex: 0 0 var(--size);
  border-radius: 9px; display: inline-grid; place-items: center;
  font-weight: 700; font-size: calc(var(--size) * .38); color: #fff;
  background: var(--ink-3);
}
.avatar.round { border-radius: 50%; }
.avatar.lg { --size: 48px; border-radius: 13px; }
.avatar[data-tone="0"] { background: #f0532f; }
.avatar[data-tone="1"] { background: #3659c9; }
.avatar[data-tone="2"] { background: #1b8f63; }
.avatar[data-tone="3"] { background: #9b3fc2; }
.avatar[data-tone="4"] { background: #c7771b; }
.avatar[data-tone="5"] { background: #d62976; }
.avatar[data-tone="6"] { background: #0f8a9a; }
.avatar[data-tone="7"] { background: #4b4857; }

/* ---- Cards & surfaces ---------------------------------------------------- */
.card-x {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-x-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
}
.card-x-header h2, .card-x-header h3 { font-size: 1rem; margin: 0; }
.card-x-body { padding: 1.25rem; }
.card-x-footer { padding: .9rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.6rem; margin: 0; }
.page-header .lead-text { color: var(--muted); margin: .25rem 0 0; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; color: var(--accent); margin-bottom: .3rem; }

.stat {
  padding: 1.1rem 1.2rem; height: 100%;
  display: flex; flex-direction: column; gap: .3rem;
}
.stat .stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: .4rem; }
.stat .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .stat-foot { font-size: .8rem; color: var(--muted); }

.progress-thin { height: 6px; border-radius: 99px; background: #eeebe4; overflow: hidden; }
.progress-thin > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---- Setup checklist ----------------------------------------------------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: .85rem; align-items: flex-start; padding: .8rem 0; border-top: 1px dashed var(--line); }
.checklist li:first-child { border-top: 0; padding-top: 0; }
.check-dot {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  border: 2px solid var(--line-strong); display: grid; place-items: center; font-size: .8rem; color: transparent;
}
.checklist li.done .check-dot { background: var(--success); border-color: var(--success); color: #fff; }
.checklist li.locked .check-dot { border-style: dashed; color: var(--faint); }
.checklist .title { font-weight: 600; }
.checklist li.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.checklist .desc { font-size: .84rem; color: var(--muted); }

/* ---- Channel rows -------------------------------------------------------- */
.channel { display: flex; align-items: center; gap: .8rem; padding: .75rem 0; }
.channel + .channel { border-top: 1px solid var(--line); }
.channel-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 1.1rem; }
.channel-icon.fb { background: var(--facebook); }
.channel-icon.ig { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fd5949 45%, #d6249f 60%, #285aeb 90%); }

/* ---- Activity feed ------------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { position: relative; padding: 0 0 1rem 1.4rem; }
.feed li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.feed li::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: 2px; width: 2px; background: var(--line); }
.feed li:last-child { padding-bottom: 0; }
.feed li:last-child::after { display: none; }
.feed .what { font-size: .9rem; }
.feed .when { font-size: .76rem; color: var(--faint); }

/* ---- Badges -------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; background: #efede7; color: var(--ink-3); white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent-hover); }
.pill.success { background: var(--success-soft); color: var(--success); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.role-Owner { background: #fff1ec; color: #c23a18; }
.role-Admin { background: #ebf0fd; color: #2f4fb3; }
.role-ContentManager { background: #e7f6ef; color: #17784f; }
.role-Approver { background: #f4ecfb; color: #7e33a3; }
.role-Viewer { background: #efede7; color: #55525f; }

/* ---- Forms --------------------------------------------------------------- */
.form-label { font-weight: 600; font-size: .86rem; color: var(--ink-3); margin-bottom: .35rem; }
.form-control, .form-select {
  border-color: var(--line-strong); border-radius: var(--radius-sm);
  padding: .55rem .8rem; font-size: .93rem; background-color: var(--surface);
}
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 .22rem var(--accent-ring); }
.form-control:disabled, .form-select:disabled { background: var(--surface-2); }
.form-text { color: var(--faint); font-size: .8rem; }
.form-section + .form-section { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1.5rem; }
.form-section-title { font-size: .95rem; margin-bottom: .2rem; }
.form-section-desc { font-size: .84rem; color: var(--muted); margin-bottom: 1rem; }
.field-validation-error, .text-danger { color: var(--danger) !important; font-size: .82rem; }
.input-validation-error { border-color: var(--danger) !important; }
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }

.btn { border-radius: var(--radius-sm); font-weight: 600; padding: .55rem 1rem; font-size: .92rem; }
.btn-sm { padding: .35rem .7rem; font-size: .83rem; border-radius: 8px; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-hover); --bs-btn-hover-border-color: var(--accent-hover); --bs-btn-active-bg: var(--accent-hover); --bs-btn-active-border-color: var(--accent-hover); --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); --bs-btn-focus-shadow-rgb: 240, 83, 47; }
.btn-dark { --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink); --bs-btn-hover-bg: var(--ink-3); --bs-btn-hover-border-color: var(--ink-3); }
.btn-light { --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line-strong); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--line-strong); --bs-btn-color: var(--text); }
.btn-ghost-danger { color: var(--danger); background: transparent; border: 1px solid transparent; }
.btn-ghost-danger:hover { background: var(--danger-soft); color: var(--danger); }

.alert { border-radius: var(--radius-sm); border: 1px solid transparent; font-size: .92rem; }
.alert-success { background: var(--success-soft); color: #11613f; border-color: #c9ebdb; }
.alert-danger { background: var(--danger-soft); color: #9d2a2a; border-color: #f3cfcf; }
.alert-info { background: var(--info-soft); color: #28459f; border-color: #d3ddf8; }
.alert-warning { background: var(--warning-soft); color: #8a5a06; border-color: #f1dfb2; }

/* ---- Tables -------------------------------------------------------------- */
.table-x { margin: 0; }
.table-x thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--line); padding: .7rem 1.25rem; white-space: nowrap; }
.table-x td { padding: .8rem 1.25rem; vertical-align: middle; border-color: var(--line); }
.table-x tbody tr:last-child td { border-bottom: 0; }

/* ---- Empty states -------------------------------------------------------- */
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty .empty-icon { width: 52px; height: 52px; margin: 0 auto .8rem; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 1.4rem; color: var(--faint); }
.empty h3 { font-size: 1rem; margin-bottom: .3rem; }
.empty p { font-size: .87rem; margin: 0 auto; max-width: 340px; }

/* ---- Company cards ------------------------------------------------------- */
.company-card { padding: 1.2rem; display: flex; flex-direction: column; gap: .9rem; height: 100%; transition: border-color .15s, box-shadow .15s; }
.company-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.company-card.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.company-card h3 { font-size: 1.02rem; margin: 0; }

/* ---- Completion ring ----------------------------------------------------- */
.ring { --p: 0; --size: 112px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), #eeebe4 0); margin: 0 auto; }
.ring > div { width: calc(var(--size) - 18px); height: calc(var(--size) - 18px); border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.swatches { display: flex; gap: .35rem; flex-wrap: wrap; min-height: 22px; }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.08); }

/* ---- Auth pages ---------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-aside {
  background: var(--ink); color: #d9d6e2; padding: 2.5rem 3rem; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}
.auth-aside::after {
  content: ""; position: absolute; width: 520px; height: 520px; right: -180px; bottom: -200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 83, 47, .45), rgba(214, 41, 118, .18) 45%, transparent 70%);
}
.auth-aside h1 { color: #fff; font-size: 2.3rem; line-height: 1.12; letter-spacing: -.03em; max-width: 470px; }
.auth-aside .accent { color: #ff8a66; }
.auth-points { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .9rem; max-width: 440px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: .75rem; align-items: flex-start; }
.auth-points i { color: #ff8a66; font-size: 1.1rem; margin-top: .05rem; }
.auth-points strong { color: #fff; font-weight: 600; display: block; }
.auth-points span { font-size: .88rem; color: #a7a3b3; }
.auth-main { display: grid; place-items: center; padding: 2.5rem 1.5rem; background: var(--ground); }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h2 { font-size: 1.6rem; margin-bottom: .3rem; }

/* ---- Legal pages (public: privacy, terms, data deletion) ------------------ */
.legal-body-bg { background: var(--ground); }
.legal-topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1.75rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
/* The brand block is styled for the dark sidebar; on this light header it needs ink, not white. */
.legal-topbar .sidebar-brand { color: var(--ink); }
.legal-topbar .brand-name small { color: var(--muted); }
.legal-page { max-width: 820px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.legal-page .page-header { margin-bottom: 1.25rem; }
.legal-content { font-size: .95rem; line-height: 1.65; color: var(--text); }
.legal-content .lead-in { font-size: 1.02rem; color: var(--muted); margin-bottom: 1.5rem; }
.legal-content section + section { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.legal-content h2 { font-size: 1.12rem; margin-bottom: .6rem; }
.legal-content h3 { font-size: .98rem; margin: 1.1rem 0 .4rem; color: var(--ink-3); }
.legal-content ul, .legal-content ol { padding-left: 1.2rem; }
.legal-content li { margin-bottom: .45rem; }
.legal-content code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: .05rem .3rem; font-size: .86em; color: var(--ink-3); }
.deletion-steps li { margin-bottom: .7rem; }
.deletion-box { background: var(--surface-2); margin-top: 1rem; }
.impact-list { list-style: none; padding: 0; }
.impact-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding: .5rem 0; border-top: 1px dashed var(--line); }
.impact-list li:first-child { border-top: 0; }
.deletion-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.legal-footer { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-top: 1.5rem; }
.legal-links { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .82rem; }
.legal-links a { color: var(--muted); }
.legal-links a:hover { color: var(--accent); }
.legal-links .sep { color: var(--faint); }
.app-footer { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.auth-footer { margin-top: 1.75rem; display: flex; justify-content: center; }

/* ---- Utilities ----------------------------------------------------------- */
.gap-grid { row-gap: 1.25rem; }
.min-w-0 { min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider-dot::before { content: "·"; margin: 0 .4rem; color: var(--faint); }
.fade-in { animation: fadeIn .25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- Responsive ---------------------------------------------------------- */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .22s ease; }
  body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(23, 22, 31, .45); z-index: 1035; }
  .topbar { padding: .6rem 1rem; }
  .content { padding: 1.25rem 1rem; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
@media (max-width: 575.98px) {
  .company-switcher .dropdown-toggle { max-width: 190px; }
  .company-switcher .switcher-text .label { display: none; }
  .page-header h1 { font-size: 1.35rem; }
  .table-x td, .table-x thead th { padding-left: .85rem; padding-right: .85rem; }
}
