.cms-editable-wrapper {
  position: relative;
  display: inline-block;
  transition: outline 0.2s ease;
}

.cms-image-wrapper {
  display: inline-block;
}

body.cms-mode-active .cms-editable-wrapper:hover {
  outline: 2px dashed #3b82f6;
}

.cms-edit-btn {
  position: absolute;
  top: -16px;
  right: -16px;
  margin-top: 0;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  color: #3b82f6;
  font-size: 14px;
  opacity: 0;
  transition:
    opacity 0.3s ease,
    transform 0.2s ease,
    background 0.2s ease;
  z-index: 100;
}

body.cms-mode-active .cms-edit-btn {
  display: flex;
}

body.cms-mode-active .cms-editable-wrapper:hover .cms-edit-btn {
  opacity: 1;
  transform: scale(1.1);
}

.cms-edit-btn:hover {
  background: #3b82f6;
  color: white;
}

/* Modal overlay and pop-up styles */

.cms-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  z-index: 999999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 2rem 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  transform: translateZ(0);
  will-change: opacity;
}

.cms-modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.cms-modal {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 16px;
  padding: 30px;
  width: 90%;
  max-width: 500px;
  margin: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  transform: translateY(20px) scale(0.95) translateZ(0);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backface-visibility: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.cms-modal-overlay.active .cms-modal {
  transform: translateY(0) scale(1) translateZ(0);
}

.cms-modal h3 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #222;
  font-family: "Montserrat", sans-serif;
  font-size: 22px;
}

.cms-modal-body {
  margin-bottom: 20px;
}

.cms-textarea {
  width: 100%;
  min-height: 200px;
  padding: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  box-sizing: border-box;
}

.cms-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  outline: none;
}

.cms-input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 15px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.cms-input:focus {
  border-color: #3b82f6;
  outline: none;
}

.cms-file-input {
  width: 100%;
  padding: 20px;
  border: 2px dashed #bbb;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  background: #f9f9f9;
  box-sizing: border-box;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.cms-file-input:hover {
  background: #f1f1f1;
  border-color: #3b82f6;
}

.cms-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.cms-btn {
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
  font-size: 14px;
}

.cms-btn:active {
  transform: scale(0.98);
}

.cms-btn-cancel {
  background: #e0e0e0;
  color: #333;
}

.cms-btn-cancel:hover {
  background: #d4d4d4;
}

.cms-btn-save {
  background: #3b82f6;
  color: white;
}

.cms-btn-save:hover {
  background: #2563eb;
}

.cms-admin-link {
  display: inline-block;
  font-size: 12px;
  color: inherit;
  opacity: 0.2;
  text-decoration: none;
  transition: opacity 0.2s;
  margin-left: 10px;
}

.cms-admin-link:hover {
  opacity: 0.8;
}

/* Mobile adjustments for edit buttons */

@media (max-width: 768px), (hover: none) {
  .cms-edit-btn {
    opacity: 0.8;
    top: -16px;
    right: -16px;
    margin-top: 0;
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .cms-editable-wrapper:hover .cms-edit-btn,
  .cms-edit-btn:active {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Positioning for edit buttons inside primary/secondary buttons */

.btn-primary,
.btn-secondary,
.btn {
  position: relative;
}

.btn-primary .cms-editable-wrapper,
.btn-secondary .cms-editable-wrapper,
.btn .cms-editable-wrapper {
  position: static;
}

.btn-primary .cms-edit-btn,
.btn-secondary .cms-edit-btn,
.btn .cms-edit-btn {
  right: -16px;
  top: -16px;
  margin-top: 0;
}

@media (max-width: 768px), (hover: none) {
  .btn-primary .cms-edit-btn,
  .btn-secondary .cms-edit-btn,
  .btn .cms-edit-btn {
    right: -16px;
    top: -16px;
    margin-top: 0;
  }
}

/* Utility classes for spacing, hiding elements, and statuses */

.cms-status-msg {
  font-size: 12px;
  margin-bottom: 10px;
  display: none;
}

.cms-error-msg {
  color: red;
}

.cms-action-link {
  font-size: 12px;
  color: var(--primary);
}

.cms-helper-text {
  font-size: 12px;
  color: #666;
  margin-top: 10px;
  margin-bottom: 10px;
}

.cms-hidden {
  display: none !important;
}

.cms-textarea-tall {
  min-height: 100px !important;
  height: auto;
}

.cms-textarea-sm {
  min-height: 80px !important;
  height: auto;
}

/* Size variations for modals and settings grids */

.cms-modal-large {
  max-width: 800px;
  width: 95%;
}

.cms-modal-large .cms-textarea {
  min-height: 400px;
  font-size: 16px;
}

@media (max-width: 768px) {
  .cms-modal-large .cms-textarea {
    min-height: 300px;
  }
}

.cms-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.cms-settings-label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 600;
}

.cms-settings-hr {
  margin: 15px 0;
  border: 0;
  border-top: 1px solid #eee;
}

.cms-msg-box {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-weight: 600;
  text-align: center;
}

.cms-msg-success {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: block;
}

.cms-msg-error {
  background-color: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
  border: 1px solid rgba(255, 59, 48, 0.3);
  display: block;
}

/* Fixed floating admin banner styles and animations */

.cms-admin-banner {
  position: fixed;
  top: 8px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 10000;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  animation: cmsSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color: #333;
  font-family: "Montserrat", sans-serif;
}

@media (max-width: 1930px) {
  .cms-admin-banner {
    display: none !important;
  }
}

.cms-admin-banner-icon {
  background: #3b82f6;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.cms-admin-banner-text {
  display: flex;
  flex-direction: column;
}

.cms-admin-banner-text strong {
  font-size: 15px;
  color: #2c3e50;
  margin-bottom: 2px;
}

.cms-admin-banner-text span {
  font-size: 12px;
  color: #666;
}

.cms-admin-banner-text b {
  color: #3b82f6;
  font-weight: 700;
}

/* Tab navigation within settings modal */

.cms-tab-content {
  display: none;
}

.cms-tab-content.active {
  display: block;
  animation: cmsFadeInTab 0.2s ease-in-out;
}

@keyframes cmsFadeInTab {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Custom scrollbar for modal body content */

.cms-modal-body {
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 5px 2px 2px;
  margin-bottom: 20px;
}

.cms-modal-body::-webkit-scrollbar {
  width: 6px;
}

.cms-modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.cms-modal-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}

.cms-modal-body::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

@keyframes cmsSlideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .cms-grid-2 {
    grid-template-columns: 1fr;
  }

  .cms-admin-banner {
    top: auto;
    bottom: 20px;
    right: auto;
    left: 20px;
    padding: 8px;
    gap: 0;
    border-radius: 50%;
    animation: cmsSlideUpMobile 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .cms-admin-banner-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
    box-shadow: none;
  }

  .cms-admin-banner-text strong {
    display: none;
  }

  .cms-admin-banner-text span {
    display: none;
  }

  @keyframes cmsSlideUpMobile {
    from {
      transform: translateY(120%);
      opacity: 0;
    }

    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}

/* Extracted media grid layout and upload wrappers */

/* CMS Edit Mode Toggle Switch */
.cms-toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}
.cms-toggle-switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.cms-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .3s;
  border-radius: 34px;
}
.cms-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
.cms-toggle-switch input:checked + .cms-toggle-slider {
  background-color: #3b82f6;
}
.cms-toggle-switch input:checked + .cms-toggle-slider:before {
  transform: translateX(24px);
}
