/* ===== FLATEE NEWSLETTER BUILDER v3 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:   #3ecfff;
  --dark:     #0d0d0d;
  --panel:    #161616;
  --surface:  #1f1f1f;
  --surface2: #2a2a2a;
  --border:   #2e2e2e;
  --text:     #e2e2e2;
  --muted:    #666;
  --muted2:   #999;
  --danger:   #ff5f5f;
  --success:  #3effb0;
}

body { background: #111; color: var(--text); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; min-height: 100vh; }

/* ── LAYOUT ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
.app > .topbar { flex-shrink: 0; }
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  background: var(--dark);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
}
.topbar-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.topbar-logo-img {
  height: 26px; width: auto;
  filter: brightness(0) invert(1);
  flex-shrink: 0;
}
.topbar-sep  { color: var(--border); font-size: 18px; font-weight: 100; }
.topbar-title { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--muted2); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; }

/* ── SIDEBAR ── */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 300px;
  min-width: 200px;
  max-width: 560px;
  flex-shrink: 0;
  transition: width 0.22s ease;
}
.sidebar.collapsed {
  width: 0 !important;
  min-width: 0;
  border-right: none;
  overflow: hidden;
}

/* ── SIDEBAR RESIZE HANDLE ── */
.sidebar-resizer {
  width: 14px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-resizer::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
  transition: background 0.15s;
}
.sidebar-resizer:hover::before,
body.resizing .sidebar-resizer::before { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }

.sidebar-toggle-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 40px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted2);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 21;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-toggle-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); }

/* ── SIDEBAR TABS ── */
.sidebar-tabs {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: var(--dark);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.sidebar-tabs::-webkit-scrollbar { display: none; }

.sidebar-collapse-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--muted2);
  font-size: 16px;
  padding: 0 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.sidebar-collapse-btn:hover { color: var(--accent); background: rgba(62,207,255,0.08); }

.stab {
  padding: 10px 11px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.stab.active { color: var(--accent); border-bottom-color: var(--accent); }
.stab:hover:not(.active) { color: var(--text); }

.spanel { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.spanel.active { display: flex; }

/* ── BLOCK SETTINGS AREA ── */
.block-settings-area {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bsa-header {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.bsa-header span { flex: 1; font-size: 12px; font-weight: 700; color: var(--text); letter-spacing: 0.04em; }
#bsa-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

/* ── PALETTE ── */
#palette-area { flex: 1; overflow-y: auto; }
.palette-group { border-bottom: 1px solid var(--border); }
.palette-group-label {
  padding: 8px 14px 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--muted);
  text-transform: uppercase;
}
.palette-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px 10px 10px;
}
.palette-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.palette-item:hover { border-color: var(--accent); background: rgba(62,207,255,0.07); }
.palette-item:active { cursor: grabbing; }
.pi-icon  { font-size: 14px; color: var(--accent); flex-shrink: 0; width: 18px; text-align: center; }
.pi-label { font-size: 11px; color: var(--text); font-weight: 500; }

/* ── CANVAS ── */
.canvas-list {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 40px;
  flex: 1;
}
.canvas-list.drag-active { background: rgba(62,207,255,0.04); }
.canvas-drop-hint {
  text-align: center;
  padding: 24px 16px;
  font-size: 12px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin: 8px 10px;
}

.canvas-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  gap: 8px;
  cursor: default;
  user-select: none;
  transition: border-color 0.12s, opacity 0.12s;
}
.canvas-row:hover        { border-color: #3a3a3a; }
.canvas-row.selected     { border-color: var(--accent); background: rgba(62,207,255,0.08); }
.canvas-row.dragging   { opacity: 0.35; }
.canvas-row.drag-top   { border-top: 2px solid var(--accent); }
.canvas-row.drag-bottom{ border-bottom: 2px solid var(--accent); }

.canvas-row-icon  { font-size: 14px; color: var(--accent); flex-shrink: 0; width: 16px; text-align: center; }
.canvas-row-label { flex: 1; font-size: 12px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canvas-row-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 0.15s; }
.canvas-row:hover .canvas-row-actions { opacity: 1; }

/* ── SHOP ── */
.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.shop-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 0.12s;
}
.shop-card:hover   { border-color: var(--accent); }
.shop-card.on-sale { border-color: #c8a800; }
.sale-badge {
  position: absolute; top: 5px; left: 5px; z-index: 1;
  background: #ffd700; color: #000;
  font-size: 8px; font-weight: 800; letter-spacing: 0.08em;
  padding: 2px 5px; border-radius: 3px;
}
.shop-card-img   { height: 80px; background: #222 center/cover no-repeat; flex-shrink: 0; }
.shop-card-info  { padding: 6px 8px 3px; flex: 1; }
.shop-card-name  { font-size: 10px; font-weight: 600; color: var(--text); line-height: 1.3; margin-bottom: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shop-card-price { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 5px; }
.shop-card-btn   { margin: 0 7px 7px; width: calc(100% - 14px); }

/* ── TEMPLATES ── */
.template-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.template-row:hover { border-color: #3a3a3a; }
.template-row-info  { flex: 1; min-width: 0; }
.template-row-name  { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-row-date  { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ── PREVIEW ── */
.preview-pane {
  background: #c8c8c8;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  min-width: 0;
}
.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #c0c0c0;
  border-bottom: 1px solid #aaa;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.preview-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #888;
  text-transform: uppercase;
}
#preview-frame {
  width: 100%;
  border: none;
  background: #fff;
  flex: 1;
  min-height: 500px;
  display: block;
  box-shadow: 0 0 40px rgba(0,0,0,0.2);
}

/* ── FORM ── */
.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted2);
}
input[type="text"], input[type="url"], input[type="number"],
input[type="color"], textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 7px 9px;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type="color"] { height: 34px; padding: 3px 5px; cursor: pointer; }
textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--accent); color: #000; }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: #555; color: #fff; }
.btn-danger    { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-send      { background: #1a6b2a; color: #fff; }
.btn-send:hover { background: #1e7d32; }
.btn-sm   { padding: 5px 10px; font-size: 11px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.icon-btn:hover { color: var(--accent); background: rgba(62,207,255,0.1); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(255,95,95,0.1); }

/* ── DRAG HANDLE ── */
.drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1;
  padding: 0 2px;
}
.drag-handle:hover  { color: var(--accent); }
.drag-handle:active { cursor: grabbing; }

/* ── STATUS ── */
.status-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  min-height: 40px;
  color: var(--muted2);
}
.status-box.ok  { border-color: var(--success); color: var(--success); }
.status-box.err { border-color: var(--danger);  color: var(--danger); }

/* ── SEND PANEL ── */
.send-panel { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--accent); color: #000;
  padding: 10px 18px;
  border-radius: 7px;
  font-size: 12px; font-weight: 700;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  z-index: 9999;
  transform: translateY(60px); opacity: 0;
  transition: transform 0.2s, opacity 0.2s;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.err  { background: var(--danger); color: #fff; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── RESPONSIVE ── */
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 48px auto 1fr; }
  .sidebar { max-height: 50vh; }
}
