/* Hotel Newsletter UI */

:root{
  --border:#ddd;
  --muted:#6b6b6b;
  --bg:#f6f6f6;
  --text:#111;
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color:var(--text);
  background:var(--bg);
}

.top{
  display:flex;
  gap:12px;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  border-bottom:1px solid #e7e7e7;
  background:#fff;
  position:sticky;
  top:0;
  z-index:10;
}

.title h1{ margin:0; font-size:18px; }
.title p{ margin:4px 0 0; color:var(--muted); font-size:12px; max-width:820px; }

.actions{ display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
button, select, input{ font:inherit; }
button{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
}
button.primary{
  background:#111;
  color:#fff;
  border-color:#111;
}
button:disabled{ opacity:.45; cursor:not-allowed; }

.wrap{
  display:grid;
  grid-template-columns: 380px 1fr;
  gap:14px;
  padding:14px;
}

.panel{
  background:#fff;
  border:1px solid #e7e7e7;
  border-radius:16px;
  overflow:hidden;
  min-height: calc(100vh - 88px);
}

.tabs{
  display:flex;
  gap:8px;
  padding:10px;
  border-bottom:1px solid #eee;
  background:#fafafa;
}
.tab{
  flex:1;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
}
.tab.active{
  background:#111;
  color:#fff;
  border-color:#111;
}

.panel-b{ padding:12px 12px 16px; }

.sidebar-scroll{
  max-height: calc(100vh - 170px);
  overflow:auto;
}

.field-row{ margin-bottom:12px; }
.field-row label{
  display:block;
  font-size:12px;
  color:#222;
  font-weight:700;
  margin:0 0 6px;
}
.field-row input[type="text"], 
.field-row select{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
}

.small{ font-size:12px; color:var(--muted); margin-top:6px; }

.row-inline{ display:flex; gap:8px; align-items:center; }

/* --- A4 Preview sizing (must match mm layout) --- */
.preview-wrap{
  background:#fff;
  border:1px solid #e7e7e7;
  border-radius:16px;
  overflow:hidden;
}

.preview-toolbar{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-bottom:1px solid #eee;
  background:#fafafa;
}

.page{
  position: relative;
  width: 210mm;
  height: 297mm;
  background: #fff;
  margin: 12px auto;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
}

#bg-img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit: fill;
  z-index:0;
  pointer-events:none;
  user-select:none;
}

#overlay{ position:absolute; inset:0; z-index:2; }

.page .grid{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  background-image: linear-gradient(to right, rgba(0,0,0,.06) 1px, transparent 1px),
                    linear-gradient(to bottom, rgba(0,0,0,.06) 1px, transparent 1px);
  background-size: 10mm 10mm;
  display:none;
}
.page.show-grid .grid{ display:block; }
.page:not(.show-bg) #bg-img{ display:none; }

/* Overlay fields */
.f{
  position:absolute;
  border:1px dashed rgba(0,0,0,.22);
  border-radius:10px;
  padding:6px 6px 8px;
  background: rgba(255,255,255,.84);
  overflow:hidden;
}
.f .name{ display:none; }
.f .content{
  width:100%;
  height: calc(100% - 18px);
  overflow:hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.f .content b, .f .content strong{ font-weight:800; }
.f .content i, .f .content em{ font-style:italic; }

.f .content span[data-size="8"]{ font-size:8px; }
.f .content span[data-size="9"]{ font-size:9px; }
.f .content span[data-size="10"]{ font-size:10px; }
.f .content span[data-size="11"]{ font-size:11px; }
.f .content span[data-size="12"]{ font-size:12px; }
.f .content span[data-size="14"]{ font-size:14px; }
.f .content span[data-size="16"]{ font-size:16px; }

/* --- Rich text editor --- */
.rte-wrap{
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  overflow:hidden;
}
.rte-toolbar{
  display:flex;
  gap:6px;
  align-items:center;
  padding:8px 10px;
  border-bottom:1px solid #eee;
  background:#fafafa;
}
.rte-btn{
  padding:6px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
}
.rte-size{
  margin-left:auto;
  padding:6px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
}
.rte{
  min-height:110px;
  max-height:380px;
  padding:10px 12px;
  overflow:auto;
  outline:none;
}
[data-rte="menu"]{ min-height:260px; max-height:520px; }

/* --- Modal --- */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.35);
  z-index:9999;
  padding:6vh 10px;
}
.modal-card{
  max-width:980px;
  margin:0 auto;
  background:#fff;
  border-radius:16px;
  border:1px solid #e2e2e2;
  overflow:hidden;
  box-shadow:0 18px 60px rgba(0,0,0,.25);
}
.modal-head{
  padding:12px 14px;
  border-bottom:1px solid #eee;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}
.modal-title{ font-weight:800; }
.modal-actions{ display:flex; gap:8px; }
.modal-body{
  display:grid;
  grid-template-columns: 280px 1fr;
  min-height:60vh;
}
.modal-list{
  border-right:1px solid #eee;
  padding:12px;
  overflow:auto;
}
.tpl-list{ display:flex; flex-direction:column; gap:6px; }
.modal-edit{
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.modal-footer{
  display:flex;
  gap:8px;
  justify-content:flex-end;
}

/* Toast */
#toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform:translateX(-50%);
  background:#111;
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
  z-index:99999;
}
#toast.show{ opacity:1; }

@media (max-width: 1100px){
  .wrap{ grid-template-columns: 1fr; }
  .panel{ min-height:auto; }
  .page{ margin: 12px auto; }
}

/* Preview labels only in admin */
.f .name{ display:none; }
body.is-admin .f .name{ display:block; }

/* Admin layout handles */
.f.editable{ cursor: move; }
.f.editable .h{ position:absolute; width:12px; height:12px; background:#111; border-radius:4px; right:4px; bottom:4px; cursor: nwse-resize; }

/* Admin resize handles (only on selected field) */
.f .handle{ display:none; position:absolute; width:10px; height:10px; border-radius:8px;
  right:2px; bottom:2px; border:1px solid rgba(0,0,0,.35); background:rgba(255,255,255,.9);
  cursor:nwse-resize;
}
body.is-admin .f.selected .handle{ display:block; }
body.is-admin .f.selected{ outline:2px solid rgba(0,0,0,.55); }
.inspector{
  position: sticky;
  bottom: 0;
  margin-top: 10px;
  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;
}
.inspector .row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px;
  margin-top:8px;
}
.inspector label{ font-size:11px; color:#333; font-weight:700; display:block; margin:0 0 4px; }
.inspector input{
  width:100%;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  font-variant-numeric: tabular-nums;
}
.inspector .title{ font-weight:800; font-size:12px; }
.inspector .hint{ font-size:11px; color:var(--muted); margin-top:6px; }
