/* 4W Ads 3.0 — Banner Studio */

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --line: #e3e2df;
  --line-strong: #cfcecb;
  --text: #16181c;
  --muted: #6a6f78;
  --accent: #e8543f;
  --accent-soft: #fdeeea;
  --ok: #1a7f52;
  --warn: #b45309;
  --danger: #c2413a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 18, 22, .05), 0 8px 24px rgba(16, 18, 22, .06);
  --shadow-lg: 0 24px 64px rgba(16, 18, 22, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Vlastni display v pravidlech nize by jinak prebil atribut hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 0.98rem; }
h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
p { margin: 0; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .82rem; line-height: 1.45; }

/* --------------------------------------------------------------- topbar - */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
}
.brand-mark.small { width: 28px; height: 28px; font-size: .74rem; border-radius: 8px; }

.tabs { display: flex; gap: 2px; margin-left: 10px; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 999px;
  font: inherit; font-size: .88rem; color: var(--muted);
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--text); color: #fff; }

.status-chip {
  font-size: .76rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface);
  white-space: nowrap;
}
.status-chip.bad { color: var(--danger); border-color: #f0c8c5; background: #fdf1f0; }

/* --------------------------------------------------------------- tlacitka - */

.btn {
  font: inherit;
  font-size: .88rem;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--text); border-color: var(--text); color: #fff; }
.btn.primary:hover { background: #2b2f36; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: .82rem; }
.btn.block { width: 100%; justify-content: center; }
.btn.tall { align-self: stretch; }

/* ----------------------------------------------------------------- views - */

.view { display: none; padding: 26px 24px 60px; max-width: 1500px; margin: 0 auto; }
.view.active { display: block; }
.view.campaign-view { max-width: none; padding: 0; }

.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 22px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.card-grid.narrow { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-content: start; }

.campaign-card, .brand-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.campaign-card:hover, .brand-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.campaign-card .thumb {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: var(--surface-2) center/cover no-repeat;
  border: 1px solid var(--line);
  margin-bottom: 10px;
  display: grid; place-items: center;
  color: var(--muted); font-size: .78rem;
}
.campaign-card h3 { font-size: .95rem; text-transform: none; letter-spacing: -.01em; color: var(--text); }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: .76rem; color: var(--muted); }
.card-actions { display: flex; gap: 4px; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }

.empty-note { color: var(--muted); font-size: .88rem; padding: 24px 0; }

/* ------------------------------------------------------------- formulare - */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: .78rem; font-weight: 550; color: var(--muted); }
.field > span b { font-weight: 600; color: var(--text); float: right; }

input[type=text], input:not([type]), input[type=password], input[type=url], textarea, select {
  font: inherit;
  font-size: .88rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(22, 24, 28, .08);
}

input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] {
  width: 100%; height: 32px; padding: 2px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.check { display: flex; align-items: center; gap: 8px; font-size: .84rem; margin-bottom: 8px; cursor: pointer; }
.check.inline { margin: 0; font-size: .82rem; color: var(--muted); }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.field-group { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin: 0 0 14px; }
.field-group legend { font-size: .76rem; font-weight: 600; color: var(--muted); padding: 0 6px; }

.color-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-field { display: flex; flex-direction: column; gap: 4px; }
.color-field span { font-size: .72rem; color: var(--muted); }

.form-actions { display: flex; gap: 8px; margin-top: 14px; }
.form-error { color: var(--danger); font-size: .82rem; margin-top: 8px; }

/* ---------------------------------------------------------------- upload - */

.upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.upload-slot {
  display: flex; flex-direction: column; gap: 2px; justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-2);
  cursor: pointer;
  min-height: 58px;
  transition: border-color .12s ease, background .12s ease;
}
.upload-slot:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-slot.wide { width: 100%; }
.upload-slot.has-file { border-style: solid; border-color: var(--line-strong); background: var(--surface); }
.upload-label { font-size: .82rem; font-weight: 550; }
.upload-state { font-size: .74rem; color: var(--muted); word-break: break-all; }

.thumb-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.thumb-strip figure {
  margin: 0; width: 76px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
}
.thumb-strip img { display: block; width: 100%; height: 54px; object-fit: contain; background:
  repeating-conic-gradient(#eeedeb 0% 25%, #ffffff 0% 50%) 50% / 12px 12px; }
.thumb-strip figcaption { font-size: .66rem; color: var(--muted); padding: 3px 5px; text-align: center; }

.font-sample {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; background: var(--surface-2);
  font-size: 1.15rem; line-height: 1.3;
}

/* -------------------------------------------------------------- kampan - */

.campaign-head {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.campaign-title {
  flex: 1; max-width: 420px;
  font-size: 1.02rem; font-weight: 600;
  border-color: transparent; background: transparent;
}
.campaign-title:hover { border-color: var(--line); }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.save-state { font-size: .76rem; color: var(--muted); }

.campaign-body {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  align-items: start;
  gap: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
  height: calc(100vh - 55px);
  overflow-y: auto;
  position: sticky;
  top: 55px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface);
}
.panel h2 { margin-bottom: 10px; }
.panel-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.subhead { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 14px 0 8px; }
.copy-fields { margin-top: 10px; }

.template-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.template-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px; cursor: pointer; background: var(--surface-2);
  transition: border-color .12s ease, background .12s ease;
}
.template-card:hover { border-color: var(--line-strong); }
.template-card.active { border-color: var(--text); background: var(--surface); box-shadow: 0 0 0 2px rgba(22,24,28,.08); }
.template-card .swatch { height: 42px; border-radius: 6px; margin-bottom: 6px; display: flex; overflow: hidden; }
.template-card .swatch i { flex: 1; }
.template-card strong { display: block; font-size: .8rem; font-weight: 600; }
.template-card small { font-size: .7rem; color: var(--muted); }

.size-list { display: flex; flex-direction: column; gap: 2px; }
.size-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; font-size: .82rem; cursor: pointer;
}
.size-row:hover { background: var(--surface-2); }
.size-row input { accent-color: var(--accent); }
.size-row .dims { color: var(--muted); font-size: .76rem; margin-left: auto; font-variant-numeric: tabular-nums; }
.size-group-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 10px 0 4px; }

/* --------------------------------------------------------------- nahledy - */

.preview-area { padding: 18px 22px 60px; min-width: 0; }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.preview-tools { display: flex; align-items: center; gap: 12px; }
.mini-select { width: auto; font-size: .8rem; padding: 5px 8px; }

.banner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.banner-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.banner-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.banner-card header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: .78rem;
}
.banner-card header .size { font-weight: 600; font-variant-numeric: tabular-nums; }
.banner-card header .name { color: var(--muted); }
.banner-stage {
  padding: 14px;
  background: repeating-conic-gradient(#efeeec 0% 25%, #f8f8f7 0% 50%) 50% / 16px 16px;
  display: grid; place-items: center;
  min-height: 200px;
}
.banner-stage canvas {
  max-width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 1px 3px rgba(0,0,0,.14);
  cursor: pointer;
}
.banner-card footer { display: flex; gap: 2px; padding: 6px 8px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- editor - */

.editor-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(16, 18, 22, .55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 24px;
}
.editor-shell {
  width: min(1400px, 100%);
  height: min(860px, 100%);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.editor-head .muted { font-size: .8rem; margin-left: 8px; }
.editor-scope { display: flex; align-items: center; gap: 10px; }

.editor-body { flex: 1; display: grid; grid-template-columns: 200px minmax(0, 1fr) 280px; min-height: 0; }

.layer-pane, .props-pane { padding: 14px; overflow-y: auto; }
.layer-pane { border-right: 1px solid var(--line); background: var(--surface-2); }
.props-pane { border-left: 1px solid var(--line); background: var(--surface-2); }

.layer-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.layer-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 6px;
  font-size: .82rem; cursor: pointer;
}
.layer-list li:hover { background: var(--surface); }
.layer-list li.active { background: var(--text); color: #fff; }
.layer-list li.active .layer-type { color: rgba(255,255,255,.6); }
.layer-type { margin-left: auto; font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.layer-eye { border: 0; background: none; cursor: pointer; font-size: .8rem; padding: 0; opacity: .55; }
.layer-list li.hidden-layer { opacity: .45; }

.canvas-pane { display: flex; flex-direction: column; min-width: 0; padding: 16px; gap: 10px; }
.canvas-holder {
  flex: 1;
  display: grid; place-items: center;
  background: repeating-conic-gradient(#efeeec 0% 25%, #f8f8f7 0% 50%) 50% / 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  min-height: 0;
  padding: 20px;
}
.canvas-holder canvas {
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  cursor: grab;
  touch-action: none;
}
.canvas-holder canvas:active { cursor: grabbing; }

.prop-row { margin-bottom: 10px; }
.prop-row > label { display: block; font-size: .74rem; color: var(--muted); margin-bottom: 4px; }
.prop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prop-group { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.prop-group:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.seg { display: flex; gap: 2px; }
.seg button {
  flex: 1; font: inherit; font-size: .76rem;
  border: 1px solid var(--line-strong); background: var(--surface);
  padding: 5px 4px; cursor: pointer;
}
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.active { background: var(--text); color: #fff; border-color: var(--text); }

.scope-note {
  font-size: .74rem; color: var(--warn);
  background: #fff8ed; border: 1px solid #f4dcb8;
  padding: 6px 8px; border-radius: 6px; margin-bottom: 10px;
}

/* ----------------------------------------------------------------- login - */

body.is-login { display: grid; place-items: center; min-height: 100vh; }
.login-shell { width: min(360px, 92vw); }
.login-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.login-card h1 { font-size: 1.2rem; margin-top: 12px; }
.login-card .muted { font-size: .84rem; margin-bottom: 14px; }

/* --------------------------------------------------------- toast a busy - */

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: .85rem; z-index: 120; box-shadow: var(--shadow-lg);
  max-width: 90vw;
}
.toast.bad { background: var(--danger); }

.busy {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(244, 244, 242, .78);
  backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font-size: .9rem; color: var(--muted);
}
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.brands-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
.brand-form { position: sticky; top: 76px; }

@media (max-width: 1100px) {
  .campaign-body { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .brands-layout { grid-template-columns: 1fr; }
  .editor-body { grid-template-columns: 160px minmax(0, 1fr) 250px; }
}
