/* =========================================================================
   misawq Visual Site Constructor & Drawing Studio (Admin-only UI)
   ========================================================================= */

body.is-admin-builder {
  padding-top: 46px;
}
body.is-admin-builder .corner-brand {
  top: calc(clamp(18px, 2.8vw, 30px) + 46px);
}
body.is-admin-builder .corner-nav {
  top: calc(clamp(20px, 2.8vw, 32px) + 46px);
  transition: right 0.25s ease, opacity 0.25s ease;
}
body.is-admin-builder.ab-drawer-open .corner-nav {
  right: calc(clamp(18px, 3.4vw, 44px) + 390px);
}
body.is-reader-open .ab-topbar,
body.is-reader-open .ab-drawer,
body.is-reader-open .ab-preview-pill {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ---- TOP ADMIN BAR ---- */
.ab-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 46px;
  z-index: 155;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  background: #0b0910;
  border-bottom: 1px solid rgba(235, 193, 194, 0.24);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  contain: layout style;
  font-family: "Inter", "IBM Plex Mono", sans-serif;
  color: #f7f0f2;
}
body.is-admin-builder .ab-topbar { display: flex; }

.ab-topbar__left,
.ab-topbar__center,
.ab-topbar__right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ab-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(235, 193, 194, 0.16);
  border: 1px solid rgba(235, 193, 194, 0.48);
  color: #ffe2e3;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ab-brand-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ffe2e3;
  box-shadow: 0 0 8px #ebc1c2;
}

.ab-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
  font-family: "Inter", sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.ab-btn:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(235, 193, 194, 0.45);
}
.ab-btn.is-active {
  background: rgba(235, 193, 194, 0.22);
  border-color: #ebc1c2;
  color: #ffe2e3;
}
.ab-btn--primary {
  background: #ebc1c2;
  border-color: #ffe2e3;
  color: #0b0910;
  font-weight: 600;
}
.ab-btn--primary:hover {
  background: #ffe2e3;
  color: #0b0910;
}
.ab-btn--danger:hover {
  background: rgba(232, 92, 107, 0.25);
  border-color: #e85c6b;
  color: #ff9ca6;
}
.ab-btn--sm {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
}
.ab-btn--icon {
  padding: 4px 7px;
  min-width: 26px;
  justify-content: center;
}

.ab-status {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  padding: 0 6px;
  white-space: nowrap;
}
.ab-status.is-dirty { color: #ffbe76; }
.ab-status.is-saved { color: #a8e6cf; }

/* Floating return button when Admin enters Viewer Preview */
.ab-preview-pill {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 160;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #0d0b12;
  border: 1px solid rgba(235, 193, 194, 0.55);
  color: #ffe2e3;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}
.ab-preview-pill:hover {
  background: #ebc1c2;
  color: #09070d;
}
.ab-preview-pill.is-visible { display: inline-flex; }

/* ---- ON-PAGE SELECTION & HOVER OUTLINES ---- */
body.is-admin-builder [data-block-id]:hover {
  outline: 1.5px solid rgba(235, 193, 194, 0.45);
  outline-offset: -2px;
}
body.is-admin-builder [data-block-id].is-admin-selected {
  outline: 2px solid #ebc1c2;
  outline-offset: -2px;
}
body.is-admin-builder [data-admin-target]:hover {
  outline: 1.5px solid #ffe2e3;
  outline-offset: 4px;
}
body.is-admin-builder .is-block-hidden-admin {
  opacity: 0.34;
  filter: grayscale(0.65);
}
body.is-admin-builder .is-block-hidden-admin::before {
  content: "СКРЫТ ДЛЯ ПОЛЬЗОВАТЕЛЕЙ";
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(12, 10, 16, 0.92);
  border: 1px solid rgba(255, 190, 118, 0.6);
  color: #ffbe76;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  pointer-events: none;
}

.ab-block-pill {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 148;
  display: none;
  align-items: center;
  gap: 5px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: #0d0b12;
  border: 1px solid rgba(235, 193, 194, 0.52);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  font-family: "Inter", sans-serif;
  font-size: 11px;
  color: #ffe2e3;
  pointer-events: auto;
  will-change: transform;
  contain: layout style;
}
body.is-admin-builder .ab-block-pill.is-visible { display: flex; }
.ab-block-pill__name {
  font-weight: 600;
  padding-right: 4px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ab-block-pill button {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 999px;
  cursor: pointer;
}
.ab-block-pill button:hover {
  background: #ebc1c2;
  color: #0b0910;
}

/* ---- RIGHT INSPECTOR DRAWER ---- */
.ab-drawer {
  position: fixed;
  top: 46px;
  right: 0;
  bottom: 0;
  width: 390px;
  max-width: 100vw;
  z-index: 152;
  display: none;
  flex-direction: column;
  background: #0d0b12;
  border-left: 1px solid rgba(235, 193, 194, 0.20);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.55);
  contain: layout style;
  font-family: "Inter", sans-serif;
  color: #f6eff1;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
body.is-admin-builder .ab-drawer { display: flex; }
body.is-admin-builder.ab-drawer-open .ab-drawer { transform: translateX(0); }

.ab-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px 10px;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  flex-shrink: 0;
}
.ab-tab {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.68);
  font-family: "Inter", sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.ab-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.09); }
.ab-tab.is-active {
  background: rgba(235, 193, 194, 0.2);
  border-color: rgba(235, 193, 194, 0.5);
  color: #ffe2e3;
}

.ab-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 28px;
  scrollbar-width: none;
}
.ab-drawer__body::-webkit-scrollbar { display: none; }

/* ---- BLOCK LIST ---- */
.ab-block-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}
.ab-block-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ab-block-row:hover { background: rgba(255, 255, 255, 0.08); }
.ab-block-row.is-selected {
  background: rgba(235, 193, 194, 0.14);
  border-color: rgba(235, 193, 194, 0.55);
}
.ab-block-row.is-hidden { opacity: 0.52; }
.ab-block-row__info { flex: 1; min-width: 0; }
.ab-block-row__title {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ab-block-row__type {
  font-family: "IBM Plex Mono", monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(235, 193, 194, 0.72);
  margin-top: 2px;
}
.ab-block-row__acts { display: flex; gap: 3px; }

/* ---- ACCORDIONS & FORM CONTROLS ---- */
.ab-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.ab-section-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #ffe2e3;
}

.ab-acc {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  margin-bottom: 10px;
  overflow: hidden;
}
.ab-acc > summary {
  list-style: none;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f9edf0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  user-select: none;
}
.ab-acc > summary::-webkit-details-marker { display: none; }
.ab-acc > summary::after {
  content: "▾";
  font-size: 11px;
  color: rgba(235, 193, 194, 0.8);
  transition: transform 0.18s ease;
}
.ab-acc:not([open]) > summary::after { transform: rotate(-90deg); }
.ab-acc__body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.ab-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ab-field__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: rgba(250, 245, 246, 0.72);
}
.ab-field__val {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10.5px;
  color: #ebc1c2;
}
.ab-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ab-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ab-input,
.ab-select,
.ab-textarea {
  width: 100%;
  background: rgba(5, 4, 8, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  color: #fff;
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
  padding: 7px 9px;
  outline: none;
  transition: border-color 0.15s ease;
}
.ab-input:focus,
.ab-select:focus,
.ab-textarea:focus {
  border-color: #ebc1c2;
}
.ab-textarea {
  min-height: 62px;
  resize: vertical;
  line-height: 1.45;
}
.ab-select option {
  background: #14111c;
  color: #fff;
}

.ab-range {
  width: 100%;
  accent-color: #ebc1c2;
  cursor: pointer;
}

.ab-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #f5ebed;
  cursor: pointer;
  user-select: none;
}
.ab-toggle input[type="checkbox"] {
  appearance: none;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  cursor: pointer;
  transition: background 0.18s ease;
  flex-shrink: 0;
}
.ab-toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}
.ab-toggle input[type="checkbox"]:checked { background: #ebc1c2; }
.ab-toggle input[type="checkbox"]:checked::after {
  transform: translateX(15px);
  background: #0d0a12;
}

.ab-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.ab-seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-family: "Inter", sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.ab-seg button.is-active {
  background: #ebc1c2;
  color: #0b0910;
  font-weight: 600;
}

.ab-color-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ab-color-input {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}
.ab-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease;
}
.ab-swatch:hover { transform: scale(1.18); border-color: #fff; }

.ab-typo-card {
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ab-typo-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: #ffe2e3;
}
.ab-hint {
  font-size: 10.5px;
  color: rgba(250, 245, 246, 0.50);
  line-height: 1.4;
}

.ab-img-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.ab-img-preview img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}
.ab-img-preview__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ab-item-card {
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ab-item-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #ffe2e3;
}

/* ---- ADD BLOCK MODAL ---- */
.ab-modal {
  position: fixed;
  inset: 0;
  z-index: 195;
  background: rgba(5, 4, 9, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ab-modal.is-open { display: flex; }
.ab-modal__box {
  width: min(760px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: #12101a;
  border: 1px solid rgba(235, 193, 194, 0.28);
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.88);
  overflow: hidden;
  font-family: "Inter", sans-serif;
  color: #fff;
}
.ab-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.ab-modal__head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #ffe2e3;
}
.ab-modal__body {
  padding: 18px;
  overflow-y: auto;
}
.ab-tpl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ab-tpl-card {
  appearance: none;
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.16s ease;
}
.ab-tpl-card:hover {
  background: rgba(235, 193, 194, 0.12);
  border-color: #ebc1c2;
  transform: translateY(-2px);
}
.ab-tpl-card__icon { font-size: 20px; }
.ab-tpl-card__name { font-size: 13.5px; font-weight: 600; color: #ffe2e3; }
.ab-tpl-card__desc { font-size: 11.5px; color: rgba(250, 245, 246, 0.68); line-height: 1.45; }

/* ---- DRAWING STUDIO MODAL ---- */
.ab-draw-box {
  width: min(820px, 100%);
}
.ab-draw-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.ab-draw-stage {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.ab-draw-canvas-wrap {
  width: 100%;
  max-width: 740px;
  aspect-ratio: 720 / 320;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(235, 193, 194, 0.35);
  background-color: #0b0910;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.65);
  touch-action: none;
}
.ab-draw-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
.ab-draw-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ab-drawer-close-mob {
  display: none;
}

@media (max-width: 960px) {
  .ab-topbar {
    padding: 0 8px;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ab-topbar__center { display: none; }
  .ab-status { display: none; }
  .ab-brand-badge { display: none; }
  .ab-topbar__left,
  .ab-topbar__right {
    gap: 5px;
    flex-shrink: 0;
  }
  .ab-btn {
    padding: 5px 8px;
    font-size: 11px;
  }
  .ab-topbar [data-ab="export"] { display: none; }
  .ab-drawer {
    width: 100vw;
    max-width: 100vw;
    border-left: 0;
  }
  .ab-tabs {
    grid-template-columns: 1fr 1fr 1fr auto;
    align-items: center;
  }
  .ab-drawer-close-mob {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: #ffe2e3;
    cursor: pointer;
    font-size: 13px;
  }
  body.is-admin-builder.ab-drawer-open .corner-nav { right: 14px; }
  .ab-tpl-grid { grid-template-columns: 1fr; }
  .ab-modal { padding: 10px; }
  .ab-draw-foot { flex-wrap: wrap; }
}
