/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(var(--bg-rgb), 0.92);
}

/* Reusable toggle switch — replaces stock checkboxes inside modals.
   Pure CSS, no JS, accessible (the underlying input still toggles). */
.eo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.eo-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.eo-toggle .eo-toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: rgba(var(--text-rgb), 0.18);
  border-radius: 22px;
  transition: background-color 0.12s linear;
  flex-shrink: 0;
  will-change: background-color;
}
.eo-toggle .eo-toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.12s ease-out;
  will-change: transform;
}
.eo-toggle input[type="checkbox"]:checked + .eo-toggle-track {
  background: var(--status-success);
}
.eo-toggle input[type="checkbox"]:checked + .eo-toggle-track::after {
  transform: translateX(18px);
}
.eo-toggle input[type="checkbox"]:focus-visible + .eo-toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.eo-toggle .eo-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.eo-toggle .eo-toggle-text-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.eo-toggle .eo-toggle-text-help {
  font-size: 12px;
  color: rgba(var(--text-rgb), 0.6);
}

/* Card-framed variant — wraps the toggle in a subtle panel so it stands
   apart inside a busy modal body. Use `.eo-toggle.eo-toggle-card`. */
.eo-toggle-card {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  background: rgba(var(--text-rgb), 0.04);
  border: 1px solid rgba(var(--text-rgb), 0.12);
  border-radius: 6px;
}
.eo-toggle-card:hover {
  background: rgba(var(--text-rgb), 0.07);
}

.modal-content {
  background-color: var(--card-bg);
  margin: 5% auto;
  padding: 0;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Reusable empty/info-state card. Use inside any modal body or panel
   when there's nothing to render and we need to explain why. Variants:
   .info (cyan), .warning (amber, default), .danger (red). */
.eo-empty-state {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(var(--status-warning-rgb), 0.08);
  border: 1px solid rgba(var(--status-warning-rgb), 0.30);
  color: var(--status-warning);
  margin: 4px 0;
}
.eo-empty-state.info {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.30);
  color: var(--accent);
}
.eo-empty-state.danger {
  background: rgba(var(--status-danger-rgb), 0.08);
  border-color: rgba(var(--status-danger-rgb), 0.35);
  color: #fecaca;
}
.eo-empty-state-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(var(--text-rgb), 0.06);
  color: currentColor;
}
.eo-empty-state-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.eo-empty-state-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.eo-empty-state-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(var(--text-rgb), 0.78);
}
.eo-empty-state-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--card-bg);
}

.modal-header h2 {
  margin: 0;
  color: var(--text-color);
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-color);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.modal-close:hover {
  background-color: rgba(var(--text-rgb), 0.1);
}

.modal-body {
  padding: 0;
  overflow: hidden;
  flex: 1;
}

#readme-iframe {
  width: 100%;
  height: 80vh;
  border: none;
  background: white;
  border-radius: 0 0 0 0;
}

#readme-content {
  color: var(--text-color);
  line-height: 1.6;
}

#readme-content h1,
#readme-content h2,
#readme-content h3 {
  color: var(--text-color);
  margin-top: 24px;
  margin-bottom: 16px;
}

#readme-content h1:first-child {
  margin-top: 0;
}

#readme-content p {
  margin-bottom: 16px;
}

#readme-content code {
  background-color: rgba(var(--text-rgb), 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

#readme-content pre {
  background-color: rgba(var(--text-rgb), 0.05);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

#readme-content pre code {
  background: none;
  padding: 0;
}

#readme-content ul,
#readme-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

#readme-content blockquote {
  border-left: 4px solid var(--primary-color);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-muted);
  font-style: italic;
}

#readme-content a {
  color: var(--primary-color);
  text-decoration: none;
}

#readme-content a:hover {
  text-decoration: underline;
}

.loading {
  text-align: center;
  color: var(--text-color);
  padding: 40px;
  font-style: italic;
}

.error {
  color: var(--status-danger);
  text-align: center;
  padding: 40px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    margin: 2% auto;
    max-height: 95vh;
  }
  
  .modal-header {
    padding: 16px 20px;
  }
  
  .modal-body {
    padding: 20px;
  }
  
  .modal-header h2 {
    font-size: 18px;
  }
}

/* ============================================================
   EO Modal — unified modal system. Use openEoModal() in JS.
   See eo-modal.js for API + composable section primitives.
   ============================================================ */

.eo-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--bg-rgb), 0.92);
  padding: 16px;
}
.eo-modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  background: var(--card-bg, var(--code-bg));
  border: 1px solid var(--border-color, var(--border-strong));
  border-radius: 12px;
  overflow: hidden;
}
.eo-modal[data-size="sm"] .eo-modal-content { max-width: 460px; }
.eo-modal[data-size="lg"] .eo-modal-content { max-width: 820px; }

.eo-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color, var(--border-strong));
}
.eo-modal-header-info { display: flex; gap: 14px; align-items: center; flex: 1; min-width: 0; }
.eo-modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(var(--text-rgb), 0.04);
  padding: 4px;
  flex-shrink: 0;
}
.eo-modal[data-size="sm"] .eo-modal-icon { width: 36px; height: 36px; }
.eo-modal-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 2px;
}
.eo-modal-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.eo-modal-desc { margin: 4px 0 0 0; font-size: 13px; color: rgba(var(--text-rgb), 0.65); line-height: 1.4; }
.eo-modal-close {
  background: none;
  border: none;
  color: rgba(var(--text-rgb), 0.7);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.eo-modal-close:hover { background: rgba(var(--text-rgb), 0.10); color: var(--text-primary); }

.eo-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.eo-modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-color, var(--border-strong));
}
.eo-modal-footer .btn { flex: 1 1 0; }

/* ----- Composable body primitives ----- */
.eo-modal-section { display: flex; flex-direction: column; gap: 6px; }
.eo-modal-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(var(--text-rgb), 0.55);
  font-weight: 600;
}
.eo-modal-section-text { font-size: 13px; color: rgba(var(--text-rgb), 0.80); line-height: 1.5; margin: 0; }

.eo-modal-badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.eo-modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(var(--text-rgb), 0.05);
  border: 1px solid rgba(var(--text-rgb), 0.10);
  color: rgba(var(--text-rgb), 0.85);
}
.eo-modal-badge.success { background: rgba(var(--status-success-rgb),0.10);  border-color: rgba(var(--status-success-rgb),0.30);  color: var(--status-success); }
.eo-modal-badge.info    { background: rgba(var(--accent-rgb),0.10); border-color: rgba(var(--accent-rgb),0.30); color: var(--accent); }
.eo-modal-badge.purple  { background: rgba(var(--accent-rgb),0.10); border-color: rgba(var(--accent-rgb),0.30); color: #d8b4fe; }
.eo-modal-badge.warning { background: rgba(var(--status-warning-rgb),0.10); border-color: rgba(var(--status-warning-rgb),0.30); color: var(--status-warning); }
.eo-modal-badge.danger  { background: rgba(var(--status-danger-rgb),0.10);  border-color: rgba(var(--status-danger-rgb),0.30);  color: var(--status-danger); }

.eo-modal-url-list { display: flex; flex-direction: column; gap: 4px; }
.eo-modal-url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(var(--text-rgb), 0.03);
  border: 1px solid rgba(var(--text-rgb), 0.08);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
  min-width: 0;
}
.eo-modal-url-row:hover { background: rgba(var(--accent-rgb), 0.08); border-color: rgba(var(--accent-rgb), 0.30); }
.eo-modal-url-label { font-size: 14px; font-weight: 500; color: var(--text-primary); flex-shrink: 0; }
.eo-modal-url-href {
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: rgba(var(--text-rgb), 0.50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  text-align: right;
}
.eo-modal-url-row svg { color: rgba(var(--text-rgb), 0.50); flex-shrink: 0; }

.eo-modal-cred {
  background: rgba(var(--text-rgb), 0.03);
  border: 1px solid rgba(var(--text-rgb), 0.08);
  border-radius: 8px;
  padding: 10px 12px;
}
.eo-modal-cred + .eo-modal-cred { margin-top: 6px; }
.eo-modal-cred-title { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.eo-modal-cred-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.eo-modal-cred-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(var(--text-rgb), 0.50);
  width: 38px;
  flex-shrink: 0;
}
.eo-modal-cred-value {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  color: #e0f2fe;
  padding: 4px 8px;
  background: rgba(var(--bg-rgb), 0.25);
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eo-modal-cred-toggle {
  font-size: 11px;
  padding: 4px 10px;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.40);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.eo-modal-cred-toggle:hover { background: rgba(var(--accent-rgb), 0.10); }

.eo-modal-cred-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: rgba(var(--text-rgb), 0.50);
  border: 1px solid rgba(var(--text-rgb), 0.12);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.eo-modal-cred-copy:hover {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.08);
}
.eo-modal-cred-copy.copied {
  color: var(--status-success);
  border-color: rgba(var(--status-success-rgb), 0.50);
  background: rgba(var(--status-success-rgb), 0.10);
}

.eo-modal-empty { text-align: center; color: rgba(var(--text-rgb), 0.55); font-size: 13px; padding: 12px 0; }

/* Body content shouldn't push the modal wider than its container. */
.eo-modal-body :where(input, textarea, select) { max-width: 100%; box-sizing: border-box; }
.eo-modal-body :where(p, h1, h2, h3, h4) { overflow-wrap: anywhere; }

/* Keep close X reachable in the corner even when the header stacks. */
.eo-modal-header { position: relative; }
.eo-modal-close { min-width: 44px; min-height: 44px; }

/* Tablet + smaller phones */
@media (max-width: 560px) {
  .eo-modal { padding: 8px; align-items: flex-end; }
  .eo-modal-content { max-height: 92vh; border-radius: 14px 14px 8px 8px; }
  .eo-modal-header { padding: 14px 56px 14px 16px; }
  .eo-modal-icon { width: 44px; height: 44px; }
  .eo-modal-title { font-size: 18px; }
  .eo-modal-close { position: absolute; top: 8px; right: 8px; }
  .eo-modal-body { padding: 14px 16px; gap: 12px; }
  .eo-modal-footer { padding: 12px 16px 16px; }
  .eo-modal-url-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .eo-modal-url-href { text-align: left; width: 100%; }
  .eo-modal-cred-row { flex-wrap: wrap; }
  .eo-modal-cred-value { width: 100%; }
}

/* Very narrow phones — stack the footer buttons so labels don't squash. */
@media (max-width: 380px) {
  .eo-modal-footer { flex-direction: column-reverse; }
  .eo-modal-footer .btn { width: 100%; }
  .eo-modal-eyebrow { font-size: 10px; }
  .eo-modal-title { font-size: 17px; }
  .eo-modal-icon { width: 38px; height: 38px; }
}

/* Uninstall-modal toggles — text in the middle, decorative coloured icon on the right. */
.eo-toggle.eo-toggle-card.uninstall-extra { gap: 12px; align-items: center; }
.eo-toggle.eo-toggle-card.uninstall-extra .eo-toggle-text { flex: 1; min-width: 0; }
.eo-toggle.eo-toggle-card.uninstall-extra .uninstall-extra-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: filter 0.15s ease, transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.eo-toggle.eo-toggle-card.uninstall-extra .uninstall-extra-icon.image  { background: rgba(var(--accent-rgb), 0.12); border-color: rgba(var(--accent-rgb), 0.28); color: var(--accent); }
.eo-toggle.eo-toggle-card.uninstall-extra .uninstall-extra-icon.tasks  { background: rgba(var(--accent-rgb), 0.12); border-color: rgba(var(--accent-rgb), 0.30); color: var(--accent); }
.eo-toggle.eo-toggle-card.uninstall-extra:hover .uninstall-extra-icon  { filter: brightness(1.2); transform: scale(1.04); }
.eo-toggle.eo-toggle-card.uninstall-extra input[type="checkbox"]:checked ~ .uninstall-extra-icon.image { background: rgba(var(--status-success-rgb), 0.18); border-color: rgba(var(--status-success-rgb), 0.45); color: var(--status-success); }
.eo-toggle.eo-toggle-card.uninstall-extra input[type="checkbox"]:checked ~ .uninstall-extra-icon.tasks { background: rgba(var(--status-success-rgb), 0.18); border-color: rgba(var(--status-success-rgb), 0.45); color: var(--status-success); }

/* End icon in the eo-modal header — sits on the right side of the
   header (before the close X). Use for tool emoji / accent badges
   that don't belong in the title text. */
.eo-modal-end-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  color: var(--accent);
}
