/**
 * Edit Mode Overlay Styles
 * Generic styles for inline editing on any site with admin
 * Uses site's CSS variables for consistency
 */

/* ============================================
   Edit Mode Floating Badge (discrete)
   ============================================ */
.edit-mode-badge {
  position: fixed;
  top: 16px;
  left: 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: white;
  padding: 10px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.1);
  opacity: 0.95;
  transition: all 0.2s ease;
  font-family: inherit;
  cursor: default;
  backdrop-filter: blur(10px);
}

.edit-mode-badge:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.edit-mode-badge__dot {
  width: 8px;
  height: 8px;
  background: var(--accent, #15B0BC);
  border-radius: 50%;
  animation: editPulse 2s ease-in-out infinite;
}

@keyframes editPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

.edit-mode-badge__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,0.3);
}

.edit-mode-badge__btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.edit-mode-badge__btn:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.1);
}

.edit-mode-badge__btn--danger:hover {
  background: #ef4444;
}

.edit-mode-badge__btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================
   Editable Element Highlights
   ============================================ */
[data-edit] {
  position: relative;
  transition: all 0.2s ease;
}

/* Editable elements highlight on hover */
body.edit-mode [data-edit] {
  position: relative;
  cursor: pointer;
}

body.edit-mode [data-edit]:hover {
  outline: 3px dashed var(--accent, #15B0BC);
  outline-offset: 6px;
  box-shadow: 0 0 0 3px rgba(21, 176, 188, 0.15);
}

/* Disable overlays that block editable elements */
body.edit-mode .founder-overlay,
body.edit-mode .video-overlay,
body.edit-mode [data-edit] .overlay {
  pointer-events: none;
  opacity: 0.3;
}

/* Allow outline to be visible outside clipped containers */
body.edit-mode .founder-image,
body.edit-mode .video-placeholder {
  overflow: visible;
}

/* Label tooltip on hover */
body.edit-mode [data-edit]::after {
  content: attr(data-edit-label);
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary, #064661);
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

body.edit-mode [data-edit]:hover::after {
  opacity: 1;
}

/* ============================================
   Edit Panel (slides from right)
   ============================================ */
.edit-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: white;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 999998;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  font-family: inherit;
}

.edit-panel.open {
  transform: translateX(0);
}

.edit-panel__header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.edit-panel__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark, #134661);
  display: flex;
  align-items: center;
  gap: 10px;
}

.edit-panel__title-icon {
  width: 32px;
  height: 32px;
  background: var(--primary, #064661);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.edit-panel__close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-medium, #4A5F68);
  transition: all 0.2s ease;
}

.edit-panel__close:hover {
  background: #e5e7eb;
  color: var(--text-dark, #134661);
}

.edit-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.edit-panel__footer {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #fafbfc;
}

/* ============================================
   Form Elements
   ============================================ */
.edit-field {
  margin-bottom: 20px;
}

.edit-field__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark, #134661);
  margin-bottom: 8px;
}

.edit-field__sublabel {
  font-size: 12px;
  color: var(--text-medium, #4A5F68);
  font-weight: 400;
  margin-left: 4px;
}

.edit-field__input,
.edit-field__textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-dark, #134661);
  transition: all 0.2s ease;
  font-family: inherit;
  background: white;
}

.edit-field__input:focus,
.edit-field__textarea:focus {
  outline: none;
  border-color: var(--primary, #064661);
  box-shadow: 0 0 0 3px rgba(6, 70, 97, 0.1);
}

.edit-field__textarea {
  min-height: 100px;
  resize: vertical;
}

.edit-field__number {
  width: 140px;
}

/* Custom Checkboxes */
.edit-field input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #e5e7eb;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.edit-field input[type="checkbox"]:checked {
  background: var(--primary, #064661);
  border-color: var(--primary, #064661);
}

.edit-field input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.edit-field input[type="checkbox"]:hover {
  border-color: var(--primary, #064661);
}

.edit-field input[type="checkbox"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(6, 70, 97, 0.15);
}

/* Language tabs */
.edit-lang-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 8px;
}

.edit-lang-tab {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-medium, #4A5F68);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.edit-lang-tab.active {
  background: white;
  color: var(--primary, #064661);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ============================================
   Image Picker
   ============================================ */
.edit-image-picker {
  border: 2px dashed #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: all 0.2s ease;
}

.edit-image-picker:hover {
  border-color: var(--accent, #15B0BC);
}

.edit-image-picker__current {
  margin-bottom: 12px;
}

.edit-image-picker__current img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.edit-image-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  padding: 8px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  flex: 1;
  min-height: 150px;
}

.edit-image-library__item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  position: relative;
  min-height: 0;
  background: #f3f4f6;
}

.edit-image-library__item:hover {
  border-color: var(--accent, #15B0BC);
}

.edit-image-library__item.selected {
  border-color: var(--primary, #064661);
  box-shadow: 0 0 0 3px rgba(6, 70, 97, 0.2);
}

.edit-image-library__item img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edit-image-library__item.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(6, 70, 97, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.edit-image-library__item.selected::before {
  content: '\2713';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 24px;
  font-weight: bold;
  z-index: 1;
}

/* ============================================
   Buttons
   ============================================ */
.edit-btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}

.edit-btn--primary {
  background: var(--primary, #064661);
  color: white;
}

.edit-btn--primary:hover {
  background: var(--primary-dark, #134661);
  transform: translateY(-1px);
}

.edit-btn--secondary {
  background: #f3f4f6;
  color: var(--text-dark, #134661);
}

.edit-btn--secondary:hover {
  background: #e5e7eb;
}

.edit-btn--success {
  background: var(--accent, #15B0BC);
  color: white;
}

.edit-btn--success:hover {
  filter: brightness(1.1);
}

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

/* ============================================
   Loading & Toast
   ============================================ */
.edit-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.edit-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--primary, #064661);
  border-radius: 50%;
  animation: editSpin 0.7s linear infinite;
}

@keyframes editSpin {
  to { transform: rotate(360deg); }
}

.edit-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  left: auto;
  padding: 12px 20px;
  background: var(--text-dark, #134661);
  color: white;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 999999;
  transform: translateX(20px);
  opacity: 0;
  transition: all 0.2s ease;
}

.edit-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.edit-toast--success {
  background: #10b981;
}

.edit-toast--error {
  background: #ef4444;
}

/* ============================================
   Backdrop
   ============================================ */
.edit-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  z-index: 999997;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.edit-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
  .edit-panel {
    width: 100%;
    max-width: 100vw;
  }

  .edit-panel__body {
    padding: 16px;
  }

  .edit-panel__footer {
    padding: 12px 16px;
  }

  .edit-mode-badge {
    top: auto;
    bottom: 12px;
    left: 12px;
    padding: 8px 10px;
    gap: 0;
  }

  .edit-mode-badge > span:not(.edit-mode-badge__dot) {
    display: none;
  }

  .edit-mode-badge__actions {
    margin-left: 8px;
    padding-left: 8px;
  }

  .edit-image-library {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-height: none;
    overflow-y: visible;
  }

  .edit-image-library__item {
    aspect-ratio: 1;
    height: auto;
    min-height: 80px;
    max-height: 100px;
  }

  .edit-image-library__item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  .edit-image-picker__current img {
    max-height: 80px;
  }

  .edit-field__input,
  .edit-field__textarea {
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .edit-lang-tabs {
    flex-wrap: nowrap;
  }

  .edit-lang-tab {
    padding: 6px 12px;
    font-size: 12px;
  }

  .edit-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Tier rows on mobile */
  .edit-tier-row {
    flex-wrap: wrap;
  }

  .edit-tier-row span {
    min-width: 60px !important;
    font-size: 10px !important;
  }

  .edit-tier-row input {
    width: 55px !important;
    padding: 4px !important;
    font-size: 12px !important;
  }
}

/* ============================================
   Print: Hide edit elements
   ============================================ */
@media print {
  .edit-mode-badge,
  .edit-panel,
  .edit-backdrop,
  .edit-toast {
    display: none !important;
  }
}
