/* Fiagril DS — Component styles */

/* ==================== BUTTON ==================== */
.ds-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-3);
  height: var(--ds-control-height-md);
  padding: 0 var(--ds-control-padding-x);
  border: 1px solid transparent;
  border-radius: var(--ds-radius-button);
  background: var(--ds-color-brand);
  color: var(--ds-color-brand-on);
  font-family: var(--ds-font-family-sans);
  font-size: var(--ds-font-size-14);
  font-weight: var(--ds-font-weight-medium);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  transition: background var(--ds-duration-fast) var(--ds-easing-standard),
              border-color var(--ds-duration-fast) var(--ds-easing-standard),
              color var(--ds-duration-fast) var(--ds-easing-standard),
              transform var(--ds-duration-fast) var(--ds-easing-standard);
  white-space: nowrap;
}
.ds-button:hover { background: var(--ds-color-brand-hover); }
.ds-button:active { background: var(--ds-color-brand-active); transform: translateY(0.5px); }
.ds-button:disabled { opacity: 0.45; cursor: not-allowed; }

.ds-button--secondary {
  background: var(--ds-color-surface);
  color: var(--ds-color-text-primary);
  border-color: var(--ds-color-border-default);
}
.ds-button--secondary:hover { background: var(--ds-color-bg-subtle); border-color: var(--ds-color-border-strong); }
.ds-button--secondary:active { background: var(--ds-color-bg-subtle); }

.ds-button--ghost {
  background: transparent;
  color: var(--ds-color-text-primary);
}
.ds-button--ghost:hover { background: var(--ds-color-bg-subtle); }

.ds-button--link {
  background: transparent;
  color: var(--ds-color-brand);
  padding: 0;
  height: auto;
}
.ds-button--link:hover { text-decoration: underline; background: transparent; }

.ds-button--danger { background: var(--ds-color-danger); }
.ds-button--danger:hover { filter: brightness(0.92); }

.ds-button--sm { height: var(--ds-control-height-sm); font-size: var(--ds-font-size-13); padding: 0 calc(var(--ds-control-padding-x) - 4px); }
.ds-button--lg { height: var(--ds-control-height-lg); font-size: var(--ds-font-size-15); padding: 0 calc(var(--ds-control-padding-x) + 4px); }

.ds-button--icon { width: var(--ds-control-height-md); padding: 0; }
.ds-button--icon.ds-button--sm { width: var(--ds-control-height-sm); }
.ds-button--icon.ds-button--lg { width: var(--ds-control-height-lg); }

/* ==================== INPUT ==================== */
.ds-input, .ds-select, .ds-textarea {
  display: block;
  width: 100%;
  height: var(--ds-control-height-md);
  padding: 0 var(--ds-control-padding-x);
  background: var(--ds-color-surface);
  color: var(--ds-color-text-primary);
  border: 1px solid var(--ds-color-border-default);
  border-radius: var(--ds-radius-input);
  font-family: var(--ds-font-family-sans);
  font-size: var(--ds-font-size-14);
  line-height: var(--ds-control-height-md);
  transition: border-color var(--ds-duration-fast) var(--ds-easing-standard),
              box-shadow var(--ds-duration-fast) var(--ds-easing-standard);
}
.ds-textarea { height: auto; padding: 10px var(--ds-control-padding-x); line-height: var(--ds-line-height-normal); min-height: 80px; resize: vertical; }
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--ds-color-text-tertiary); }
.ds-input:hover, .ds-select:hover, .ds-textarea:hover { border-color: var(--ds-color-border-strong); }
.ds-input:focus, .ds-select:focus, .ds-textarea:focus {
  outline: none;
  border-color: var(--ds-color-brand);
  box-shadow: var(--ds-shadow-focus);
}
.ds-input[aria-invalid='true'], .ds-input--error {
  border-color: var(--ds-color-danger);
}
.ds-input[aria-invalid='true']:focus { box-shadow: 0 0 0 3px oklch(55% 0.18 25 / 0.3); }

.ds-field { display: flex; flex-direction: column; gap: var(--ds-space-3); }
.ds-field__label { font-size: var(--ds-font-size-13); font-weight: var(--ds-font-weight-medium); color: var(--ds-color-text-primary); }
.ds-field__label--required::after { content: ' *'; color: var(--ds-color-danger); }
.ds-field__hint { font-size: var(--ds-font-size-12); color: var(--ds-color-text-secondary); }
.ds-field__error { font-size: var(--ds-font-size-12); color: var(--ds-color-danger); }

.ds-input-group { position: relative; display: flex; align-items: center; }
.ds-input-group__icon {
  position: absolute; left: 12px; pointer-events: none;
  color: var(--ds-color-text-tertiary); display: flex;
}
.ds-input-group .ds-input { padding-left: 36px; }

/* Checkbox + radio */
.ds-check, .ds-radio {
  display: inline-flex; align-items: center; gap: var(--ds-space-3);
  cursor: pointer; user-select: none;
  font-size: var(--ds-font-size-14);
}
.ds-check input, .ds-radio input { position: absolute; opacity: 0; pointer-events: none; }
.ds-check__box, .ds-radio__dot {
  width: 16px; height: 16px; border: 1.5px solid var(--ds-color-border-strong);
  background: var(--ds-color-surface); transition: all var(--ds-duration-fast) var(--ds-easing-standard);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ds-check__box { border-radius: var(--ds-radius-xs); }
.ds-radio__dot { border-radius: 999px; }
.ds-check input:checked + .ds-check__box {
  background: var(--ds-color-brand); border-color: var(--ds-color-brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 6.5L4.75 8.75L9.5 3.5' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.ds-radio input:checked + .ds-radio__dot { border-color: var(--ds-color-brand); border-width: 5px; }

/* Switch */
.ds-switch { display: inline-flex; align-items: center; gap: var(--ds-space-3); cursor: pointer; user-select: none; font-size: var(--ds-font-size-14); }
.ds-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ds-switch__track {
  width: 34px; height: 20px; border-radius: 999px;
  background: var(--ds-color-border-default); position: relative;
  transition: background var(--ds-duration-fast) var(--ds-easing-standard);
  flex-shrink: 0;
}
.ds-switch__track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 999px; background: white;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: transform var(--ds-duration-fast) var(--ds-easing-standard);
}
.ds-switch input:checked + .ds-switch__track { background: var(--ds-color-brand); }
.ds-switch input:checked + .ds-switch__track::after { transform: translateX(14px); }

/* ==================== BADGE ==================== */
.ds-badge {
  display: inline-flex; align-items: center; gap: var(--ds-space-2);
  padding: 2px 8px; border-radius: var(--ds-radius-full);
  background: var(--ds-color-bg-subtle); color: var(--ds-color-text-primary);
  font-size: var(--ds-font-size-12); font-weight: var(--ds-font-weight-medium);
  line-height: 1.5;
}
.ds-badge--brand   { background: var(--ds-color-brand-subtle); color: var(--ds-color-brand); }
.ds-badge--success { background: var(--ds-color-success-subtle); color: var(--ds-color-success); }
.ds-badge--warning { background: var(--ds-color-warning-subtle); color: var(--ds-color-warning); }
.ds-badge--danger  { background: var(--ds-color-danger-subtle); color: var(--ds-color-danger); }
.ds-badge--info    { background: var(--ds-color-info-subtle); color: var(--ds-color-info); }
.ds-badge--solid   { background: var(--ds-color-brand); color: var(--ds-color-brand-on); }
.ds-badge__dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* ==================== CARD ==================== */
.ds-card {
  background: var(--ds-color-surface);
  border: 1px solid var(--ds-color-border-subtle);
  border-radius: var(--ds-radius-card);
  padding: var(--ds-card-padding);
}
.ds-card--elevated { box-shadow: var(--ds-shadow-2); border-color: transparent; }
.ds-card--interactive { cursor: pointer; transition: box-shadow var(--ds-duration-base) var(--ds-easing-standard), border-color var(--ds-duration-base) var(--ds-easing-standard); }
.ds-card--interactive:hover { box-shadow: var(--ds-shadow-2); border-color: var(--ds-color-border-default); }
.ds-card__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--ds-space-4); gap: var(--ds-space-4); }
.ds-card__title { font-size: var(--ds-font-size-15); font-weight: var(--ds-font-weight-semibold); margin: 0; }
.ds-card__sub { font-size: var(--ds-font-size-12); color: var(--ds-color-text-secondary); margin-top: 2px; }
.ds-card__footer { margin-top: var(--ds-space-5); padding-top: var(--ds-space-4); border-top: 1px solid var(--ds-color-border-subtle); display: flex; justify-content: space-between; align-items: center; gap: var(--ds-space-3); }

/* ==================== ALERT / TOAST ==================== */
.ds-alert {
  display: flex; gap: var(--ds-space-4); padding: 12px 14px;
  border-radius: var(--ds-radius-md); border: 1px solid var(--ds-color-border-subtle);
  background: var(--ds-color-surface);
  align-items: flex-start;
}
.ds-alert__icon { flex-shrink: 0; display: flex; align-items: center; margin-top: 1px; }
.ds-alert__content { flex: 1; font-size: var(--ds-font-size-13); line-height: var(--ds-line-height-normal); }
.ds-alert__title { font-weight: var(--ds-font-weight-semibold); margin-bottom: 2px; font-size: var(--ds-font-size-14); }
.ds-alert--info    { background: var(--ds-color-info-subtle); border-color: transparent; color: var(--ds-color-info); }
.ds-alert--success { background: var(--ds-color-success-subtle); border-color: transparent; color: var(--ds-color-success); }
.ds-alert--warning { background: var(--ds-color-warning-subtle); border-color: transparent; color: var(--ds-color-warning); }
.ds-alert--danger  { background: var(--ds-color-danger-subtle); border-color: transparent; color: var(--ds-color-danger); }
.ds-alert--info .ds-alert__content,
.ds-alert--success .ds-alert__content,
.ds-alert--warning .ds-alert__content,
.ds-alert--danger .ds-alert__content { color: var(--ds-color-text-primary); }

/* ==================== TABLE ==================== */
.ds-table-wrap { border: 1px solid var(--ds-color-border-subtle); border-radius: var(--ds-radius-card); overflow: hidden; background: var(--ds-color-surface); }
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--ds-font-size-13); }
.ds-table thead th {
  text-align: left; font-weight: var(--ds-font-weight-semibold);
  color: var(--ds-color-text-secondary); text-transform: uppercase;
  font-size: var(--ds-font-size-11); letter-spacing: 0.06em;
  background: var(--ds-color-bg-subtle);
  padding: 0 12px; height: var(--ds-row-height);
  border-bottom: 1px solid var(--ds-color-border-subtle);
  white-space: nowrap; user-select: none;
}
.ds-table tbody td { padding: 0 12px; height: var(--ds-row-height); border-bottom: 1px solid var(--ds-color-border-subtle); }
.ds-table tbody tr:last-child td { border-bottom: none; }
.ds-table tbody tr:hover { background: var(--ds-color-bg-subtle); }
.ds-table__num { font-family: var(--ds-font-family-mono); font-variant-numeric: tabular-nums; text-align: right; }
.ds-table__sort { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

/* ==================== TABS ==================== */
.ds-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ds-color-border-subtle); }
.ds-tab {
  padding: 10px 14px; font-size: var(--ds-font-size-13); font-weight: var(--ds-font-weight-medium);
  color: var(--ds-color-text-secondary); border: none; background: transparent; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all var(--ds-duration-fast);
}
.ds-tab:hover { color: var(--ds-color-text-primary); }
.ds-tab[aria-selected='true'] { color: var(--ds-color-brand); border-bottom-color: var(--ds-color-brand); }

/* ==================== PROGRESS ==================== */
.ds-progress { height: 6px; background: var(--ds-color-bg-subtle); border-radius: 999px; overflow: hidden; }
.ds-progress__bar { height: 100%; background: var(--ds-color-brand); border-radius: inherit; transition: width var(--ds-duration-slow) var(--ds-easing-standard); }

/* ==================== PATH / STEPPER ==================== */
.ds-path { display: flex; background: var(--ds-color-surface); border: 1px solid var(--ds-color-border-subtle); border-radius: var(--ds-radius-input); overflow: hidden; }
.ds-path__step {
  flex: 1; position: relative; padding: 10px 14px 10px 32px; font-size: var(--ds-font-size-12);
  background: var(--ds-color-surface); color: var(--ds-color-text-secondary);
  font-weight: var(--ds-font-weight-medium);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%);
}
.ds-path__step:first-child { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%); }
.ds-path__step:last-child  { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 14px 50%); }
.ds-path__step--done { background: var(--ds-color-brand-subtle); color: var(--ds-color-brand); }
.ds-path__step--current { background: var(--ds-color-brand); color: var(--ds-color-brand-on); }
.ds-path__num { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-family: var(--ds-font-family-mono); opacity: 0.7; }

/* ==================== AVATAR ==================== */
.ds-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--ds-color-brand-subtle); color: var(--ds-color-brand);
  font-weight: var(--ds-font-weight-semibold); font-size: var(--ds-font-size-13);
  flex-shrink: 0;
}
.ds-avatar--sm { width: 24px; height: 24px; font-size: 11px; }
.ds-avatar--lg { width: 40px; height: 40px; font-size: var(--ds-font-size-14); }

/* ==================== TOKEN SWATCH (docs) ==================== */
.ds-swatch { display: flex; flex-direction: column; gap: 6px; }
.ds-swatch__chip { width: 100%; aspect-ratio: 2 / 1; border-radius: var(--ds-radius-md); border: 1px solid var(--ds-color-border-subtle); }
.ds-swatch__meta { display: flex; flex-direction: column; gap: 2px; }
.ds-swatch__name { font-size: var(--ds-font-size-12); font-weight: var(--ds-font-weight-medium); }
.ds-swatch__token { font-family: var(--ds-font-family-mono); font-size: 11px; color: var(--ds-color-text-tertiary); }

/* ==================== DOC MISC ==================== */
.ds-kbd {
  display: inline-flex; align-items: center; padding: 1px 6px;
  border: 1px solid var(--ds-color-border-default); border-bottom-width: 2px;
  border-radius: 4px; font-family: var(--ds-font-family-mono);
  font-size: 11px; background: var(--ds-color-surface); color: var(--ds-color-text-secondary);
}
.ds-chip-toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--ds-color-border-default); background: var(--ds-color-surface);
  border-radius: 999px; font-size: var(--ds-font-size-12); cursor: pointer;
  color: var(--ds-color-text-secondary); font-weight: var(--ds-font-weight-medium);
  transition: all var(--ds-duration-fast);
}
.ds-chip-toggle[aria-pressed='true'] { background: var(--ds-color-brand); color: var(--ds-color-brand-on); border-color: var(--ds-color-brand); }
.ds-chip-toggle:hover:not([aria-pressed='true']) { border-color: var(--ds-color-border-strong); color: var(--ds-color-text-primary); }

/* Code block */
.ds-code-block {
  background: var(--ds-color-surface-sunken);
  border: 1px solid var(--ds-color-border-subtle);
  border-radius: var(--ds-radius-md);
  padding: 12px 14px;
  font-family: var(--ds-font-family-mono);
  font-size: var(--ds-font-size-12);
  line-height: 1.6;
  overflow-x: auto;
  color: var(--ds-color-text-primary);
  white-space: pre;
}
.ds-code-block .tok-key { color: var(--ds-color-accent); }
.ds-code-block .tok-val { color: var(--ds-color-brand); }
.ds-code-block .tok-com { color: var(--ds-color-text-tertiary); font-style: italic; }
