/* ── IT Helpdesk — Minimal overrides (MudBlazor handles everything) ── */

/* Keep body clean */
html,
body {
  margin: 0;
  padding: 0;
  font-family: "Roboto", sans-serif;
}

#app,
.mud-main-content,
.mud-container {
  color: var(--mud-palette-text-primary);
}

/* Fix Blazor error UI */
#blazor-error-ui {
  background: #c62828;
  color: white;
  padding: 0.75rem;
  text-align: center;
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 9999;
}

#blazor-error-ui .reload {
  color: #ffcdd2;
}

/* ── Markdown rendered content ── */
.markdown-content {
  line-height: 1.7;
  color: var(--mud-palette-text-primary);
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin: 1em 0 0.5em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--mud-palette-text-primary);
}

.markdown-content h1 {
  font-size: 1.6rem;
}

.markdown-content h2 {
  font-size: 1.3rem;
}

.markdown-content h3 {
  font-size: 1.1rem;
}

.markdown-content p {
  margin: 0 0 0.85em;
}

.markdown-content ul,
.markdown-content ol {
  margin: 0.5em 0 0.85em;
  padding-left: 1.8em;
}

.markdown-content li {
  margin-bottom: 0.3em;
}

.markdown-content code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.875em;
  background: var(--mud-palette-action-default-hover);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--mud-palette-text-primary);
}

.markdown-content pre {
  background: var(--mud-palette-action-default-hover);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.85em 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

.markdown-content blockquote {
  border-left: 4px solid var(--mud-palette-primary);
  background: var(--mud-palette-action-default-hover);
  margin: 0.85em 0;
  padding: 0.5em 1em;
  border-radius: 0 8px 8px 0;
  color: var(--mud-palette-text-secondary);
}

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.85em 0;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid var(--mud-palette-lines-default);
  padding: 0.5em 0.75em;
  text-align: left;
}

.markdown-content th {
  background: var(--mud-palette-action-default-hover);
  font-weight: 600;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--mud-palette-lines-default);
  margin: 1em 0;
}

.markdown-content a {
  color: var(--mud-palette-primary);
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

/* Markdown editor tab wrapper */
.markdown-editor-wrapper .mud-tabs-toolbar {
  border-bottom: 1px solid var(--mud-palette-lines-default);
}

.markdown-live-preview {
  background: var(--mud-palette-surface);
  border-color: var(--mud-palette-lines-default);
}

.rte-editor {
  min-height: 180px;
  border: 1px solid var(--mud-palette-lines-default);
  border-radius: 8px;
  background: var(--mud-palette-surface);
  color: var(--mud-palette-text-primary);
  padding: 12px;
  line-height: 1.55;
  outline: none;
  white-space: pre-wrap;
}

.rte-editor:focus {
  border-color: var(--mud-palette-primary);
  box-shadow: 0 0 0 1px var(--mud-palette-primary);
}

.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--mud-palette-text-secondary);
}

.rte-editor ul,
.rte-editor ol {
  margin: 0.45rem 0;
  padding-left: 1.45rem;
}

.rte-editor code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.9em;
  background: var(--mud-palette-action-default-hover);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.rte-editor pre {
  margin: 0.6rem 0;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--mud-palette-lines-default);
  background: var(--mud-palette-action-default-hover);
  overflow-x: auto;
}

.rte-editor pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

/* ── User Menu — AppBar Avatar Button ── */
.user-avatar-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #2e7d32, #1b5e20);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition:
    box-shadow 0.2s ease,
    transform 0.15s ease;
  user-select: none;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.user-avatar-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transform: scale(1.05);
}

/* ── User Menu — Dropdown Header Panel ── */
.user-menu-header {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
  padding: 16px 20px 14px;
  min-width: 260px;
  border-radius: 4px 4px 0 0;
}

.user-menu-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2e7d32, #66bb6a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.user-menu-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.user-menu-email {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 185px;
  margin-top: 1px;
}

.user-menu-role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 10px;
  letter-spacing: 0.6px;
  color: #fff;
  margin-top: 6px;
}

.role-admin {
  background: #c62828;
}

.role-technician {
  background: #bf360c;
}

.role-user {
  background: #1565c0;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* ── User Menu — Overlay wrapper so avatar sits on top of hidden MudMenu button ── */
.user-menu-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}

/* The avatar div overlays on top and receives pointer events but passes clicks through to the MudMenu button below */
.user-menu-wrapper .user-avatar-btn {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  /* let clicks fall through to the MudMenu button underneath */
  z-index: 10;
}

/* Make the MudMenu icon button invisible but still fully clickable */
.user-menu-hidden-trigger .mud-icon-button {
  opacity: 0 !important;
  width: 34px !important;
  height: 34px !important;
  padding: 0 !important;
}

.user-menu-hidden-trigger {
  width: 34px;
  height: 34px;
}

/* ── GlobalErrorBoundary — friendly full-screen error card ── */
.global-error-boundary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 32px 16px;
}

.error-boundary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 540px;
  width: 100%;
  text-align: center;
  padding: 40px 32px;
  border-radius: 16px;
  background: var(--mud-palette-surface);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--mud-palette-lines-default);
  animation: errorFadeIn 0.35s ease both;
}

@keyframes errorFadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.error-boundary-icon {
  margin-bottom: 8px;
  animation: errorShake 0.5s ease 0.1s both;
}

@keyframes errorShake {
  0%,
  100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(-6deg);
  }
  40% {
    transform: rotate(6deg);
  }
  60% {
    transform: rotate(-3deg);
  }
  80% {
    transform: rotate(3deg);
  }
}

/* ── CreateTicket Page ── */
.create-ticket-page {
  position: relative;
}

.create-ticket-hero {
  border: 1px solid rgba(33, 150, 243, 0.22);
  border-radius: 16px;
  background:
    radial-gradient(circle at 0% 0%, rgba(33, 150, 243, 0.1), transparent 45%),
    radial-gradient(
      circle at 100% 100%,
      rgba(0, 188, 212, 0.1),
      transparent 40%
    ),
    linear-gradient(135deg, rgba(2, 136, 209, 0.08), rgba(0, 77, 64, 0.08));
}

.create-ticket-hero-text {
  max-width: 72ch;
  color: var(--mud-palette-text-secondary);
}

.create-ticket-main-card {
  border: 1px solid var(--mud-palette-lines-default);
  background: linear-gradient(
    180deg,
    var(--mud-palette-surface),
    var(--mud-palette-background)
  );
}

.create-ticket-side-card {
  border: 1px solid var(--mud-palette-lines-default);
  background: linear-gradient(
    180deg,
    var(--mud-palette-surface),
    var(--mud-palette-background)
  );
}

.section-title {
  letter-spacing: 0.2px;
}

.quick-template-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tips-list {
  border-radius: 10px;
  background: rgba(var(--mud-palette-primary-rgb), 0.1);
  padding: 0.35rem 0.3rem;
}

/* ── Router states (authorizing / not found) ── */
.app-route-state-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.app-route-state-text {
  color: var(--mud-palette-text-secondary);
  font-family: "Roboto", sans-serif;
}

.app-not-found-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 16px;
  gap: 16px;
  text-align: center;
}

.app-not-found-icon {
  fill: var(--mud-palette-text-secondary);
}

.app-not-found-title {
  margin: 0;
  color: var(--mud-palette-text-primary);
  font-size: 1.5rem;
  font-weight: 700;
  font-family: "Roboto", sans-serif;
}

.app-not-found-description {
  margin: 0;
  color: var(--mud-palette-text-secondary);
  max-width: 400px;
  font-family: "Roboto", sans-serif;
}

.app-not-found-link {
  margin-top: 8px;
  padding: 10px 24px;
  background: var(--mud-palette-primary);
  color: var(--mud-palette-primary-text);
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  font-family: "Roboto", sans-serif;
}

@media (max-width: 960px) {
  .create-ticket-hero {
    padding: 1rem !important;
  }

  .create-ticket-main-card .mud-card-content {
    padding: 1rem !important;
  }
}
