/*
 * Base layer: reset, typography, and the primitives (buttons, inputs, chips,
 * menus) every screen reuses. Layout and feature styles live in layout.css.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-weight: 600;
  line-height: 1.3;
}

h1 {
  font-size: var(--text-2xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

p {
  margin: 0 0 var(--space-4);
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
}

/* Keyboard focus is always visible; pointer focus never draws a ring. */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
  border-radius: var(--radius-sm);
}

/*
 * Except on the page heading.
 *
 * FocusOnNavigate moves focus to the h1 after every navigation, so a screen
 * reader announces which page it landed on. That is worth keeping. But a reload
 * is a keyboard action, which puts the browser in keyboard modality, and the
 * heading then matches :focus-visible — which is why pressing F5 drew a box
 * around "Good afternoon, Admin" and around the title of every other page.
 *
 * A heading is not something you can act on, so the ring tells a sighted person
 * nothing; the announcement, which is the point, is unaffected.
 */
h1:focus,
h1:focus-visible {
  outline: none;
}

::selection {
  background: var(--accent-soft);
}

/* ---- scrollbars ------------------------------------------------------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
  background-clip: content-box;
}

/* ---- buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 30px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font-size: var(--text-base);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
}

.btn-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.94);
}

.btn-sm {
  height: 26px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius);
  color: var(--text-secondary);
}

.btn-icon:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* ---- inputs ----------------------------------------------------------- */

.input,
.textarea,
.select {
  width: 100%;
  padding: 5px var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--text-tertiary);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

.textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.55;
}

.select {
  appearance: none;
  padding-right: var(--space-7);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236d6e6f' d='M6 8.2 2.3 4.5l.9-.9L6 6.4l2.8-2.8.9.9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

/*
 * Fields that look like plain text until hovered. Used everywhere the user
 * edits in place: task titles, dates, assignees.
 */
.input-inline {
  width: 100%;
  padding: 4px var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.input-inline:hover {
  background: var(--surface-hover);
}

.input-inline:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.field {
  margin-bottom: var(--space-5);
}

.field-error {
  margin-top: var(--space-2);
  color: var(--danger);
  font-size: var(--text-sm);
}

/* ---- checkbox --------------------------------------------------------- */

.check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast),
    color var(--transition-fast);
}

.check:hover {
  border-color: var(--success);
  color: var(--success);
}

.check.is-checked {
  border-color: var(--success);
  background: var(--success);
  color: #ffffff;
}

.check svg {
  width: 11px;
  height: 11px;
}

/* ---- badges and chips ------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 20px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 20px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--neutral-soft);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
}

/* ---- avatars ---------------------------------------------------------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--avatar-0);
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs {
  width: 20px;
  height: 20px;
  font-size: 9px;
}

.avatar-lg {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar-xl {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.avatar-empty {
  border: 1.5px dashed var(--border-strong);
  background: transparent;
  color: var(--text-tertiary);
}

/* ---- dropdown / menu -------------------------------------------------- */

.menu {
  min-width: 200px;
  max-height: 340px;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  z-index: 400;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-base);
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item.is-active {
  background: var(--surface-hover);
}

.menu-item.is-selected {
  color: var(--accent-text);
  font-weight: 500;
}

.menu-item.is-danger {
  color: var(--danger);
}

.menu-separator {
  height: 1px;
  margin: var(--space-2) 0;
  background: var(--border);
}

.menu-header {
  padding: var(--space-2) var(--space-3);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.menu-search {
  margin-bottom: var(--space-2);
}

/* ---- dialog ----------------------------------------------------------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--overlay);
  z-index: 600;
}

.dialog {
  width: 100%;
  max-width: 460px;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.dialog-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.dialog-body {
  padding: var(--space-6);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--background-subtle);
}

/* ---- states ----------------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--text-tertiary);
}

.empty-state-title {
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 600;
}

.empty-state-text {
  max-width: 380px;
  font-size: var(--text-base);
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(
    90deg,
    var(--surface-sunken) 25%,
    var(--surface-hover) 37%,
    var(--surface-sunken) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.3s ease infinite;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ---- helpers ---------------------------------------------------------- */

.text-secondary {
  color: var(--text-secondary);
}

.text-tertiary {
  color: var(--text-tertiary);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.text-sm {
  font-size: var(--text-sm);
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---- Blazor framework UI ---------------------------------------------- */

#blazor-error-ui {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  display: none;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--danger);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  z-index: 900;
}

#blazor-error-ui .reload,
#blazor-error-ui .dismiss {
  color: #ffffff;
  cursor: pointer;
  text-decoration: underline;
}

.validation-message,
.validation-errors {
  color: var(--danger);
  font-size: var(--text-sm);
}

.invalid {
  border-color: var(--danger) !important;
}

/* The avatar in the profile dialog, big enough to judge a crop by. */
.profile-photo .avatar {
  width: 72px;
  height: 72px;
  font-size: 24px;
}
