/**
 * Orblio Pulse Auth Redirect Pages
 * Shared styles: Orb Midnight, Pulse Blue, premium type scale.
 * Deep link scheme (app.orblio.pulse) kept in code only; not visible in UI.
 */

:root {
  /* Orblio visual identity */
  --orb-midnight: #0B1220;
  --orb-midnight-soft: #0f1729;
  --card-surface: #111827;
  --card-surface-elevated: #151d2e;
  --border: #1F2937;
  --text-primary: #E5E7EB;
  --text-secondary: #9CA3AF;
  --pulse-blue: #2563EB;
  --pulse-blue-hover: #3b82f6;
  --pulse-blue-subtle: rgba(37, 99, 235, 0.15);
  --executive-teal: #14B8A6;
  --executive-teal-subtle: rgba(20, 184, 166, 0.15);
  --error-red: #DC2626;
  --error-red-subtle: rgba(220, 38, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 1rem;
  background: var(--orb-midnight);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle radial gradient (orb-like glow) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(
    ellipse 80% 60% at 50% -20%,
    rgba(37, 99, 235, 0.08) 0%,
    transparent 50%
  );
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2.5rem 2rem;
  max-width: 420px;
}

/* App icon watermark (subtle, bottom-right) */
.container::after {
  content: '';
  position: absolute;
  right: -1rem;
  bottom: -1rem;
  width: 140px;
  height: 140px;
  background: radial-gradient(
    circle,
    rgba(37, 99, 235, 0.06) 0%,
    transparent 70%
  );
  border-radius: 50%;
  pointer-events: none;
}

/* Premium type scale */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.35;
}

p {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}

a {
  color: var(--pulse-blue);
  text-decoration: none;
  -webkit-tap-highlight-color: var(--pulse-blue-subtle);
}

a:hover {
  color: var(--pulse-blue-hover);
  text-decoration: underline;
}

/* Spinner */
.spinner {
  border: 3px solid rgba(37, 99, 235, 0.2);
  border-top: 3px solid var(--pulse-blue);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 1.25rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Primary button */
.btn {
  display: inline-block;
  padding: 14px 28px;
  background: var(--pulse-blue);
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: var(--pulse-blue-subtle);
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--pulse-blue-hover);
}

.btn:active {
  transform: scale(0.98);
}

/* Manual/tap link (before CTA) */
.manual-link {
  color: var(--pulse-blue);
  text-decoration: underline;
  cursor: pointer;
}

.manual-link:hover {
  color: var(--pulse-blue-hover);
}

/* Secondary button (outline style) */
.btn-secondary {
  display: inline-block;
  padding: 8px 16px;
  background: var(--card-surface);
  color: var(--pulse-blue);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--pulse-blue);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: var(--pulse-blue-subtle);
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover {
  background: var(--pulse-blue-subtle);
}

/* Debug section (hidden unless ?debug=1) */
.debug {
  margin-top: 2rem;
  padding: 1rem 1.25rem;
  background: var(--pulse-blue-subtle);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: left;
}

.debug strong {
  color: var(--pulse-blue);
}

.debug code {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
}

.debug.hidden {
  display: none !important;
}

/* Diagnostic panel (when open fails) */
.diagnostic-panel {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: left;
}

.diagnostic-panel strong {
  color: var(--pulse-blue);
}

.diagnostic-panel code {
  word-break: break-all;
  font-family: ui-monospace, 'SF Mono', Monaco, monospace;
}

.diagnostic-panel.hidden {
  display: none !important;
}

/* Muted link (Download from App Store) */
.muted-link {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 1.5rem;
}

.muted-link a {
  color: var(--pulse-blue);
  text-decoration: underline;
}

/* Executive card (Xero callback) */
body.xero-callback {
  padding-bottom: 3rem;
}

body.xero-callback::before {
  background: radial-gradient(
    ellipse 80% 60% at 50% -20%,
    rgba(37, 99, 235, 0.1) 0%,
    rgba(20, 184, 166, 0.05) 40%,
    transparent 70%
  );
}

.xero-card {
  background: var(--card-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(37, 99, 235, 0.05),
              0 0 40px rgba(20, 184, 166, 0.03);
  padding: 2.5rem 2rem;
  max-width: 420px;
}

.orb-icon {
  margin-bottom: 1.25rem;
}

.orb-icon svg {
  display: block;
  margin: 0 auto;
}

.page-hint {
  font-size: 0.8125rem;
  margin-top: 0.5rem;
}

.deep-link-display {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.deep-link-display code {
  font-size: 0.75rem;
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace;
  color: var(--text-secondary);
  word-break: break-all;
}

.page-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0.85;
}

/* Error state (on-brand red) */
body.has-error .xero-card {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3),
              0 0 0 1px rgba(220, 38, 38, 0.15);
}

.error-state {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--error-red-subtle);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 10px;
}

.error-message {
  color: #FCA5A5;
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
}

.btn-error-outline {
  border-color: rgba(220, 38, 38, 0.5);
  color: #FCA5A5;
}

.btn-error-outline:hover {
  background: var(--error-red-subtle);
}

/* Utility */
.hidden {
  display: none !important;
}

/* Debug panel enhancements */
.debug-row {
  margin-top: 0.5rem;
}

.debug-label {
  display: block;
  color: var(--pulse-blue);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.debug pre {
  margin: 0.25rem 0 0;
  font-size: 0.7rem;
  white-space: pre-wrap;
  word-break: break-all;
}
