/* HIRECRM Production SaaS Polish
   Final UI-only layer for production polish:
   - public/auth safeguards;
   - brand consistency;
   - mobile overflow protection;
   - cleaned visual hierarchy;
   - safer public surfaces.
*/

:root {
  --psp-bg: #f8fafc;
  --psp-surface: #ffffff;
  --psp-soft: #fbfcfe;
  --psp-border: #e7ecf3;
  --psp-border-soft: #edf2f7;
  --psp-text: #0f172a;
  --psp-muted: #64748b;
  --psp-accent: #2563eb;
  --psp-accent-hover: #1d4ed8;
  --psp-danger: #dc2626;
  --psp-radius: 12px;
  --psp-shadow-soft: 0 16px 45px rgba(15, 23, 42, .08);
}

/* Global mobile overflow guard. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--psp-bg);
}

/* Public pages must not expose internal CRM chrome. */
[data-public-page] .topbar,
[data-public-page] .sidebar,
[data-public-page] .global-search,
[data-public-page] .command-palette,
[data-public-page] .global-ai-widget,
[data-public-page] .worker-ai-chat,
[data-public-page] .mobile-bottom-nav,
[data-public-page] .scroll-top-fab,
[data-public-page] [data-global-search],
[data-public-page] [data-command-palette],
[data-public-page] [data-global-ai-widget],
[data-public-page] [data-pwa-install],
[data-public-page] [data-install-prompt],
[data-public-page] .pwa-install,
[data-public-page] .pwa-install-banner,
[data-public-page] .install-banner {
  display: none !important;
}

/* Remove leftover visual debug/demo strips if any are accidentally included. */
[data-public-page] [class*="demo"],
[data-public-page] [class*="debug"],
[data-public-page] [data-demo-cta],
[data-public-page] [data-system-diagnostics],
[data-public-page] .presentation-demo-ready-strip {
  display: none !important;
}

/* Auth/public layout hardening. */
.public-auth-shell,
.public-gateway-shell,
.public-landing-shell {
  min-width: 0;
  overflow-x: hidden;
}

.public-auth-card,
.public-gateway-card,
.public-landing-card {
  max-width: calc(100vw - 28px);
}

/* Auth form final focus/disabled polish. */
.public-auth-field input:disabled,
.public-auth-submit:disabled {
  opacity: .72;
}

.public-auth-field input[aria-invalid="true"],
.public-auth-field input.is-invalid {
  border-color: var(--psp-danger) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12) !important;
}

.public-auth-submit.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.38);
  border-top-color: #fff;
  border-radius: 999px;
  animation: psp-spin .7s linear infinite;
}

@keyframes psp-spin {
  to { transform: rotate(360deg); }
}

/* App title/brand consistency helpers. */
.sidebar__logo-text,
.sidebar__mobile-title,
.public-auth-brand__name,
[data-brand-name] {
  letter-spacing: -.035em;
  font-weight: 850;
}

/* Production SaaS card polish for authenticated pages. */
.page-shell .card,
.enterprise-page .card,
.workspace-shell .card,
.page-shell .panel-card,
.enterprise-page .panel-card,
.workspace-shell .panel-card,
.page-shell .section-card,
.enterprise-page .section-card,
.workspace-shell .section-card {
  border-color: var(--psp-border) !important;
}

/* Consistent muted text contrast. */
.page-shell .text-muted,
.enterprise-page .text-muted,
.workspace-shell .text-muted,
.page-shell .muted,
.enterprise-page .muted,
.workspace-shell .muted,
.page-shell small,
.enterprise-page small,
.workspace-shell small {
  color: var(--psp-muted) !important;
}

/* Prevent clipped text after compact UI layers. */
button,
.btn,
.button,
input,
select,
textarea,
.badge,
.status-badge,
.priority-pill {
  text-rendering: geometricPrecision;
}

button,
.btn,
.button {
  line-height: 1.25 !important;
}

/* Table/registry mobile safety. */
.table-card,
.table-container,
.table-responsive,
.platform-table-wrapper,
.registry-table-wrapper {
  max-width: 100%;
  overflow-x: auto;
}

/* Empty states must remain product-like, not debug-like. */
.empty-state,
.empty-card,
.no-data {
  color: var(--psp-muted);
}

/* Public errors should also use the brand tone. */
.error-page,
.public-error-page {
  background: var(--psp-bg);
  color: var(--psp-text);
}

.error-page .error-card,
.public-error-page .error-card {
  background: var(--psp-surface);
  border: 1px solid var(--psp-border);
  border-radius: 18px;
  box-shadow: var(--psp-shadow-soft);
}

/* Mobile rules. */
@media (max-width: 768px) {
  .public-auth-card {
    width: min(100%, 420px);
  }

  .public-auth-brand {
    align-items: flex-start;
  }

  .public-auth-heading h1 {
    font-size: 22px;
  }
}

@media (max-width: 390px) {
  .public-auth-card {
    max-width: calc(100vw - 24px);
  }

  .public-auth-demo {
    justify-content: flex-start;
  }

  .public-auth-field input,
  .public-auth-submit {
    min-height: 40px;
  }
}

@media (max-width: 360px) {
  .public-auth-shell {
    padding: 10px;
  }

  .public-auth-card {
    max-width: calc(100vw - 20px);
    padding: 16px;
  }

  .public-auth-brand__subtitle {
    display: none;
  }
}
