/* Editor page additions (keeps Home look) */

.editor-category{
  position: relative;
}

/* ✅ Make the toptitle behave like Home AND keep room for the icons */
.editor-toptitle{
  position: relative;
  text-align: center;
  /* leave space for drag/delete buttons on both sides */
  padding-left: 46px;
  padding-right: 46px;
}

/* ✅ Tab name button: centered like normal text */
.editor-tabname-btn{
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  color: #fff;
  font: inherit;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  width: 100%;
}
.editor-tabname-btn:hover{
  text-decoration: underline;
}

/* Static tab name (Add new tab header) */
.editor-tab-name-static{
  color: #fff;
  display: inline-block;
  width: 100%;
  text-align: center;
}

/* Dashed border for "Add new" tab category */
.category.addnew-tab{
  border-style: dashed !important;
  border-width: 2px !important;
}

/* Add new tile: dashed border like a normal tile box */
.object.addnew-tile{
  border: 2px dashed var(--glass-border-strong, rgba(255,255,255,0.55));
  border-radius: 12px;
  box-sizing: border-box;
}

/* Make sure regular tiles still look the same; only buttons overlay */
.object.editor-tile{
  position: relative;
}

/* Thumbnail + sign */
.addnew-link{
  display: block;
  color: inherit;
  text-decoration: none;
}

.addnew-thumb{
  position: relative;
}

.addnew-thumb img{
  opacity: 0.22;
}

.addnew-plus{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  line-height: 1;
  font-weight: 800;
  color: var(--site-text, rgba(255,255,255,0.92));
  user-select: none;
  pointer-events: none;
}
.addnew-plus-big{
  font-size: 72px;
}

/* Round editor buttons */
.editor-btn{
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.35));
  background-color: rgba(0,0,0,0.20);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  z-index: 5;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
}


.editor-btn{
  color: transparent;
  font-size: 0;
  text-indent: -9999px;
  overflow: hidden;
}
.editor-btn::before,
.editor-btn::after{
  content: none !important;
}

/* Tile buttons: top-left and top-right */
.editor-btn-drag{ top: 8px; left: 8px; background-image: url('/img/editor/drag.png'); }
.editor-btn-del{ top: 8px; right: 8px; background-image: url('/img/editor/delete.png'); }

/* Tab buttons inside the toptitle */
.editor-btn-tab{ top: 8px; }
.editor-toptitle .editor-btn-drag.editor-btn-tab{ left: 10px; }
.editor-toptitle .editor-btn-del.editor-btn-tab{ right: 10px; }

/* Add-new category should be clickable */
.editor-category.addnew-tab{
  cursor: pointer;
}

/* Modal */
.editor-modal-overlay{
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
  z-index: 200000;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.editor-modal-overlay[hidden]{ display: none; }

.editor-modal-card{
  width: 520px;
  max-width: calc(100vw - 24px);
  border-radius: 20px;
  padding: 18px;
  box-sizing: border-box;

  background: transparent;
  border: 2px solid var(--glass-border-strong);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));

  color: rgba(255,255,255,0.95);
  position: relative;
}

.editor-modal-close{
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.35));
  background: var(--glass-bg, rgba(255,255,255,0.10));
  color: rgba(255,255,255,0.95);
  cursor: pointer;
  font-size: 22px;
  line-height: 0;
}

.editor-modal-title{
  font-size: 1.05em;
  font-weight: 800;
  margin-bottom: 12px;
}

.editor-modal-body label{
  display: block;
  font-size: 0.95em;
  margin: 10px 0 6px;
  opacity: 0.95;
}

.editor-modal-body input[type="text"],
.editor-modal-body input[type="url"]{
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--input-text);
  outline: none;
  padding: 0 12px;
  box-sizing: border-box;
}

.editor-modal-body input[type="file"]{
  width: 100%;
  color: var(--site-text, rgba(255,255,255,0.92));
}

.editor-modal-help{
  font-size: 0.9em;
  opacity: 0.9;
  margin-top: 6px;
}

.editor-modal-error{
  margin-top: 10px;
  font-weight: 700;
  color: rgba(255,120,120,0.95);
}

.editor-modal-actions{
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.editor-action-btn{
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.35));
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.95);
  cursor: pointer;
  font-weight: 800;
}

.editor-action-btn.primary{
  background: rgba(255,255,255,0.22);
}

/* Drag feedback */
.is-dragging{
  opacity: 0.65;
  filter: saturate(0.85);
}
.category.editor-category.drag-over{
  outline: 2px dashed rgba(255,255,255,0.6);
  outline-offset: 6px;
  border-radius: 16px;
}

/* Drag handle cursor */
.editor-btn-drag{
  cursor: grab;
}
.is-dragging .editor-btn-drag{
  cursor: grabbing;
}

/* While dragging */
.is-dragging{
  opacity: 0.65;
  filter: saturate(0.85);
}

/* Drop highlight */
.category.editor-category.drag-over{
  outline: 2px dashed rgba(255,255,255,0.65);
  outline-offset: 8px;
  border-radius: 18px;
}

/* Drop insertion indicator line (between tiles) */
.editor-drop-line{
  height: 10px;
  border-radius: 999px;
  margin: 6px 0;
  border: 2px dashed rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.08);
  box-sizing: border-box;
  pointer-events: none;
}

/* Drop insertion indicator line (between tabs) */
.editor-tab-drop-line{
  height: 70%;
  width: 18px;
  align-self: center;
  margin: 0 6px;
  border-radius: 999px;
  border: 2px dashed rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.08);
  box-sizing: border-box;
  pointer-events: none;
}


/* --- Image preview inside editor modal --- */
.editor-img-preview{
  margin-top: 10px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.25);
  background: var(--glass-bg, rgba(255,255,255,0.06));
  padding: 10px;
}

.editor-img-preview-title{
  font-size: 0.9em;
  opacity: 0.9;
  margin-bottom: 8px;
}

.editor-img-preview img{
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  border: 1px solid rgba(255,255,255,0.20);
}

/* --- Tile preview (Home-like) inside modal --- */
.editor-tile-preview-wrap{
  margin-top: 10px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.25);
  background: var(--glass-bg, rgba(255,255,255,0.06));
  padding: 10px;
}

.editor-tile-preview-title{
  font-size: 0.9em;
  opacity: 0.9;
  margin-bottom: 8px;
}

.editor-tile-preview{
  width: 100%;
  max-width: 360px;
}

/* This tries to mimic your Home tile look without depending on page layout */
.editor-tile-preview .object{
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.35);
  background: rgba(0,0,0,0.15);
}

.editor-tile-preview .tile-img img{
  width: 100%;
  height: auto;
  display: block;
}

/* Name overlay similar to Home */
.editor-tile-preview .tile-name{
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.95);
  font-weight: 700;
  font-size: 0.95em;
  line-height: 1.2;
  text-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

/* Center the Home-style tile preview inside the modal */
.editor-tile-preview {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

.editor-tile-preview .object.editor-preview-object {
  margin: 0 auto;     /* just in case .object has margins */
}

/* Make sure the preview link never "feels" clickable */
.editor-preview-link {
  cursor: default;
  pointer-events: none;  /* hard-disable clicking in the preview */
}

/* --- Modal tile preview: force centering even if .object is float/inline --- */
.editor-tile-preview{
  width: 100%;
}

.editor-tile-preview-center{
  width: 100%;
  display: flex;
  justify-content: center;
}

/* If Home tiles use float/positioning, neutralize it ONLY in modal preview */
.editor-tile-preview-center .object.editor-preview-object{
  float: none !important;
  position: relative;
  margin: 0 !important;
}

/* Preview must never be clickable */
.editor-preview-link{
  pointer-events: none;
  cursor: default;
}


/* ---- Thumbnail crop/position controls (modal) ---- */
.editor-crop-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 6px;
  flex-wrap: wrap;
}

.editor-crop-actions .btn{
  padding: 8px 12px;
  border-radius: 12px;
}

.editor-crop-status{
  color: rgba(255,255,255,0.82);
  font-size: 13px;
}

.editor-cropper{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.editor-cropper-canvas{
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.25);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  touch-action: none;
}

.editor-cropper-controls{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-cropper-controls label{
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

.editor-cropper-controls input[type="range"]{
  width: 220px;
}

.editor-cropper-tip{
  font-size: 13px;
  color: rgba(255,255,255,0.75);
}


/* ---------------- Thumbnail library picker ---------------- */

.thumblib-toolbar{
  display:flex;
  gap:10px;
  margin: 2px 0 10px;
}
.thumblib-toolbar input{
  width:100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--input-text);
  outline: none;
}
.thumblib-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;

  /* Scroll within the library instead of growing the modal off-screen */
  max-height: 55vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.thumblib-loading,
.thumblib-empty{
  grid-column: 1 / -1;
  padding: 12px 12px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.88);
}
.thumblib-item{
  width: 100%;
  height: auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.05);
  cursor:pointer;
  text-align:left;
}
.thumblib-item:hover{
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.07);
}

/* Ensure global button styles don't squash thumbnail items */
button.thumblib-item{
  height: auto !important;
  background: rgba(255,255,255,0.05) !important;
  border: 1px solid rgba(255,255,255,0.16) !important;
  border-radius: 16px !important;
}
.thumblib-thumb{
  flex: 0 0 auto;
  min-height: 90px;
  width:100%;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  overflow:hidden;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.12);
}
.thumblib-thumb img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}
.thumblib-meta{
  display:flex;
  flex-direction:column;
  gap:2px;
}
.thumblib-name{
  font-weight: 700;
  font-size: 13px;
  color: var(--site-text, rgba(255,255,255,0.92));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thumblib-file{
  font-size: 12px;
  color: var(--input-placeholder);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-thumb-actions{
  display:flex;
  gap:10px;
  flex-wrap: wrap;
  margin-top: 8px;
  align-items:center;
}



/* Template picker (Add new tile) */
.editor-template-picker{
  margin-top: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--glass-bg, rgba(255,255,255,0.06));
  border-radius: 14px;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
}

.editor-template-loading,
.editor-template-empty{
  color: rgba(255,255,255,0.88);
  padding: 8px 6px;
}

.editor-template-list{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-template-item{
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--glass-bg, rgba(255,255,255,0.06));
  padding: 8px;
  cursor: pointer;
  text-align: left;
}
.editor-template-item:hover{
  background: var(--glass-bg, rgba(255,255,255,0.10));
  border-color: rgba(255,255,255,0.20);
}

.editor-template-thumb{
  width: 72px;
  height: 45px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
  display:flex;
  align-items:center;
  justify-content:center;
}
.editor-template-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display:block;
}

.editor-template-meta{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.editor-template-name{
  font-weight: 700;
  color: rgba(255,255,255,0.95);
}
.editor-template-url{
  font-size: 12px;
  color: rgba(255,255,255,0.70);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}



/* Template picker (popup) */
.editor-template-modal .editor-template-search{
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 10px;
}
.editor-template-list-wrap{
  max-height: 52vh;
  overflow: auto;
  padding-right: 2px;
}

/* ---------------------------
   Theme variable hookups
   --------------------------- */
.editor-category,
.editor-category *{
  color: var(--site-text);
}

.editor-category .muted,
.editor-category small,
.editor-thumb-note{
  color: var(--site-text-muted);
}
