/*
  Admin System CSS
  ================
  Drop this into your project alongside admin.js.

  CSS variables used (define these in your :root or replace with hardcoded values):
    --primary       : your brand color (used for Save button bg)        e.g. #2563eb
    --border        : subtle border color                                e.g. #e5e7eb
    --bg-page       : your page background color                         e.g. #f9fafb
    --text-dark     : primary text color                                 e.g. #111827
    --text-muted    : secondary/muted text color                         e.g. #6b7280
    --r-full        : full-radius value for pill shapes                  e.g. 9999px
    --notif-h       : height of your alert bar — set by JS, start at 0px

  The yellow accent (#ffd200) is used throughout for all admin UI chrome.
  Change this one color to rebrand the entire admin system.
*/

/* ── CSS variable defaults (override in your :root) ── */
:root {
  --notif-h: 0px;
}


/* ════════════════════════════════════════════
   ADMIN TOGGLE BUTTON
   Place <button id="admin-toggle-btn"> in your footer.
   ════════════════════════════════════════════ */

.admin-toggle-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.35);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-top: 8px;
}
.admin-toggle-btn:hover {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.4);
}
.admin-mode .admin-toggle-btn {
  color: #ffd200;
  border-color: rgba(255,210,0,0.5);
}

/* Adjust for light-background footers: */
/* .admin-toggle-btn { border-color: rgba(0,0,0,0.12); color: rgba(0,0,0,0.3); } */


/* ════════════════════════════════════════════
   HEADER EXIT BUTTON
   Optional: <button id="admin-header-exit-btn"> in your header.
   Hidden by default — appears only in admin mode.
   ════════════════════════════════════════════ */

.admin-header-exit-btn {
  display: none;
  flex-shrink: 0;
}
.admin-mode .admin-header-exit-btn {
  display: flex;
  align-items: center;
  background: #ffd200;
  color: #1a1a1a;
  border: none;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s;
}
.admin-mode .admin-header-exit-btn:hover {
  background: #f0c800;
}


/* ════════════════════════════════════════════
   ALERT / NOTIFICATION BAR
   A sticky amber banner for urgent announcements.
   Markup lives in your header component — see example-page.html.
   ════════════════════════════════════════════ */

#notif-bar {
  position: sticky;
  top: 0;
  z-index: 201;
  background: #f59e0b;
  color: #1a1a2e;
  text-align: center;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
}
#notif-bar[hidden] { display: none; } /* prevent sticky from taking up space when hidden */
.notif-bar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
}
.notif-bar-inner svg { flex-shrink: 0; }

/* In admin mode the bar sits below the fixed admin banner (34px) */
.admin-mode #notif-bar { top: 34px; }


/* ════════════════════════════════════════════
   ALERT ADMIN CONTROL BAR
   Shown only in admin mode — lets admins turn the bar on/off and edit the message.
   ════════════════════════════════════════════ */

#notif-admin-bar {
  display: none;
  background: #fffbeb;
  border-bottom: 2px solid #ffd200;
  padding-top: 34px; /* clear the fixed admin banner */
}
.admin-mode #notif-admin-bar { display: block; }

.notif-admin-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}
.notif-admin-view,
.notif-admin-edit {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}
.notif-admin-edit[hidden] { display: none; }

.notif-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #dc2626;
  flex-shrink: 0;
}
.notif-status-dot--on { background: #16a34a; }

.notif-status-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark, #111827);
  white-space: nowrap;
}
.notif-admin-preview {
  font-size: 0.85rem;
  color: #6b7280;
  font-style: italic;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notif-admin-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.notif-admin-btn {
  padding: 6px 14px;
  border-radius: var(--r-full, 9999px);
  border: 2px solid #d1b800;
  background: transparent;
  color: #1a1a2e;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.notif-admin-btn:hover { background: #ffd200; border-color: #ffd200; }
.notif-admin-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.notif-toggle-btn--on { border-color: #dc2626; color: #dc2626; }
.notif-toggle-btn--on:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.notif-admin-input {
  flex: 1;
  min-width: 220px;
  padding: 7px 12px;
  border: 1.5px solid #ffd200;
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.notif-admin-input:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.2);
}
.notif-admin-btn--save { background: #ffd200; border-color: #ffd200; }
.notif-admin-btn--save:hover { background: #f5c800; border-color: #f5c800; }


/* ════════════════════════════════════════════
   ADMIN MODE BANNER
   Fixed top bar that appears when body.admin-mode is active.
   Uses ::before on <body> — no extra HTML needed.
   ════════════════════════════════════════════ */

.admin-mode::before {
  content: 'Admin Mode — click the pencil icon next to any section to edit it';
  display: block;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  background: #1a1a2e;
  color: #ffd200;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  padding: 7px 16px;
  letter-spacing: 0.03em;
}

/* If you have a sticky header, offset it in admin mode so it clears the banner: */
/* .admin-mode .site-header { top: calc(34px + var(--notif-h)); } */


/* ════════════════════════════════════════════
   EDIT GROUP CONTAINERS & TRIGGER BUTTON
   Groups are marked with data-egroup.
   The yellow pencil "Edit" button is injected by buildUI().
   ════════════════════════════════════════════ */

.admin-mode [data-egroup] {
  position: relative; /* so the absolute-positioned trigger button anchors here */
}

.admin-edit-trigger {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  align-items: center;
  gap: 6px;
  background: #ffd200;
  color: #1a1a1a;
  border: none;
  border-radius: 6px;
  padding: 6px 12px 6px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: background 0.15s, transform 0.15s;
}
.admin-edit-trigger svg { width: 14px; height: 14px; flex-shrink: 0; }
.admin-edit-trigger:hover { background: #e6bd00; transform: translateY(-1px); }
.admin-mode .admin-edit-trigger { display: inline-flex; }
/* While one section is being edited, hide all other triggers */
.admin-editing-active .admin-edit-trigger { display: none; }


/* ════════════════════════════════════════════
   EDITABLE ELEMENT HIGHLIGHT
   Applied to elements with contentEditable during an active edit session.
   ════════════════════════════════════════════ */

/* Force font so pasted content can't inject external fonts or sizes */
.admin-editing,
.admin-editing * {
  font-family: inherit !important;
  font-size:   inherit !important;
}

/* Special case: buttons that become editable */
.btn.admin-editing {
  background: #fffbe6 !important;
  border-color: #ffd200 !important;
  color: #1a1a1a !important;
  box-shadow: none !important;
}

.admin-editing {
  outline: 2px dashed #ffd200 !important;
  outline-offset: 3px;
  border-radius: 3px;
  background: rgba(255,210,0,0.08) !important;
  cursor: text;
  min-height: 1em;
}


/* ════════════════════════════════════════════
   INLINE URL / PHONE INPUT ROW
   Injected below btn-type and tel-type fields during editing.
   ════════════════════════════════════════════ */

.admin-url-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding: 8px 10px;
  background: #fffbe6;
  border: 1px solid #ffd200;
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
}
.admin-url-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #7a6000;
}
.admin-url-input {
  font-size: 0.8rem;
  font-family: inherit;
  border: 1px solid #e0c800;
  border-radius: 4px;
  padding: 5px 8px;
  background: #fff;
  color: var(--text-dark, #111827);
  width: 100%;
  box-sizing: border-box;
  outline: none;
}
.admin-url-input:focus {
  border-color: #ffd200;
  box-shadow: 0 0 0 2px rgba(255,210,0,0.3);
}


/* ════════════════════════════════════════════
   ACTION BAR (Save / Cancel / Format)
   Fixed bottom-right bar, appended to body during an edit session.
   ════════════════════════════════════════════ */

.admin-action-bar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}
.admin-bar-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-bar-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border, #e5e7eb);
  margin: 2px 2px;
}
.admin-bar-format { display: flex; gap: 2px; }
.admin-fmt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-dark, #111827);
  transition: background 0.1s, border-color 0.1s;
}
.admin-fmt-btn:hover { background: var(--bg-page, #f9fafb); border-color: var(--border, #e5e7eb); }
.admin-fmt-btn[data-cmd="bold"]      { font-weight: 700; }
.admin-fmt-btn[data-cmd="italic"]    { font-style: italic; }
.admin-fmt-btn[data-cmd="underline"] { text-decoration: underline; }

/* Link / unlink buttons */
.admin-unlink-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.admin-unlink-btn:hover { background: #fff0f0; border-color: #fed7d7; }
.admin-unlink-btn[hidden] { display: none; }

/* Rich-text link styles */
[data-eid-format="rich"] a { text-decoration: underline; }

body.admin-editing-active [data-eid] a[contenteditable="false"] {
  cursor: pointer;
  border-radius: 2px;
  outline: 1px dashed rgba(255,210,0,0.7);
}
body.admin-editing-active [data-eid] a.admin-link-selected {
  outline: 2px solid #ffd200;
  background: rgba(255,210,0,0.15);
}

/* Inline link row (shown inside the action bar when inserting a link) */
.admin-link-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.admin-link-row[hidden] { display: none; }
.admin-link-text-input {
  height: 28px;
  width: 130px;
  padding: 0 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-dark, #111827);
  outline: none;
}
.admin-link-text-input:focus { border-color: var(--primary, #2563eb); }
.admin-link-input {
  height: 28px;
  width: 200px;
  padding: 0 8px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text-dark, #111827);
  outline: none;
}
.admin-link-input:focus { border-color: var(--primary, #2563eb); }
.admin-link-apply-btn,
.admin-link-cancel-btn {
  height: 28px;
  border: none;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.admin-link-apply-btn {
  padding: 0 10px;
  background: var(--primary, #2563eb);
  color: #fff;
}
.admin-link-cancel-btn {
  padding: 0 8px;
  background: var(--bg-page, #f9fafb);
  color: var(--text-dark, #111827);
  border: 1px solid var(--border, #e5e7eb);
}

.admin-bar-btns { display: flex; gap: 6px; }

.admin-save-btn,
.admin-cancel-btn {
  border: none;
  border-radius: 5px;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.admin-save-btn {
  background: var(--primary, #2563eb);
  color: #fff;
}
.admin-cancel-btn {
  background: var(--bg-page, #f9fafb);
  color: var(--text-dark, #111827);
  border: 1px solid var(--border, #e5e7eb);
}
.admin-save-btn:hover,
.admin-cancel-btn:hover { opacity: 0.85; }


/* ════════════════════════════════════════════
   TOAST NOTIFICATION
   Short-lived confirmation pill — appears centered at bottom.
   ════════════════════════════════════════════ */

.admin-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #1a1a2e;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 99px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 9999;
}
.admin-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ════════════════════════════════════════════
   PHOTO REPLACEMENT OVERLAY
   Wraps any <img data-eid-type="photo"> in admin mode.
   The wrap + button are injected by buildUI() — no extra HTML needed.
   ════════════════════════════════════════════ */

.admin-photo-wrap {
  position: relative;
  overflow: hidden; /* clips the image to any border-radius on the wrapper */
}
.admin-photo-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.admin-photo-btn {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0,0,0,0.52);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  z-index: 20;
  transition: background 0.15s;
}
.admin-photo-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
body.admin-mode .admin-photo-wrap:hover .admin-photo-btn { display: flex; }
body.admin-mode .admin-photo-wrap:hover .admin-photo-btn:hover { background: rgba(0,0,0,0.68); }
.admin-photo-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: admin-spin 0.7s linear infinite;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }


/* ════════════════════════════════════════════
   SOCIAL ICON BUTTONS
   Optional: if your footer has social links using the social-btn--empty pattern.
   ════════════════════════════════════════════ */

/* Hide icons with no URL set from regular visitors */
.social-btn--empty { display: none; }

/* In admin mode: show empty icons dimmed so admins can activate them */
.admin-mode .social-btn--empty {
  display: inline-flex;
  opacity: 0.4;
  filter: grayscale(0.5);
}
.admin-mode .social-btn { display: inline-flex; }

/* The URL span inside each social link */
.social-url-text { display: none; } /* hidden from public view */
.admin-mode .social-url-text { display: inline; font-size: 0.7rem; color: #6b7280; }
.admin-mode .social-url-text.admin-editing { display: inline; }


/* ════════════════════════════════════════════
   MOBILE — Desktop-only restrictions
   Admin editing is intentionally disabled on mobile.
   ════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Button stays visible so users see it; JS shows a "desktop only" toast */
  .admin-toggle-btn { opacity: 0.5; pointer-events: auto; }
  /* Belt-and-suspenders: hide all editing UI even if JS somehow enables it */
  .admin-mode::before { display: none; }
  .admin-mode .admin-edit-trigger { display: none !important; }
  .admin-action-bar { display: none !important; }
  .admin-mode .admin-photo-btn { display: none !important; }
  .admin-mode #notif-admin-bar { display: none; }
}
