:root {
    --edit-mode-overlay-bg-color: transparent;
    --edit-mode-overlay-bg-color-hover: var(--primary-trans-20);
    --edit-mode-overlay-border-width: 2px;
    --edit-mode-overlay-border-style: dashed;
    --edit-mode-overlay-border-color: transparent;
    --edit-mode-overlay-border-color-hover: var(--primary);

    /* Z-INDEXING */
    --z-index-overlay-image: 9000;
    --z-index-container: 9100;
    --z-index-cpt-item-image: 9200;
    --z-index-overlay-text: 9300;
    --z-index-overlay-active: 9400;
    --z-index-editor-text: 9500;
    --z-index-overlay-section: 8999;
    --z-index-post-popup: 9600;
}
.edit-overlay {
    position: absolute;
    background: var(--edit-mode-overlay-bg-color);
    border: var(--edit-mode-overlay-border-width) var(--edit-mode-overlay-border-style) var(--edit-mode-overlay-border-color);
    border-radius: var(--radius);
    pointer-events: auto;
    cursor: pointer;
    box-sizing: border-box;
    transition: var(--transition);
    opacity: 1;
}
.edit-overlay-img {
    border-style: var(--edit-mode-overlay-border-style) !important;
    border-width: var(--edit-mode-overlay-border-width) !important;
    border-color: var(--edit-mode-overlay-border-color) !important;
    z-index: var(--z-index-overlay-image);
}
.edit-overlay-cpt-item {
    border-style: var(--edit-mode-overlay-border-style) !important;
    border-width: var(--edit-mode-overlay-border-width) !important;
    border-color: var(--edit-mode-overlay-border-color-hover) !important;
    z-index: var(--z-index-container);
}
.edit-overlay-cpt-item-img,
.edit-overlay-cpt-item-ul {
    --z-index-overlay-image: var(--z-index-cpt-item-image);
}
.edit-overlay-h1, .edit-overlay-h2, .edit-overlay-h3, .edit-overlay-h4, .edit-overlay-h5, .edit-overlay-h6,
.edit-overlay-p, .edit-overlay-a, .edit-overlay-button, .edit-overlay-span, .edit-overlay-div, .edit-overlay-ul {
    border-style: var(--edit-mode-overlay-border-style) !important;
    border-width: var(--edit-mode-overlay-border-width) !important;
    border-color: var(--edit-mode-overlay-border-color) !important;
    z-index: var(--z-index-overlay-text);
}
.edit-overlay-active {
    border-color: var(--edit-mode-overlay-border-color-hover) !important;
    background: transparent !important;
    z-index: var(--z-index-overlay-active) !important;
    opacity: 1 !important;
}
.edit-overlay-inactive {
    /* opacity: 0.3; */
    pointer-events: none;
}
.edit-original-element-active {
    background: var(--primary-light);
    color: var(--primary-ultra-dark) !important;
}
.edit-original-element-inactive {
    /* opacity: .3;
    filter: blur(2px);
    transform: blur(2px); */
}
.edit-overlay-img:hover:not(.edit-overlay-inactive) {
    background: var(--edit-mode-overlay-bg-color) !important;
    border-color: var(--edit-mode-overlay-border-color-hover) !important;
}
.edit-overlay-h1:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-h2:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-h3:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-h4:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-h5:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-h6:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-p:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-a:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-button:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-span:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-div:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-img:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-ul:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-cpt-item:hover:not(.edit-overlay-inactive, .edit-overlay-active),
.edit-overlay-repeater:hover:not(.edit-overlay-inactive, .edit-overlay-active) {
    background: var(--edit-mode-overlay-bg-color-hover) !important;
    border-color: var(--edit-mode-overlay-border-color-hover) !important;
}

.edit-overlay-section {
    z-index: var(--z-index-overlay-section);
    width: var(--gutter) !important;
    height: var(--gutter) !important;
    background: var(--primary-trans-50);
}

.edit-overlay-section:hover {
    background: var(--primary-trans-80);
}

#editModeBtn {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 12px 24px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    z-index: var(--z-index-overlay-active);
    transition: background 0.2s;
}
#editModeBtn.in-edit-mode {
    background-color: #dc3545;
}

#edit-mode-editor-frame {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: var(--z-index-editor-text) !important;
    width: 80%;
    max-width: 600px; 
}

#edit-mode-editor-frame-save-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background: #007cba;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#edit-mode-editor-frame-cancel-btn {
    margin-top: 10px;
    margin-left: 10px;
    padding: 8px 16px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Post Item Popup */

#edit-mode-popup-bg-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 9000;
    opacity: 1;
    backdrop-filter: blur(5px);
}

#edit-mode-popup-bg-overlay::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--bg-light);
    opacity: .7;
}

#edit-mode-popup-frame {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid #ccc;
    padding: 20px;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    height: 90%;
    width: 50%;
    min-width: 500px;
    z-index: var(--z-index-post-popup);
    border-radius: var(--radius);
    overflow: clip;
}
#edit-mode-popup-content {
    max-height: calc(100% - 75px);
    display: flex;
    flex-flow: column nowrap;
    row-gap: var(--content-gap);
    overflow-y: auto;
    margin-bottom: 20px;
}
#edit-mode-popup-close-btn {
    display: block;
    margin: 0 auto;
    padding: 8px 16px;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 55px;
    padding: 0 !important;
    background: transparent;
    color: #ba0000;
    font-size: 16px;
}
#edit-mode-popup-close-btn:hover {
    background: #005a87;
}
#edit-mode-popup-delete-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    margin-left: 10px;
    cursor: pointer;
}
#edit-mode-popup-delete-btn:hover {
    background-color: #c82333;
}

#edit-mode-popup-frame .standard-fields {
  display: flex;
  flex-flow: column nowrap;
  row-gap: var(--content-gap);
}

#edit-mode-popup-frame .field-container input, 
#edit-mode-popup-frame .field-container textarea, 
#edit-mode-popup-frame #editor-post_content {
    border: var(--border);
    padding: var(--space-xs) var(--space-s);
    width: calc(100% - var(--space-s));
    border-radius: var(--radius);
    overflow: clip;
}

#edit-mode-popup-frame .field-image-preview {
    max-width: 300px;
}

#edit-mode-popup-close-btn, #edit-mode-popup-save-btn, #edit-mode-popup-delete-btn {
    display: inline-flex;
    margin-right: var(--space-s);
    padding: var(--btn-pad-y) var(--btn-pad-x);
    border-radius: var(--btn-radius);
}

#edit-mode-popup-save-btn {
    background-color: #038803;
    position: absolute;
    left: auto;
    right: 0;
    padding: 7px 25px;
    font-size: var(--text-s);
    color: #fff;
}

/* NEW POPUP STYLING */


/* Inline | https://arcade.killerpom.com/ */

.field-label {
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dark);
  font-size: var(--text-s);
}

.field-description {
  font-style: italic;
  color: var(--text-dark-muted);
  font-size: var(--text-xs);
  margin-bottom: var(--space-xs);
}

.field-container {
  padding-block-end: var(--space-m);
  padding-inline: var(--space-xs);
}

.field-input[type="checkbox"] {
  width: auto !important;
  transform: scale(1.5);
  transform-origin: 0 100%;
}

/* Repeater popup styling */
.repeater-fields {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 24px;
    background: #e0e1e2;
    border-radius: 8px;
    padding: 16px 16px 16px 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.repeater-row {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    position: relative;
    transition: box-shadow 0.2s;
    border-left: 3px solid #007cba;
}

.repeater-row:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border-color: #007cba;
}

.repeater-row .field-container {
    margin-bottom: 12px;
    padding: 0;
}

.repeater-row .remove-repeater-row {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.repeater-row .remove-repeater-row:hover {
    background: #c82333;
}

.add-repeater-row {
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 8px;
    align-self: flex-start;
    transition: background 0.2s;
}

.add-repeater-row:hover {
    background: #005a87;
}

.repeater-fields h3 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.2em;
    color: #007cba;
}

.repeater-row .field-label {
    font-size: 13px;
    color: #333;
    margin-bottom: 2px;
}

.repeater-row .field-description {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
}

.repeater-row .field-image-preview {
    margin-bottom: 8px;
    max-width: 120px;
    border-radius: 4px;
    overflow: hidden;
    background: #f0f0f0;
    padding: 4px;
}

.repeater-row .field-image-preview img {
    max-width: 100%;
    border-radius: 4px;
    display: block;
}

.repeater-row .field-button.media {
    background: #35bf35;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 8px;
    margin-right: 8px;
    transition: background 0.2s;
}

.repeater-row .field-button.media:hover {
    background: #249c24;
}