/* ============================================================
   Centrica · Component styles
   Class-based styling for the React primitives so hover / focus
   / active states work. Prefixed `cx-` to avoid collisions.
   Imported from styles.css → shipped to consumers.
   ============================================================ */

/* ---------------- Button ---------------- */
.cx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--spacing-2);
  font-family: var(--font-sans); font-weight: var(--font-weight-medium);
  font-size: var(--text-sm); line-height: 1; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--radius-md);
  height: 2.25rem; padding: 0 var(--spacing-4); cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard),
              border-color var(--duration-fast) var(--ease-standard),
              opacity var(--duration-fast) var(--ease-standard);
  user-select: none; text-decoration: none;
}
.cx-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.cx-btn:disabled, .cx-btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.cx-btn svg { width: 1rem; height: 1rem; flex: none; }

.cx-btn--default { background: var(--primary); color: var(--primary-foreground); }
.cx-btn--default:hover { background: color-mix(in srgb, var(--primary) 90%, black); }
.cx-btn--secondary { background: var(--secondary); color: var(--secondary-foreground); }
.cx-btn--secondary:hover { background: color-mix(in srgb, var(--secondary) 85%, black); }
.cx-btn--outline { background: var(--background); color: var(--foreground); border-color: var(--border); }
.cx-btn--outline:hover { background: var(--accent); color: var(--accent-foreground); }
.cx-btn--ghost { background: transparent; color: var(--foreground); }
.cx-btn--ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.cx-btn--destructive { background: var(--destructive); color: var(--destructive-foreground); }
.cx-btn--destructive:hover { background: color-mix(in srgb, var(--destructive) 88%, black); }
.cx-btn--link { background: transparent; color: var(--primary); height: auto; padding: 0; border-radius: 0; }
.cx-btn--link:hover { text-decoration: underline; }

.cx-btn--sm { height: 2rem; padding: 0 var(--spacing-3); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.cx-btn--lg { height: 2.5rem; padding: 0 var(--spacing-6); border-radius: var(--radius-md); }
.cx-btn--icon { height: 2.25rem; width: 2.25rem; padding: 0; }

/* ---------------- Badge ---------------- */
.cx-badge {
  display: inline-flex; align-items: center; gap: var(--spacing-1);
  font-family: var(--font-sans); font-weight: var(--font-weight-medium); font-size: var(--text-xs);
  line-height: 1; padding: 0.25rem 0.5rem; border-radius: var(--radius-md);
  border: 1px solid transparent; white-space: nowrap;
}
.cx-badge svg { width: 0.75rem; height: 0.75rem; }
.cx-badge--default { background: var(--primary); color: var(--primary-foreground); }
.cx-badge--secondary { background: var(--secondary); color: var(--secondary-foreground); }
.cx-badge--outline { background: transparent; color: var(--foreground); border-color: var(--border); }
.cx-badge--destructive { background: var(--destructive); color: var(--destructive-foreground); }
.cx-badge--success { background: var(--centrica-green-mid); color: #fff; }

/* ---------------- Card ---------------- */
.cx-card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-xs); }
.cx-card__header { display: flex; flex-direction: column; gap: var(--spacing-1); padding: var(--spacing-6); }
.cx-card__title { font-family: var(--font-sans); font-weight: var(--font-weight-semibold); font-size: var(--text-lg); line-height: var(--leading-lg); letter-spacing: var(--tracking-tight); margin: 0; }
.cx-card__desc { font-family: var(--font-sans); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--muted-foreground); margin: 0; }
.cx-card__content { padding: 0 var(--spacing-6) var(--spacing-6); }
.cx-card__footer { display: flex; align-items: center; gap: var(--spacing-3); padding: 0 var(--spacing-6) var(--spacing-6); }

/* ---------------- Input / Textarea ---------------- */
.cx-input, .cx-textarea {
  display: block; width: 100%; box-sizing: border-box;
  font-family: var(--font-sans); font-size: var(--text-sm); color: var(--foreground);
  background: var(--background); border: 1px solid var(--input); border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.cx-input { height: 2.25rem; padding: 0 var(--spacing-3); }
.cx-textarea { min-height: 5rem; padding: var(--spacing-2) var(--spacing-3); line-height: var(--leading-sm); resize: vertical; }
.cx-input::placeholder, .cx-textarea::placeholder { color: var(--muted-foreground); }
.cx-input:focus-visible, .cx-textarea:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 35%, transparent); }
.cx-input:disabled, .cx-textarea:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Label ---------------- */
.cx-label { display: inline-flex; align-items: center; gap: var(--spacing-2); font-family: var(--font-sans); font-weight: var(--font-weight-medium); font-size: var(--text-sm); color: var(--foreground); }

/* ---------------- Checkbox ---------------- */
.cx-checkbox { -webkit-appearance: none; appearance: none; margin: 0; width: 1rem; height: 1rem; flex: none;
  border: 1px solid var(--input); border-radius: var(--radius-sm); background: var(--background); cursor: pointer;
  display: inline-grid; place-content: center; transition: background-color var(--duration-fast), border-color var(--duration-fast); }
.cx-checkbox:checked { background: var(--primary); border-color: var(--primary); }
.cx-checkbox:checked::after { content: ""; width: 0.625rem; height: 0.625rem; background: var(--primary-foreground);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat; }
.cx-checkbox:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.cx-checkbox:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Switch ---------------- */
.cx-switch { -webkit-appearance: none; appearance: none; margin: 0; position: relative; width: 2.25rem; height: 1.25rem; flex: none;
  background: var(--input); border-radius: var(--radius-full); cursor: pointer; transition: background-color var(--duration-base) var(--ease-standard); }
.cx-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 1rem; height: 1rem; border-radius: var(--radius-full);
  background: var(--background); box-shadow: var(--shadow-sm); transition: transform var(--duration-base) var(--ease-standard); }
.cx-switch:checked { background: var(--primary); }
.cx-switch:checked::after { transform: translateX(1rem); }
.cx-switch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.cx-switch:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Avatar ---------------- */
.cx-avatar { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.5rem; height: 2.5rem; border-radius: var(--radius-full); overflow: hidden; background: var(--muted);
  font-family: var(--font-sans); font-weight: var(--font-weight-medium); font-size: var(--text-sm); color: var(--muted-foreground); user-select: none; }
.cx-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cx-avatar--sm { width: 2rem; height: 2rem; font-size: var(--text-xs); }
.cx-avatar--lg { width: 3.5rem; height: 3.5rem; font-size: var(--text-lg); }

/* ---------------- Alert ---------------- */
.cx-alert { display: grid; grid-template-columns: auto 1fr; gap: 0 var(--spacing-3);
  padding: var(--spacing-4); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); color: var(--card-foreground); }
.cx-alert svg { width: 1rem; height: 1rem; margin-top: 2px; }
.cx-alert__title { font-family: var(--font-sans); font-weight: var(--font-weight-semibold); font-size: var(--text-sm); line-height: var(--leading-sm); margin: 0 0 2px; }
.cx-alert__desc { font-family: var(--font-sans); font-size: var(--text-sm); line-height: var(--leading-sm); color: var(--muted-foreground); margin: 0; }
.cx-alert--destructive { border-color: color-mix(in srgb, var(--destructive) 40%, transparent); color: var(--destructive); }
.cx-alert--destructive .cx-alert__desc { color: color-mix(in srgb, var(--destructive) 80%, var(--foreground)); }

/* ---------------- Separator ---------------- */
.cx-separator { border: none; background: var(--border); flex: none; }
.cx-separator--h { height: 1px; width: 100%; margin: 0; }
.cx-separator--v { width: 1px; align-self: stretch; }

/* ---------------- Tabs ---------------- */
.cx-tabs__list { display: inline-flex; align-items: center; gap: var(--spacing-1); padding: var(--spacing-1); background: var(--muted); border-radius: var(--radius-lg); }
.cx-tabs__trigger { appearance: none; border: none; background: transparent; cursor: pointer;
  font-family: var(--font-sans); font-weight: var(--font-weight-medium); font-size: var(--text-sm); color: var(--muted-foreground);
  padding: 0.375rem 0.75rem; border-radius: var(--radius-md); transition: background-color var(--duration-fast), color var(--duration-fast); }
.cx-tabs__trigger:hover { color: var(--foreground); }
.cx-tabs__trigger[data-state="active"] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }

/* ---------------- Kbd ---------------- */
.cx-kbd { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--muted-foreground); background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 1px 5px; min-width: 1.25rem; height: 1.25rem; justify-content: center; }

/* ---------------- Skeleton ---------------- */
.cx-skeleton { background: var(--muted); border-radius: var(--radius-md); animation: cx-pulse 1.6s var(--ease-standard) infinite; }
@keyframes cx-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .cx-skeleton { animation: none; } }

/* ---------------- Progress ---------------- */
.cx-progress { width: 100%; height: 0.5rem; background: var(--muted); border-radius: var(--radius-full); overflow: hidden; }
.cx-progress__bar { height: 100%; background: var(--primary); border-radius: var(--radius-full); transition: width var(--duration-base) var(--ease-standard); }
