/* Mulan component recipes — derived from
   projects/mulanai/knowledge/tech/frontend/design-system/components/*.md
   Each class corresponds to a documented component variant. Adding a class
   here = adding (or extending) a variant in the design system. */

/* =========================================================
   Button — components/button.md
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition:
    background var(--dur-press) var(--ease-out),
    box-shadow var(--dur-press) var(--ease-out),
    border-color var(--dur-press) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus), var(--shadow-md); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { cursor: not-allowed; pointer-events: none; }

/* Sizes — button.md "Size → dimensions" */
.btn--lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn--md { height: 31px; padding: 0 12px; font-size: 14px; }
.btn--sm { height: 28px; padding: 0 8px;  font-size: 12px; }

/* Styles */
.btn--primary {
  background: var(--mulan-accent-purple);
  color: #fff;
  box-shadow: var(--shadow-md);
  background-image: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0));
}
.btn--primary:hover:not(:disabled) {
  background-color: oklch(0.55 0.24 280 / 0.92);
  box-shadow: var(--shadow-lg);
}
.btn--primary:disabled {
  background: oklch(0.55 0.24 280 / 0.4);
  color: rgba(255,255,255,0.85);
  box-shadow: none;
}

.btn--secondary {
  background: var(--mulan-bg-primary);
  color: var(--mulan-text-secondary);
  border-color: var(--mulan-border-subtle);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--mulan-bg-tertiary);
  box-shadow: var(--shadow-md);
}
.btn--secondary:disabled {
  background: var(--mulan-bg-tertiary);
  color: var(--mulan-text-disabled);
  box-shadow: none;
}

.btn--third {
  background: var(--mulan-bg-tertiary);
  color: var(--mulan-text-secondary);
}
.btn--third:hover:not(:disabled) { background: var(--mulan-bg-hover); }
.btn--third:disabled { color: var(--mulan-text-disabled); }

.btn--ghost {
  background: transparent;
  color: var(--mulan-text-secondary);
}
.btn--ghost:hover:not(:disabled) { background: var(--mulan-bg-tertiary); }
.btn--ghost:disabled { color: var(--mulan-text-disabled); }

.btn--danger {
  background: var(--mulan-status-error);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.btn--danger:hover:not(:disabled) {
  background-color: oklch(0.6 0.2 25 / 0.92);
  box-shadow: var(--shadow-lg);
}

/* =========================================================
   Input / Selector — components/input.md
   ========================================================= */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 12px;
  color: var(--mulan-text-tertiary);
  font-weight: 500;
}
.field__label-required::after {
  content: " *";
  color: var(--mulan-status-error);
}
.field__error {
  font-size: 12px;
  color: var(--mulan-status-error);
  min-height: 14px;
}

.input, .select {
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--mulan-border-subtle);
  border-radius: var(--radius);
  background: var(--mulan-bg-primary);
  font-family: inherit;
  font-size: 14px;
  color: var(--mulan-text-secondary);
  transition:
    border-color var(--dur-press) var(--ease-out),
    box-shadow var(--dur-press) var(--ease-out),
    background var(--dur-press) var(--ease-out);
}
.input::placeholder { color: var(--mulan-text-muted); }
.input:focus-visible, .select:focus-visible {
  outline: none;
  border-color: var(--mulan-accent-purple);
  box-shadow: var(--shadow-focus);
  color: var(--mulan-text-primary);
}
.input:disabled, .select:disabled {
  background: var(--mulan-bg-tertiary);
  color: var(--mulan-text-disabled);
  cursor: not-allowed;
}
.input[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--mulan-status-error);
  background: var(--mulan-status-error-bg);
}
.input[aria-invalid="true"]:focus-visible,
.select[aria-invalid="true"]:focus-visible {
  box-shadow: var(--shadow-focus-err);
}
.select { appearance: none; background-image:
  url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235B6067' stroke-width='1.5'%3E%3Cpolyline points='4 6 8 10 12 6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* =========================================================
   Card — components/card.md (default Mulan p-4)
   ========================================================= */
.card {
  background: var(--mulan-bg-primary);
  border: 1px solid var(--mulan-border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card--flat { box-shadow: none; }
.card--elevated { box-shadow: var(--shadow-md); }

/* =========================================================
   Dialog — components/dialog.md
   max-w-md (448px), p-6, rounded-2xl, shadow-xl
   ========================================================= */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
  animation: dialog-backdrop-in 200ms var(--ease-out);
}
.dialog {
  position: fixed;
  inset: 0;
  z-index: 51;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
}
.dialog__panel {
  position: relative;
  width: 100%;
  max-width: 448px;
  background: var(--mulan-bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 16px rgba(19, 20, 20, 0.25), var(--shadow-xl);
  pointer-events: auto;
  animation: dialog-in 200ms var(--ease-out);
}
.dialog--lg .dialog__panel { max-width: 512px; }
.dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.dialog__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--mulan-text-primary);
}
.dialog__close {
  border: 0; background: transparent; cursor: pointer;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  color: var(--mulan-text-muted); font-size: 20px; line-height: 1;
  transition: background var(--dur-press), color var(--dur-press);
}
.dialog__close:hover { background: var(--mulan-bg-tertiary); color: var(--mulan-text-secondary); }
.dialog__body { padding: 16px 24px; }
.dialog__footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--mulan-border-default);
  margin-top: 8px;
}
@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.96) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes dialog-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* =========================================================
   Tag / Badge — components/tag.md
   ========================================================= */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}
.tag--success {
  background: var(--mulan-status-success-bg);
  color: var(--mulan-status-success);
}
.tag--neutral {
  background: var(--mulan-bg-tertiary);
  color: var(--mulan-text-tertiary);
}
.tag--info {
  background: oklch(0.95 0.04 255);
  color: var(--mulan-accent-blue);
}
.tag--warning {
  background: oklch(0.96 0.07 80);
  color: var(--mulan-status-warning);
}
.tag--error {
  background: var(--mulan-status-error-bg);
  color: var(--mulan-status-error);
}

/* =========================================================
   Sidebar nav — patterns/composition.md (admin shell)
   ========================================================= */
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--mulan-text-tertiary);
  text-decoration: none;
  transition: background var(--dur-press), color var(--dur-press);
}
.nav-link:hover { background: var(--mulan-bg-hover); color: var(--mulan-text-primary); }
.nav-link--active {
  background: color-mix(in oklch, var(--mulan-accent-purple) 12%, transparent);
  color: var(--mulan-accent-purple);
  font-weight: 500;
}

/* =========================================================
   Table — derived from patterns/alignment-and-layout.md +
   foundations/spacing.md (12px row padding)
   ========================================================= */
.tbl { width: 100%; font-size: 14px; border-collapse: collapse; }
.tbl thead th {
  text-align: left;
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--mulan-text-tertiary);
  background: var(--mulan-bg-secondary);
  border-bottom: 1px solid var(--mulan-border-default);
  text-transform: none;
  letter-spacing: 0;
}
.tbl tbody td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--mulan-border-default);
  color: var(--mulan-text-secondary);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--mulan-bg-secondary); }

/* =========================================================
   Link — foundations/colors.md (purple link, hover opacity)
   ========================================================= */
.link {
  color: var(--mulan-accent-purple);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 150ms;
}
.link:hover { opacity: 0.8; }
