/* F03 — UI primitives */

.ui-toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.ui-toast {
  pointer-events: auto;
  padding: 12px 14px;
  border-radius: var(--radius, 12px);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2, var(--shadow));
  font-size: 13.5px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 180ms var(--ease, ease), transform 180ms var(--ease, ease);
}

.ui-toast-in { opacity: 1; transform: translateY(0); }
.ui-toast-out { opacity: 0; transform: translateY(6px); }

.ui-toast-ok {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
  background: color-mix(in srgb, var(--ok) 10%, var(--surface));
}
.ui-toast-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}
.ui-toast-warn {
  border-color: color-mix(in srgb, var(--warn) 35%, var(--line));
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
}
.ui-toast-info {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.ui-modal.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.ui-modal-panel.modal-panel {
  width: min(480px, 94%);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  border-radius: var(--radius-l, 16px);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2, var(--shadow));
  animation: modal-in 180ms var(--ease, ease);
}

.ui-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ui-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ui-modal-title:empty { display: none; }

.ui-modal-x {
  flex: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.ui-modal-x:hover { background: var(--surface-2); color: var(--ink); }

.ui-modal-body { font-size: 14px; line-height: 1.45; }
.ui-modal-body > .ui-confirm-text { margin: 0; color: var(--ink); }

.ui-modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.ui-prompt-field label,
.ui-field-label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.ui-prompt-field input,
.ui-field-control input,
.ui-field-control select,
.ui-field-control textarea {
  width: 100%;
}

.ui-field { margin-bottom: 12px; }

.ui-field-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 12.5px;
}

.ui-tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.ui-tab {
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}

.ui-tab:hover { color: var(--ink); background: var(--surface-2); }
.ui-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: transparent;
}

.ui-tab-panel { min-width: 0; }

.ui-datatable {
  border: 1px solid var(--line);
  border-radius: var(--radius-l, 16px);
  background: var(--surface);
  overflow: hidden;
}

.ui-datatable-scroll {
  overflow: auto;
  max-width: 100%;
}

.ui-datatable table { margin: 0; }
.ui-dt-check { width: 40px; text-align: center; }
.ui-dt-sortable { cursor: pointer; }
.ui-dt-sortable:hover { color: var(--ink); }

.ui-datatable-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.ui-datatable-pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ui-datatable-pager button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
}

.contact-picker {
  position: relative;
  flex: 1;
  min-width: 0;
}

.contact-picker > input {
  width: 100%;
}

.contact-picker-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.contact-picker-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.contact-picker-item:last-child { border-bottom: 0; }
.contact-picker-item:hover { background: var(--surface-2, #f8f3ea); }
.contact-picker-item .title { font-weight: 600; font-size: 13px; }
.contact-picker-item .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.ui-skeleton-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0;
}

.ui-skeleton {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    color-mix(in srgb, var(--surface-2) 40%, var(--surface)) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: ui-skeleton-shine 1.2s var(--ease, ease) infinite;
}

.ui-skeleton:nth-child(3n) { width: 72%; }
.ui-skeleton:nth-child(3n+1) { width: 100%; }
.ui-skeleton:nth-child(3n+2) { width: 88%; }

@keyframes ui-skeleton-shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ui-skeleton { animation: none; }
  .ui-toast, .ui-modal-panel.modal-panel { transition: none; animation: none; }
}

.ui-empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 48px 16px;
  margin: 0;
}

.ui-empty-text { margin: 0 0 14px; color: var(--muted); }

.ui-empty .primary { margin: 0 auto; }
