/* CMS edit mode styles */

.cms-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.cms-login-box {
  width: min(360px, 90vw);
  padding: 2rem;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.cms-login-box h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-heading);
  font-size: 1.5rem;
}

.cms-login-box p {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--foreground-600);
}

.cms-login-box input {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--background-300);
  border-radius: 0.375rem;
}

.cms-login-box button {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 0.375rem;
  background: var(--primary-500);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.cms-login-box button:hover {
  background: var(--primary-600);
}

.cms-login-error {
  margin-top: 0.75rem;
  font-size: 0.8125rem;
  color: #c0392b;
}

.cms-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #1a1a1a;
  color: #fff;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.875rem;
}

.cms-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cms-toolbar-badge {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--primary-500);
  font-size: 0.75rem;
  font-weight: 600;
}

.cms-toolbar-dirty {
  color: #f39c12;
  font-size: 0.8125rem;
}

.cms-toolbar-hint {
  display: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
}

@media (min-width: 900px) {
  .cms-toolbar-hint {
    display: inline;
  }
}

.cms-toolbar-actions {
  display: flex;
  gap: 0.5rem;
}

.cms-toolbar-actions button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.cms-btn-save {
  background: var(--primary-500);
  color: #fff;
}

.cms-btn-hero-bg {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.cms-btn-hero-bg:hover {
  background: rgba(255, 255, 255, 0.25);
}

.cms-btn-save:hover {
  background: var(--primary-600);
}

.cms-btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cms-btn-exit {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.cms-btn-exit:hover {
  background: rgba(255, 255, 255, 0.2);
}

body.cms-edit-mode {
  padding-bottom: 3.5rem;
}

body.cms-edit-mode [data-cms],
body.cms-edit-mode [data-cms-section],
body.cms-edit-mode [data-cms-image] {
  cursor: pointer;
  outline: 2px dashed transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
}

body.cms-edit-mode [data-cms]:hover,
body.cms-edit-mode [data-cms-section]:hover,
body.cms-edit-mode [data-cms-image]:hover {
  outline-color: rgba(168, 116, 42, 0.6);
}

body.cms-edit-mode [data-cms].cms-editing {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.cms-section-controls {
  position: fixed;
  z-index: 100002;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.cms-section-controls.is-visible {
  opacity: 1;
  pointer-events: auto;
}

body.cms-edit-mode [data-cms-section].cms-editable {
  outline: 1px dashed rgba(168, 116, 42, 0.25);
  outline-offset: -1px;
}

body.cms-edit-mode [data-cms-section].cms-editable:hover {
  outline-color: rgba(168, 116, 42, 0.55);
}

.cms-section-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 0.375rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}

.cms-section-btn:hover {
  background: rgba(168, 116, 42, 0.95);
}

.cms-section-delete:hover {
  background: rgba(192, 57, 43, 0.95);
}

.cms-bg-edit-btn {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border: none;
  border-radius: 0.375rem;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.cms-bg-edit-btn:hover {
  background: rgba(168, 116, 42, 0.95);
}

@media (min-width: 768px) {
  .cms-bg-edit-btn {
    bottom: 2rem;
  }
}

body.cms-edit-mode .cms-bg-edit-btn {
  bottom: calc(1.5rem + 4.5rem);
}

@media (min-width: 768px) {
  body.cms-edit-mode .cms-bg-edit-btn {
    bottom: calc(2rem + 4.5rem);
  }
}

.cms-popup {
  position: fixed;
  z-index: 100001;
  min-width: 220px;
  padding: 1rem;
  border-radius: 0.5rem;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.cms-popup-centered {
  left: 50%;
  bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  top: auto;
  transform: translateX(-50%);
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.cms-popup label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--foreground-700);
}

.cms-popup input[type="color"] {
  width: 100%;
  height: 2.5rem;
  padding: 0.125rem;
  border: 1px solid var(--background-300);
  border-radius: 0.375rem;
  cursor: pointer;
}

.cms-popup select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--background-300);
  border-radius: 0.375rem;
}

.cms-popup-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.cms-popup-actions button {
  flex: 1;
  padding: 0.375rem;
  border: none;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.cms-popup-apply {
  background: var(--primary-500);
  color: #fff;
}

.cms-popup-close {
  background: var(--background-200);
}

.cms-image-popup {
  min-width: 260px;
}

.cms-image-preview {
  margin-bottom: 0.75rem;
  border-radius: 0.375rem;
  overflow: hidden;
  background: var(--background-100);
}

.cms-image-preview img {
  display: block;
  width: 100%;
  max-height: 140px;
  object-fit: cover;
}

.cms-image-popup input[type="file"] {
  width: 100%;
  font-size: 0.75rem;
}

.cms-image-alt-label {
  display: block;
  margin-top: 0.75rem;
}

.cms-image-alt-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--background-300);
  border-radius: 0.375rem;
  font-size: 0.8125rem;
}

.cms-image-hint {
  margin: 0.375rem 0 0;
  font-size: 0.6875rem;
  color: var(--foreground-500);
}

.cms-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100000;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  background: #27ae60;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: cms-toast-in 0.3s ease;
}

.cms-toast.error {
  background: #c0392b;
}

@keyframes cms-toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

[data-cms-font="h1"] { font-size: var(--fs-h1); }
[data-cms-font="h2"] { font-size: var(--fs-h2); }
[data-cms-font="h3"] { font-size: var(--fs-h3); }
[data-cms-font="body"] { font-size: var(--fs-body); }
[data-cms-font="small"] { font-size: var(--fs-small); }

/* Gallery add / remove in edit mode */
body.cms-edit-mode .about-gallery-item {
  cursor: pointer;
}

body.cms-edit-mode .about-gallery-item:hover {
  transform: none;
  box-shadow: none;
  outline: 2px solid rgba(168, 116, 42, 0.55);
  outline-offset: 2px;
}

.cms-gallery-remove {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0.375rem;
  background: rgba(192, 57, 43, 0.92);
  color: #fff;
  font-size: 1.125rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: background 0.15s, transform 0.15s;
}

body.cms-edit-mode .cms-gallery-remove {
  display: inline-flex;
}

.cms-gallery-remove:hover {
  background: #a93226;
  transform: scale(1.05);
}

.cms-gallery-add {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.875rem 1rem;
  border: 2px dashed rgba(168, 116, 42, 0.45);
  border-radius: 0.5rem;
  background: rgba(168, 116, 42, 0.06);
  color: var(--primary-700);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

body.cms-edit-mode .cms-gallery-add {
  display: inline-flex;
}

.cms-gallery-add:hover {
  background: rgba(168, 116, 42, 0.12);
  border-color: rgba(168, 116, 42, 0.75);
}

.cms-gallery-add i {
  font-size: 1.25rem;
}
