/*
 * VARYS-MGMT-005: Critical shell styles for error UI + reconnect banner.
 * Lifted from inline <style> in App.razor so the file can be versioned via
 * VersionHandler and cached by the browser. These rules MUST be available
 * before the Blazor circuit starts so the error/reconnect UI can render
 * even when the framework has not fully booted.
 */

/* Desktop-shell visibility helpers. The `varyos-shell` class is set on <html>
 * by js/varyos-shell.js before first paint, so these toggle flash-free:
 *   .shell-hide  → hidden when running inside the Varyos desktop shell
 *   .shell-show  → hidden everywhere EXCEPT the desktop shell
 */
.shell-show { display: none !important; }
html.varyos-shell .shell-hide { display: none !important; }
html.varyos-shell .shell-show { display: inline-flex !important; }

/* Desktop-shell PDF printing. In the shell, ShellPdfPrintButton replaces the Blazorise
 * pdf.js toolbar print (which can only do a browser print) with a printer/tray/paper-aware
 * shell job. Hide the pdf.js print button so there is a single, correct print action. The
 * app registers FontAwesome as Blazorise's icon provider, so that button carries .fa-print;
 * scope to the viewer host (.shell-pdf-host on <PdfViewerContainer>) and to the shell only,
 * so the customer portal / plain browser keep their pdf.js print. */
html.varyos-shell .shell-pdf-host button:has(i.fa-print),
html.varyos-shell .shell-pdf-host a:has(i.fa-print) {
  display: none !important;
}

/* Compact right-aligned strip carrying the shell print action, above the pdf.js toolbar.
 * Only ever rendered inside the shell (ShellPdfPrintButton self-guards), so it needs no
 * .shell-show gating of its own. */
.shell-pdf-print-bar {
  display: flex;
  justify-content: flex-end;
  padding: 2px 6px 0;
}

#blazor-error-ui {
  display: none;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 99999 !important;
  background: rgba(0, 0, 0, 0.7) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
}
#blazor-error-ui[style*="display: block"],
#blazor-error-ui[style*="display:block"] {
  display: flex !important;
}
#blazor-error-ui .error-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}
#blazor-error-ui .error-dialog {
  background: white !important;
  border-radius: 12px;
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  position: relative;
  z-index: 100000;
}
#blazor-error-ui .error-dialog h2 {
  margin: 0 0 16px;
  color: #1a1a1a;
  font-size: 1.5rem;
}
#blazor-error-ui .error-dialog p {
  color: #666;
  margin-bottom: 24px;
  line-height: 1.6;
}
#blazor-error-ui .error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
#blazor-error-ui .error-ref {
  font-family: monospace;
  background: #f5f5f5;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  display: inline-block;
}
#blazor-error-ui .error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}
#blazor-error-ui .error-actions button {
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
#blazor-error-ui .btn-primary-error {
  background: #052767;
  color: white;
  border: none;
}
#blazor-error-ui .btn-primary-error:hover {
  background: #063a8c;
}
#blazor-error-ui .btn-secondary-error {
  background: white;
  color: #333;
  border: 1px solid #ddd;
}
#blazor-error-ui .btn-secondary-error:hover {
  background: #f5f5f5;
}
#blazor-error-ui .error-status {
  margin-top: 16px;
  font-size: 0.85rem;
  color: #28a745;
}

/* --- Connection-loss banner --- */
.my-reconnect-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99998;
  pointer-events: none;
}
.my-reconnect-modal.components-reconnect-show,
.my-reconnect-modal.components-reconnect-rejected,
.my-reconnect-modal.components-reconnect-failed {
  display: block;
}
.my-reconnect-modal.components-reconnect-hide {
  display: none;
}
.reconnect-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  pointer-events: auto;
  animation: slideDown 0.3s ease-out;
}
.reconnect-banner--reconnecting {
  background: #e8a317;
}
.reconnect-banner--failed {
  background: #dc3545;
}
.reconnect-banner--rejected {
  background: #dc3545;
}
.reconnect-banner .reconnect-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.reconnect-banner button {
  margin-left: auto;
  padding: 6px 16px;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  pointer-events: auto;
}
.reconnect-banner button:hover {
  background: rgba(255,255,255,0.35);
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
