/* AdCampaign Manager — Phase 1 UI. Clean, responsive, light/dark aware. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1a1d24;
  --text-dim: #626879;
  --primary: #3b5bdb;
  --primary-ink: #ffffff;
  --success: #2f9e44;
  --warn: #e8890c;
  --danger: #e03131;
  --info: #1c7ed6;
  --shadow: 0 1px 3px rgba(20,25,40,.08), 0 1px 2px rgba(20,25,40,.04);
  --radius: 10px;
  --sidebar-w: 232px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b; --surface: #1c1f26; --surface-2: #23262f; --border: #2c303a;
    --text: #e7e9ee; --text-dim: #9aa1b1; --primary: #5c7cfa; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
h1,h2,h3,h4 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
small, .dim { color: var(--text-dim); }

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 8px;
  color: var(--text); cursor: pointer; font-weight: 500; user-select: none;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary); color: var(--primary-ink); }
.nav-item .ic { width: 18px; text-align: center; opacity: .9; }
.nav-spacer { flex: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.content { padding: 24px; max-width: 1200px; width: 100%; }
.mobile-only { display: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn.success { background: var(--success); color: #fff; border-color: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Cards / grid ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.gallery { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* ── Forms ── */
label { display: block; font-weight: 600; font-size: 12px; margin: 12px 0 4px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }
input, textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

/* ── Badges / status ── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--text-dim); }
.badge.Draft { background: #e9ecef; color: #495057; }
.badge.AwaitingReview, .badge.Awaiting.Review { background: #fff3bf; color: #a5730a; }
.badge.Approved { background: #d3f9d8; color: #2b8a3e; }
.badge.Scheduled { background: #d0ebff; color: #1971c2; }
.badge.Active, .badge.Published { background: #d3f9d8; color: #2b8a3e; }
.badge.Paused { background: #ffe3e3; color: #c92a2a; }
.badge.Rejected { background: #ffe3e3; color: #c92a2a; }
.badge.Completed { background: #e5dbff; color: #6741d9; }
.badge.plat { text-transform: capitalize; background: var(--surface-2); }

/* ── Table ── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; color: var(--text-dim); letter-spacing: .04em; }
tr:hover td { background: var(--surface-2); }

/* ── Media gallery ── */
.asset { position: relative; overflow: hidden; }
.asset .thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; background: var(--surface-2); display: block; }
.asset .meta { padding: 8px 10px; font-size: 12px; }
.asset .meta .fn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 34px; text-align: center; color: var(--text-dim); background: var(--surface); }
.dropzone.drag { border-color: var(--primary); background: var(--surface-2); color: var(--text); }

/* ── Ad preview mockups ── */
.previews { display: flex; gap: 16px; flex-wrap: wrap; }
.mock { width: 320px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; color: #050505; box-shadow: var(--shadow); }
.mock * { box-sizing: border-box; }
.mock .m-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.mock .m-ava { width: 34px; height: 34px; border-radius: 50%; background: #d0d4dc; flex: 0 0 34px; }
.mock .m-name { font-weight: 600; font-size: 13px; }
.mock .m-sub { font-size: 11px; color: #65676b; }
.mock .m-body { padding: 0 12px 10px; font-size: 13px; white-space: pre-wrap; }
.mock .m-img { width: 100%; aspect-ratio: 1.91/1; object-fit: cover; background: linear-gradient(135deg,#e9ecf3,#d7dcea); display: flex; align-items: center; justify-content: center; color: #97a; font-size: 12px; }
.mock .m-cta { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: #f0f2f5; }
.mock .m-cta .h { font-weight: 600; font-size: 13px; }
.mock .m-cta .b { background: #e4e6eb; border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: 600; }
.mock.story { width: 240px; aspect-ratio: 9/16; position: relative; color: #fff; background: #222; }
.mock.story .m-img { height: 100%; aspect-ratio: auto; position: absolute; inset: 0; }
.mock.story .s-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 12px; background: linear-gradient(180deg, rgba(0,0,0,.35), transparent 30%, transparent 70%, rgba(0,0,0,.55)); }
.mock.google { width: 340px; color: #202124; padding: 14px; background: #fff; }
.mock.google .g-url { color: #202124; font-size: 12px; }
.mock.google .g-title { color: #1a0dab; font-size: 18px; margin: 3px 0; }
.mock.google .g-desc { color: #4d5156; font-size: 13px; }
.mock.tiktok { width: 240px; aspect-ratio: 9/16; position: relative; background: #000; color: #fff; }
.mock .plat-tag { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 10px; z-index: 2; }

/* ── Concept / review ── */
.concept { margin-bottom: 22px; }
.concept-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.variant-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.variant-tab { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); cursor: pointer; font-weight: 600; font-size: 12px; }
.variant-tab.active { background: var(--primary); color: #fff; border-color: transparent; }
.review-cols { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 13px; }
.kv .k { color: var(--text-dim); font-weight: 600; }

/* ── Misc ── */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.empty { text-align: center; color: var(--text-dim); padding: 50px 20px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.banner.warn { background: #fff3bf; color: #92610a; }
.banner.info { background: #d0ebff; color: #1864ab; }

/* ── Connected Accounts ── */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.conn-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.conn-field input { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; font-family: inherit; }
.conn-field input:focus { outline: none; border-color: var(--primary); }
.conn-steps { margin: 8px 0 4px; font-size: 13px; }
.conn-steps summary { cursor: pointer; color: var(--text-dim); font-weight: 600; }

/* ── Modal ── */
.modal-bg { position: fixed; inset: 0; background: rgba(10,12,20,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.3); width: 100%; max-width: 680px; }
.modal .m-title { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal .m-content { padding: 20px; }
.modal .m-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { cursor: pointer; font-size: 20px; color: var(--text-dim); background: none; border: none; }

/* ── Toast ── */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; max-width: 340px; }
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--success); color: #fff; }

/* ── Login ── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; }
.login-card { width: 340px; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .form-grid { grid-template-columns: 1fr; }
  .review-cols { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}
