/* Alert Enterprise App Hub — page + component styles.
   Builds on brand.css (shared with Quote Tool + Email Generator).
   Depends on: --ae-purple, --ae-orange, --ae-grey-light, --ae-shadow-*, etc. */

/* ── Loading spinner shown until /api/auth/verify resolves ─────────── */
#loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
  background: var(--ae-purple);
  letter-spacing: 0.02em;
}

/* ── Login page background — Alert Cafe deep indigo + warm glows + stripe ──
   Base: #1E0F32 (matches Alert Cafe/Group 24639.jpg exactly)
   Glows: three radial-gradients in the brand warm palette — orange top-left,
          purple bottom-right, pink top-right — creating a moody premium feel
          without shouting the gradient.
   Accent: a 6px bottom stripe carrying the full warm-to-violet brand gradient,
          with a soft upward glow. Quotes Alert Cafe Header exactly. */
.login-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 70% at 15% 20%, rgba(255, 82, 51, 0.35) 0%, transparent 55%),
    radial-gradient(ellipse 70% 60% at 85% 90%, rgba(123, 42, 201, 0.5) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 15%, rgba(255, 107, 173, 0.25) 0%, transparent 55%),
    #1E0F32;
}

/* Shield watermark — centered, slow drift, white-tinted for dark background */
.login-page::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(85vh, 900px);
  aspect-ratio: 1503 / 1601;
  background-image: url('/img/ae-shield.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.06;
  transform: translate(-50%, -50%);
  animation: ae-shield-drift 40s ease-in-out infinite;
  pointer-events: none;
  filter: brightness(0) invert(1);
}

/* Bottom gradient stripe accent — the full AE warm-to-violet brand gradient */
.login-page::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background-image: linear-gradient(90deg, #FF7C3F 0%, #FF3D54 30%, #C12E9E 65%, #5F2AA3 100%);
  box-shadow: 0 0 64px 8px rgba(255, 82, 51, 0.35);
  pointer-events: none;
}

@keyframes ae-shield-drift {
  0%   { transform: translate(-50%, -50%) rotate(-3deg) scale(1); }
  50%  { transform: translate(-50%, -52%) rotate(3deg) scale(1.03); }
  100% { transform: translate(-50%, -50%) rotate(-3deg) scale(1); }
}

/* ── Login card ────────────────────────────────────────────────────── */
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 52px 44px 40px;
  background: var(--ae-white);
  border-radius: var(--ae-radius-lg);
  box-shadow: 0 32px 80px -20px rgba(38, 38, 38, 0.35), 0 2px 8px rgba(38, 38, 38, 0.1);
  text-align: center;
}
.login-wordmark {
  height: 40px;
  margin-bottom: 14px;
  filter: invert(1) brightness(0.15);
}
.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--ae-purple);
  background: var(--ae-purple-20);
  border-radius: 100px;
  margin-bottom: 24px;
}
.login-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ae-purple);
}
.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--ae-text);
}
.login-subtitle {
  font-size: 0.875rem;
  color: var(--ae-text-secondary);
  margin-bottom: 32px;
  line-height: 1.5;
}
.btn-google {
  width: 100%;
  padding: 13px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  background: var(--ae-purple);
  color: var(--ae-white);
  border: none;
  border-radius: var(--ae-radius-sm);
  cursor: pointer;
  transition: all var(--ae-transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
}
.btn-google:hover { background: #4F43B5; text-decoration: none; }
.btn-google svg { width: 20px; height: 20px; }
.login-footer {
  margin-top: 28px;
  font-size: 0.75rem;
  color: var(--ae-text-muted);
  line-height: 1.6;
}
.login-error {
  margin-bottom: 16px;
  padding: 10px 16px;
  background: #FEE2E2;
  color: var(--ae-error);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--ae-radius-sm);
  display: none;
  text-align: center;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s ease; }

/* ── Dashboard chrome (shared pattern across AE tools) ─────────────── */
.dash { min-height: 100vh; background: var(--ae-grey-light); }
.dash-header {
  background: var(--ae-white);
  border-bottom: 1px solid var(--ae-grey-border);
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.dash-logo { display: flex; align-items: center; gap: 10px; }
.dash-logo img { height: 20px; filter: invert(1) brightness(0.15); }
.dash-logo-divider { width: 1px; height: 20px; background: var(--ae-grey-border); }
.dash-logo-sub { font-size: 0.75rem; font-weight: 600; color: var(--ae-text-muted); letter-spacing: 0.02em; text-transform: uppercase; }
.dash-user { display: flex; align-items: center; gap: 10px; font-size: 0.8125rem; }
.dash-user img { width: 32px; height: 32px; border-radius: 50%; background: var(--ae-grey-light); }
.dash-user a { margin-left: 12px; font-size: 0.75rem; color: var(--ae-text-muted); }
.dash-user a:hover { color: var(--ae-purple); text-decoration: underline; }

.dash-body { max-width: 1200px; margin: 0 auto; padding: 48px 40px 80px; }

/* ── Dashboard welcome + section header ────────────────────────────── */
.welcome { margin-bottom: 8px; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
.welcome-sub { margin-bottom: 36px; color: var(--ae-text-secondary); font-size: 0.9375rem; }

.tools-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
}
.tools-header h2 { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ae-text-muted); }
.manage-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ae-text-secondary);
  background: var(--ae-white);
  border: 1px solid var(--ae-grey-border);
  border-radius: var(--ae-radius-sm);
  cursor: pointer;
  transition: all var(--ae-transition);
  font-family: inherit;
}
.manage-btn:hover { border-color: var(--ae-purple); color: var(--ae-purple); }
.manage-btn svg { width: 14px; height: 14px; }

/* ── Tool card grid ────────────────────────────────────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}
.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 28px 28px 24px;
  background: var(--ae-white);
  border: 1px solid var(--ae-grey-border);
  border-radius: var(--ae-radius-md);
  box-shadow: var(--ae-shadow-sm);
  text-decoration: none;
  color: var(--ae-text);
  transition: all 180ms ease;
  overflow: hidden;
}
.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--tool-accent, var(--ae-purple));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 220ms ease;
}
.tool-card:hover {
  border-color: transparent;
  box-shadow: 0 12px 32px -12px rgba(38, 38, 38, 0.18), 0 2px 6px rgba(38, 38, 38, 0.06);
  transform: translateY(-2px);
  text-decoration: none;
}
.tool-card:hover::before { transform: scaleX(1); }

.tool-icon {
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  padding: 10px;
  background: var(--tool-accent-bg, var(--ae-purple-20));
  border-radius: var(--ae-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tool-icon img { width: 100%; height: 100%; object-fit: contain; }
.tool-icon .emoji { font-size: 1.75rem; line-height: 1; }

.tool-name {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  color: var(--ae-text);
}
.tool-desc {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--ae-text-secondary);
  flex: 1;
  margin-bottom: 18px;
}
.tool-url {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ae-text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tool-url svg {
  width: 10px;
  height: 10px;
  transition: transform 180ms ease;
}
.tool-card:hover .tool-url { color: var(--tool-accent, var(--ae-purple)); }
.tool-card:hover .tool-url svg { transform: translate(2px, -2px); }

/* Empty state when registry has been cleared */
.tool-empty {
  grid-column: 1 / -1;
  padding: 56px 40px;
  text-align: center;
  background: var(--ae-white);
  border: 1px dashed var(--ae-grey-border);
  border-radius: var(--ae-radius-md);
}
.tool-empty h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.tool-empty p { font-size: 0.875rem; color: var(--ae-text-secondary); margin-bottom: 20px; }

/* ── Manage-tools modal (localStorage editor) ──────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 38, 38, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--ae-white);
  border-radius: var(--ae-radius-lg);
  box-shadow: 0 32px 80px -20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.modal-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--ae-grey-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 700; }
.modal-header p { font-size: 0.8125rem; color: var(--ae-text-secondary); margin-top: 4px; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--ae-text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--ae-text); }
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}
.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--ae-grey-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--ae-grey-light);
}
.modal-footer-left { display: flex; gap: 8px; }
.modal-footer-right { display: flex; gap: 8px; }

/* Inline editor row for each tool in the manage-tools modal */
.tool-editor {
  padding: 16px;
  margin-bottom: 12px;
  background: var(--ae-grey-light);
  border: 1px solid var(--ae-grey-border);
  border-radius: var(--ae-radius-sm);
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: start;
}
.tool-editor[draggable="true"] { cursor: grab; }
.tool-editor.dragging { opacity: 0.4; }
.tool-editor-drag {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  color: var(--ae-text-muted);
  font-size: 1.25rem;
  cursor: grab;
  user-select: none;
}
.tool-editor-fields { display: flex; flex-direction: column; gap: 8px; }
.tool-editor-row { display: flex; gap: 8px; }
.tool-editor-row .input { flex: 1; font-size: 0.8125rem; padding: 8px 12px; }
.tool-editor-row .input.tool-editor-color { flex: 0 0 56px; padding: 4px; }
.tool-editor-remove {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ae-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--ae-radius-sm);
  font-family: inherit;
  font-weight: 600;
  height: 28px;
}
.tool-editor-remove:hover { color: var(--ae-error); border-color: #fecaca; background: #fef2f2; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .dash-header { padding: 16px 20px; }
  .dash-body { padding: 32px 20px 60px; }
  .welcome { font-size: 1.5rem; }
  .tool-grid { grid-template-columns: 1fr; }
  .login-card { padding: 40px 28px 32px; }
  .modal { max-height: 92vh; }
  .tool-editor { grid-template-columns: 1fr; }
  .tool-editor-drag { justify-content: flex-start; }
}
