/* ==========================================================================
   Atomware – External Dependency Status Page
   Self-contained: no dark-theme or Elementor dependency (public page).
   ========================================================================== */

:root {
  --aw-es-ok:      #22c55e;
  --aw-es-warn:    #f59e0b;
  --aw-es-error:   #ef4444;
  --aw-es-unknown: #94a3b8;

  --aw-es-ok-light:    rgba(34, 197, 94, 0.16);
  --aw-es-warn-light:  rgba(245, 158, 11, 0.18);
  --aw-es-error-light: rgba(239, 68, 68, 0.16);

  --aw-es-primary:     #1552cc;
  --aw-es-text:        #f9fafb;
  --aw-es-text-muted:  #9ca3af;
  --aw-es-border:      #1a1a1a;
  --aw-es-bg:          #000000;
  --aw-es-card-bg:     #0a0a0a;
  --aw-es-radius:      10px;
}

/* ── Outer overflow clip (prevents 100vw scrollbar bleed) ─────────────── */

.aw-es-outer {
  overflow-x: hidden;
  width: 100%;
}

/* ── Wrapper ───────────────────────────────────────────────────────────── */

.aw-es-wrap {
  max-width: none;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 32px clamp(16px, 3vw, 44px) 56px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--aw-es-text);
  background:
    radial-gradient(1200px 420px at 12% -8%, rgba(21, 82, 204, 0.09), transparent 65%),
    radial-gradient(900px 380px at 92% -12%, rgba(255, 255, 255, 0.04), transparent 70%),
    var(--aw-es-bg);
  border: 0;
  border-radius: 0;
}

/* ── Toolbar ───────────────────────────────────────────────────────────── */

.aw-es-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.aw-es-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 8px;
}

.aw-es-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--aw-es-border);
  background: var(--aw-es-card-bg);
  color: var(--aw-es-text);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
}

.aw-es-btn:hover {
  border-color: #4b5563;
  background: #1a1a1a;
}

.aw-es-btn:focus-visible {
  outline: 2px solid var(--aw-es-primary);
  outline-offset: 2px;
}

.aw-es-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.aw-es-btn-fs {
  padding: 8px 12px;
  min-width: 42px;
}

.aw-es-btn-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.aw-es-btn-label {
  white-space: nowrap;
}

/* ── Header ────────────────────────────────────────────────────────────── */

.aw-es-header {
  margin-bottom: 32px;
}

.aw-es-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.2;
}

.aw-es-last-polled {
  font-size: 0.875rem;
  color: var(--aw-es-text-muted);
  margin: 0;
}

.aw-es-stale-notice {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--aw-es-warn-light);
  border-left: 4px solid var(--aw-es-warn);
  border-radius: 4px;
  font-size: 0.875rem;
  color: #fcd34d;
}

/* ── Category sections ─────────────────────────────────────────────────── */

.aw-es-category {
  margin-bottom: 36px;
}

.aw-es-cat-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--aw-es-text-muted);
  margin: 0 0 14px;
}

/* ── Card grid ─────────────────────────────────────────────────────────── */

.aw-es-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* ── Card ──────────────────────────────────────────────────────────────── */

.aw-es-card {
  background: var(--aw-es-card-bg);
  border: 1px solid var(--aw-es-border);
  border-left: 4px solid var(--aw-es-unknown);
  border-radius: var(--aw-es-radius);
  padding: 16px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.aw-es-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.aw-es-card:hover {
  box-shadow: 0 8px 22px rgba(0,0,0,.35);
}

.aw-es-card-link:hover {
  transform: translateY(-1px);
}

/* Status-specific left border */
.aw-es-card.status-operational { border-left-color: var(--aw-es-ok); }
.aw-es-card.status-degraded     { border-left-color: var(--aw-es-warn); }
.aw-es-card.status-outage       { border-left-color: var(--aw-es-error); }
.aw-es-card.status-unknown      { border-left-color: var(--aw-es-unknown); }

/* ── Card internals ────────────────────────────────────────────────────── */

.aw-es-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.aw-es-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 17px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #e2e8f0;
  background: hsl(var(--aw-es-logo-h, 220) 48% 24%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.aw-es-logo:has(.aw-es-logo-img) {
  background: #ffffff;
}

.aw-es-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
  display: block;
  background: #ffffff;
  padding: 5px;
}

.aw-es-logo-fallback {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.aw-es-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--aw-es-unknown);
  transition: background 0.2s;
}

.aw-es-card.status-operational .aw-es-status-dot { background: var(--aw-es-ok); }
.aw-es-card.status-degraded     .aw-es-status-dot { background: var(--aw-es-warn); }
.aw-es-card.status-outage       .aw-es-status-dot { background: var(--aw-es-error); }

.aw-es-service-name {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--aw-es-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aw-es-status-text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--aw-es-text-muted);
  margin-bottom: 0;
}

.aw-es-card.status-operational .aw-es-status-text { color: #4ade80; }
.aw-es-card.status-degraded     .aw-es-status-text { color: #f59e0b; }
.aw-es-card.status-outage       .aw-es-status-text { color: #f87171; }

/* Scrollable service list (toolbar + header stay put in fullscreen) */
.aw-es-body {
  min-width: 0;
}

/* ── Empty state ───────────────────────────────────────────────────────── */

.aw-es-empty {
  padding: 32px;
  text-align: center;
  color: var(--aw-es-text-muted);
  background: var(--aw-es-card-bg);
  border: 1px dashed var(--aw-es-border);
  border-radius: var(--aw-es-radius);
}

/* ── Live sync updating animation ─────────────────────────────────────── */

@keyframes aw-es-pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

.aw-es-card.aw-es-updating .aw-es-status-dot {
  animation: aw-es-pulse 1.2s ease-in-out infinite;
}

/* ── Responsive ────────────────────────────────────────────────────────── */

/* Tablet: tighter min-width so 3 columns fit on iPad */
@media (max-width: 900px) {
  .aw-es-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* Mobile: 2 columns side-by-side */
@media (max-width: 600px) {
  .aw-es-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .aw-es-title {
    font-size: 1.375rem;
  }

  /* Compact cards at 2-col */
  .aw-es-card {
    padding: 12px 12px;
  }

  /* Slightly smaller logo on mobile (still much bigger than original) */
  .aw-es-logo {
    width: 32px;
    height: 32px;
    font-size: 13px;
    border-radius: 8px;
  }

  .aw-es-logo-img {
    border-radius: 6px;
    padding: 4px;
  }

  .aw-es-card-top {
    gap: 8px;
    margin-bottom: 8px;
  }

  /* Ensure service name wraps instead of overflowing 2-col cards */
  .aw-es-service-name {
    font-size: 0.8125rem;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .aw-es-status-text {
    font-size: 0.75rem;
  }
}

/* ── Fullscreen: fill viewport (100dvh), flex column, scroll body only ─── */

.aw-es-outer.aw-es-is-fullscreen {
  width: 100%;
  max-width: 100%;
  margin: 0;
  box-sizing: border-box;
  background: var(--aw-es-bg);
  /* Fill visual viewport on mobile + desktop */
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding: max(4px, env(safe-area-inset-top, 0px)) clamp(4px, 2vw, 14px) max(2px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-toolbar {
  flex-shrink: 0;
  margin-bottom: 4px;
  gap: 6px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-header {
  flex-shrink: 0;
  margin-bottom: 4px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-title {
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  margin-bottom: 2px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-last-polled {
  font-size: clamp(0.62rem, 2vw, 0.72rem);
  margin: 0;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-stale-notice {
  margin-top: 4px;
  padding: 5px 8px;
  font-size: 0.65rem;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-category:last-child {
  margin-bottom: 0;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-category {
  margin-bottom: 6px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-cat-title {
  font-size: clamp(0.55rem, 1.8vw, 0.62rem);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-grid {
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 4px;
  align-content: start;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-card {
  padding: 5px 5px;
  border-radius: 7px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-card-top {
  gap: 3px;
  margin-bottom: 2px;
  align-items: flex-start;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-logo {
  width: 20px;
  height: 20px;
  font-size: 9px;
  border-radius: 5px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-logo-img {
  padding: 2px;
  border-radius: 4px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-status-dot {
  width: 5px;
  height: 5px;
  margin-top: 2px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-service-name {
  font-size: clamp(0.55rem, 2vw, 0.62rem);
  white-space: normal;
  line-height: 1.15;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-status-text {
  font-size: clamp(0.52rem, 1.8vw, 0.58rem);
  margin-bottom: 0;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-btn {
  padding: 5px 10px;
  font-size: 0.7rem;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-btn-fs {
  min-width: 34px;
  padding: 5px 8px;
}

@media (min-width: 600px) {
  .aw-es-outer.aw-es-is-fullscreen .aw-es-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
}

@media (min-width: 900px) {
  .aw-es-outer.aw-es-is-fullscreen .aw-es-grid {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  }
}

@media (min-width: 1400px) {
  .aw-es-outer.aw-es-is-fullscreen .aw-es-grid {
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  }
}

/* Landscape phones: slightly more columns, less vertical title noise */
@media (max-height: 500px) and (orientation: landscape) {
  .aw-es-outer.aw-es-is-fullscreen .aw-es-header {
    margin-bottom: 2px;
  }
  .aw-es-outer.aw-es-is-fullscreen .aw-es-title {
    font-size: 0.9rem;
  }
  .aw-es-outer.aw-es-is-fullscreen .aw-es-category {
    margin-bottom: 4px;
  }
}

/* ── Access denied (guests) ───────────────────────────────────────────── */

.aw-es-access-denied {
  max-width: 520px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--aw-es-card-bg);
  border: 1px solid var(--aw-es-border);
  border-radius: var(--aw-es-radius);
  color: var(--aw-es-text);
  font-family: inherit;
}

.aw-es-access-denied-link {
  color: #93c5fd;
}

/* ── Poll attribution ───────────────────────────────────────────────── */

.aw-es-poll-attribution,
.aw-es-poll-attribution-detail {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--aw-es-text-muted);
}

.aw-es-poll-attribution-detail {
  font-size: 0.8125rem;
}

/* ── Hosting card + admin-only provider link ─────────────────────────── */

.aw-es-hosting-card {
  cursor: pointer;
}

.aw-es-hosting-card:focus {
  outline: 2px solid rgba(147, 197, 253, 0.7);
  outline-offset: 2px;
}

.aw-es-card-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--aw-es-border);
}

.aw-es-admin-provider-link {
  font-size: 0.75rem;
  color: #93c5fd;
  text-decoration: none;
}

.aw-es-admin-provider-link:hover {
  text-decoration: underline;
}

.aw-es-subcat-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--aw-es-text-muted);
}

.aw-es-grid-client-sites {
  margin-bottom: 0.5rem;
}

/* Client website shortcut cards: name + green marker only (no status subtitle). */
.aw-es-card-client-site .aw-es-card-top {
  margin-bottom: 0;
}

/* ── Recent activity ─────────────────────────────────────────────────── */

.aw-es-activity {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--aw-es-border);
}

.aw-es-activity-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.aw-es-activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.aw-es-activity-item {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  font-size: 0.875rem;
  align-items: flex-start;
}

.aw-es-activity-leading {
  flex: 0 0 auto;
}

.aw-es-activity-logo {
  width: 28px;
  height: 28px;
  font-size: 11px;
  border-radius: 8px;
}

.aw-es-activity-logo .aw-es-logo-img {
  padding: 3px;
  border-radius: 6px;
}

/* Manual refresh rows: WordPress user avatar (Gravatar / local avatar). */
.aw-es-activity-logo.aw-es-activity-avatar {
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  overflow: hidden;
}

.aw-es-activity-logo.aw-es-activity-avatar:has(.aw-es-logo-img) {
  background: #1e293b;
}

.aw-es-activity-logo.aw-es-activity-avatar .aw-es-logo-img {
  padding: 0;
  border-radius: 50%;
  object-fit: cover;
}

.aw-es-activity-body {
  flex: 1 1 auto;
  min-width: 0;
}

.aw-es-activity-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.aw-es-activity-msg {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--aw-es-text);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.aw-es-activity-detail {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--aw-es-text-muted);
  line-height: 1.35;
  word-break: break-word;
}

.aw-es-activity-time {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: var(--aw-es-text-muted);
  white-space: nowrap;
  padding-top: 1px;
}

@media (max-width: 520px) {
  .aw-es-activity-item {
    gap: 8px;
  }

  .aw-es-activity-logo {
    width: 26px;
    height: 26px;
    font-size: 10px;
  }

  .aw-es-activity-topline {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .aw-es-activity-msg {
    padding-right: 0;
  }

  .aw-es-activity-time {
    align-self: flex-end;
  }
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity {
  margin-top: 8px;
  padding-top: 8px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity-title {
  font-size: clamp(0.65rem, 2vw, 0.75rem);
  margin-bottom: 4px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity-item {
  padding: 6px 0;
  font-size: clamp(0.62rem, 1.9vw, 0.72rem);
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity-logo {
  width: 20px;
  height: 20px;
  font-size: 8px;
  border-radius: 5px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity-logo .aw-es-logo-img {
  padding: 2px;
  border-radius: 4px;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity-logo.aw-es-activity-avatar .aw-es-logo-img {
  padding: 0;
  border-radius: 50%;
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity-time {
  font-size: clamp(0.55rem, 1.8vw, 0.65rem);
}

.aw-es-outer.aw-es-is-fullscreen .aw-es-activity-detail {
  font-size: clamp(0.55rem, 1.8vw, 0.65rem);
  margin-top: 3px;
}

.aw-es-activity-empty {
  padding: 12px 0;
  color: var(--aw-es-text-muted);
  font-size: 0.875rem;
}

/* ── Hosting modal ───────────────────────────────────────────────────── */

body.aw-es-modal-open {
  overflow: hidden;
}

.aw-es-modal[hidden] {
  display: none !important;
}

.aw-es-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.aw-es-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.aw-es-modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: var(--aw-es-card-bg);
  border: 1px solid var(--aw-es-border);
  border-radius: var(--aw-es-radius);
  padding: 12px 20px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.aw-es-modal-panel:fullscreen {
  width: 100%;
  max-width: none;
  max-height: none;
  border-radius: 0;
}

.aw-es-modal-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.aw-es-modal-fs,
.aw-es-modal-close {
  border: 0;
  background: transparent;
  color: var(--aw-es-text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.aw-es-modal-fs:hover,
.aw-es-modal-close:hover {
  color: var(--aw-es-text);
  background: rgba(148, 163, 184, 0.12);
}

.aw-es-modal-close {
  font-size: 1.5rem;
}

.aw-es-modal-title {
  margin: 0 0 12px;
  padding-right: 0;
  font-size: 1.1rem;
}

.aw-es-modal-body {
  font-size: 0.9rem;
  color: var(--aw-es-text);
  line-height: 1.45;
}

.aw-es-modal-desc {
  margin: 0 0 12px;
}

.aw-es-modal-excerpt-wrap {
  margin: 0 0 8px;
  max-height: 48vh;
  overflow: auto;
}

.aw-es-modal-line {
  margin: 0 0 10px;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--aw-es-text-muted);
  word-break: break-word;
}

.aw-es-modal-line:last-child {
  margin-bottom: 0;
}

.aw-es-modal-incidents {
  margin: 0;
  padding-left: 1.1rem;
}

.aw-es-modal-incidents li {
  margin-bottom: 10px;
}

.aw-es-modal-inc-sum {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--aw-es-text-muted);
}

.aw-es-modal-disclaimer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--aw-es-border);
  font-size: 0.82rem;
  color: var(--aw-es-text-muted);
}

.aw-es-modal-error,
.aw-es-modal-loading,
.aw-es-modal-ok {
  margin: 0 0 8px;
}
