/* Thư Mời Online — đổi thương hiệu chỉ cần sửa các biến này */
:root {
  --primary: #C8102E;
  --primary-dark: #9E0B22;
  --primary-soft: #FDF1F0;
  --accent: #FFC53D;
  --ink: #26272b;
  --gray: #6b7280;
  --line: #e8dfe0;
  --bg: #f6f3f2;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

/* Thuộc tính hidden phải thắng mọi display đặt trong CSS (flex/grid) */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: var(--shadow);
}
.logo-badge {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
}
.header-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.header-text p {
  margin: 2px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
}
#modeToggle { margin-left: auto; }

/* ===== Layout ===== */
.layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  max-width: 1280px;
  margin: 0 auto;
}
@media (min-width: 1024px) {
  .layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .preview-col { flex: 1; min-width: 0; }
  .controls-col { width: 380px; flex-shrink: 0; }
}

/* ===== Preview ===== */
.canvas-wrap {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fff;
}
#previewCanvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: grab;
}
#previewCanvas:active { cursor: grabbing; }

.spinner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--gray);
  font-size: 14px;
  font-weight: 600;
  z-index: 5;
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(200, 16, 46, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Admin overlay ===== */
.admin-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
}
.zone-box, .name-box {
  position: absolute;
  border: 3px dashed var(--accent);
  background: rgba(245, 158, 11, 0.12);
  cursor: move;
  touch-action: none;
}
.zone-box.circle { border-radius: 50%; }
.name-box {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}
.handle {
  position: absolute;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  touch-action: none;
}
.handle-se { right: -11px; bottom: -11px; cursor: nwse-resize; }
.handle-w { left: -11px; top: 50%; transform: translateY(-50%); cursor: ew-resize; background: #38bdf8; }
.handle-e { right: -11px; top: 50%; transform: translateY(-50%); cursor: ew-resize; background: #38bdf8; }

/* ===== Cards & controls ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 16px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--primary-soft);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.dropzone:hover, .dropzone.dragover {
  background: #fae3e2;
  border-color: var(--primary-dark);
}
.dropzone.compact { padding: 12px; font-weight: 600; font-size: 14px; color: var(--primary); }
.dz-icon { font-size: 34px; }
.dz-title { font-weight: 800; font-size: 16px; color: var(--primary); }
.dz-sub { font-size: 12.5px; color: var(--gray); }

.tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.tool-label {
  width: 76px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
}
.tool-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--primary);
}
.tool-row-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}
.tool-value {
  font-size: 13px;
  color: var(--gray);
  min-width: 48px;
  text-align: right;
}
.icon-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 6px;
}
.text-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
}
.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.13);
}

.primary-btn {
  display: block;
  width: 100%;
  padding: 15px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(200, 16, 46, 0.35);
  transition: transform 0.1s, box-shadow 0.15s;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-1px); }
.primary-btn:disabled {
  background: #b9b9c6;
  box-shadow: none;
  cursor: not-allowed;
}

.ghost-btn {
  padding: 10px 16px;
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.controls-col .ghost-btn {
  border-color: var(--line);
  color: var(--ink);
}
.controls-col .ghost-btn:hover { border-color: var(--primary); color: var(--primary); }
.ghost-btn.small { padding: 8px 14px; font-size: 12.5px; }
.ghost-btn.full { display: block; width: 100%; margin-top: 10px; }

.hint {
  font-size: 12.5px;
  color: var(--gray);
  line-height: 1.5;
  margin: 8px 0 0;
}
.hint.center { text-align: center; }

/* Admin form bits */
.radio-row {
  display: flex;
  gap: 18px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}
.num-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.num-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gray);
}
.num-input {
  width: 100%;
  padding: 9px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}
.color-input {
  width: 100%;
  height: 40px;
  padding: 3px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  margin: 10px 0;
  cursor: pointer;
}
.check-row input { accent-color: var(--primary); width: 18px; height: 18px; }

/* ===== Danh sách khung đã tạo ===== */
.campaign-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.campaign-item:last-child { border-bottom: none; }
.campaign-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.campaign-item .ghost-btn { padding: 6px 10px; font-size: 12px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: min(90vw, 480px);
  text-align: center;
}
