*,
::backdrop,
::file-selector-button,
:after,
:before {
  border: 0 solid;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font: inherit;
}

:root {
  --color-primary: #000;
  --color-on-primary: #fff;
  --color-secondary: #eee;
  --color-muted: #666;
  --color-border: #ccc;
  --color-danger: #dc2626;
  --color-success-bg: #dcfce7;
  --color-success-text: #166534;
  --color-warning-bg: #fef9c3;
  --color-warning-text: #854d0e;
  --color-error-bg: #fee2e2;
  --color-error-text: #991b1b;
  --radius: 0.75rem;
  --radius-lg: 1rem;
}

html {
  font-family: sans-serif;
  line-height: 1.5;
  accent-color: var(--color-primary);
}

body {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1rem;
}

/* Fluid variant — full width, no centered max-width cap */
body.fluid {
  max-width: none;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
.h1 {
  font-size: 2.25rem;
  font-weight: bold;
  line-height: 1.1;
  text-wrap: balance;
}
h2,
.h2 {
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1.2;
  text-wrap: balance;
}
h3,
.h3 {
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1.3;
}
h4,
.h4 {
  font-size: 1rem;
  font-weight: bold;
}

main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.article {
  display: flex;
  flex-direction: column;
  gap: 1rem;

  & ul,
  & ol {
    padding-left: 1.5rem;
  }
}

/* Header & Footer */

.header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.site-name {
  font-size: 1.5rem;
  font-weight: 900;
  width: fit-content;
}

.footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  & .input,
  & .input-filled,
  & .input-white {
    flex: 1;
  }
}

/* Inputs */

.input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;

  &:focus-visible {
    border-color: var(--color-primary);
    outline: none;
  }
}

.input-filled {
  background: var(--color-secondary);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;

  &:focus-visible {
    outline: none;
  }
}

.input-white {
  background: white;
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;

  &:focus-visible {
    outline: none;
  }
}

.textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  resize: vertical;

  &:focus-visible {
    border-color: var(--color-primary);
    outline: none;
  }
}

.select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: white
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 0.75rem center;
  appearance: none;

  &:focus-visible {
    border-color: var(--color-primary);
    outline: none;
  }
}

.color-input {
  width: 3rem;
  height: 2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.25rem;
  cursor: pointer;
}

.range {
  cursor: pointer;
}

.file-input {
  cursor: pointer;

  &::file-selector-button {
    background: var(--color-secondary);
    color: var(--color-primary);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    line-height: 1.5;
    margin-right: 0.75rem;
  }
}

/* Forms */

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend {
  font-weight: bold;
  padding: 0 0.5rem;
}

.radio-label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* Buttons */

.primary-button,
.secondary-button,
.outline-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  line-height: 1.5;
  text-decoration: none;

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.primary-button {
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.secondary-button {
  background: var(--color-secondary);
  color: var(--color-primary);
}
.outline-button {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}
.ghost-button {
  background: transparent;
  color: var(--color-primary);
}
.danger-button {
  background: var(--color-danger);
  color: var(--color-on-primary);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;

  & svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  &.primary {
    background: var(--color-primary);
    color: var(--color-on-primary);
  }
  &.secondary {
    background: var(--color-secondary);
    color: var(--color-primary);
  }
  &.outline {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-border);
  }
  &.ghost {
    background: transparent;
    color: var(--color-primary);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.plain-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;

  & svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.button-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Navigation */

.nav {
  display: flex;
  column-gap: 1rem;
  row-gap: 0.5rem;
  flex-wrap: wrap;

  & a {
    color: var(--color-primary);
  }

  &.bold a {
    font-weight: bold;
  }
}

.nav-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  & a {
    color: var(--color-primary);
  }
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.tab {
  white-space: nowrap;
  padding: 0.5rem 1rem;
  color: var(--color-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;

  &.active {
    color: var(--color-primary);
    font-weight: bold;
    border-bottom-color: var(--color-primary);
  }
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;

  & a {
    color: var(--color-muted);
  }
}

.breadcrumb-separator {
  color: var(--color-border);
}

.chip-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip {
  color: var(--color-muted);
}

/* Cards */

.card {
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--color-secondary);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  &.center {
    justify-content: center;
  }
  &.end {
    align-self: flex-end;
  }
}

.pagination-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-primary);
  cursor: pointer;

  &.active {
    background: var(--color-primary);
    color: white;
  }
}

.pagination-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  color: var(--color-muted);
}

.pagination-info {
  padding-inline: 0.25rem;
}

/* Disclosure */

.disclosure {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;

  & summary {
    cursor: pointer;
    font-weight: bold;
    list-style: none;

    &::marker,
    &::-webkit-details-marker {
      display: none;
    }
  }

  &[open] summary {
    margin-bottom: 1rem;
  }
}

/* Alerts */

.alert {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;

  &.info {
    background: var(--color-secondary);
    color: var(--color-primary);
  }
  &.success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
  }
  &.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
  }
  &.error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
  }
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: bold;

  &.primary {
    background: var(--color-primary);
    color: var(--color-on-primary);
  }
  &.secondary {
    background: var(--color-secondary);
    color: var(--color-primary);
  }
  &.success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
  }
  &.warning {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
  }
  &.danger {
    background: var(--color-error-bg);
    color: var(--color-error-text);
  }
}

/* Tables */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;

  & th,
  & td {
    border-bottom: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    padding: 0.5rem;
    text-align: left;
  }

  & th:last-child,
  & td:last-child {
    border-right: none;
  }

  & tbody tr:last-child td {
    border-bottom: none;
  }

  & th {
    font-weight: bold;
  }

  & .text-right {
    text-align: right;
  }
  & .text-center {
    text-align: center;
  }
}

/* Divider */

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
}

/* Lists */

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 1.5rem;
}

.list-none {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

/* Blockquote */

.blockquote {
  border-left: 3px solid var(--color-primary);
  padding: 0.5rem 1rem;
  color: var(--color-muted);
}

/* Code */

.code {
  font-family: monospace;
  font-size: 0.875rem;
  background: var(--color-secondary);
  border-radius: 0.25rem;
  padding: 0.125rem 0.375rem;
}

.code-block {
  font-family: monospace;
  font-size: 0.875rem;
  background: var(--color-secondary);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  white-space: pre;
}

/* Empty State */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

/* Avatar */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1rem;

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

  &.avatar-xs {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.625rem;
  }
  &.avatar-sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
  }
  &.avatar-lg {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
  }
  &.avatar-xl {
    width: 5rem;
    height: 5rem;
    font-size: 1.75rem;
  }
}

.avatar-placeholder {
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: bold;
}

/* Modal */

.modal {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 28rem;
  width: calc(100% - 2rem);

  &[open] {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: auto;
  }

  &::backdrop {
    background: rgba(0, 0, 0, 0.5);
  }

  & .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  & .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
  }
}

/* Hero */

.hero {
  background: var(--color-primary);
  color: white;
  padding: 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
}

/* Utilities */

.text-muted {
  color: var(--color-muted);
}
.text-small {
  font-size: 0.875rem;
}

/* Row: space-between flex — nav bars, card headers, section title + action */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Centered narrow containers — auth forms, single-column content */
.container-sm {
  max-width: 24rem;
  width: 100%;
  margin: 0 auto;
}

.container-md {
  max-width: 32rem;
  width: 100%;
  margin: 0 auto;
}

/* Two-column form grid — admin panels, settings forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;

  & .full {
    grid-column: 1 / -1;
  }
}
