/* Oghma - composants réutilisables (boutons, cartes, champs, tableaux, dialogues...). */

/* Boutons (mat-flat-button / mat-stroked-button / mat-button) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--oghma-navy);
  background: transparent;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition:
    box-shadow 0.15s ease,
    filter 0.15s ease,
    background 0.15s ease;
}

.btn:hover {
  color: var(--oghma-navy);
  text-decoration: none;
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  pointer-events: none;
}

.btn--primary {
  background: var(--oghma-grad);
  box-shadow: 0 10px 22px rgba(var(--oghma-gold-rgb), 0.32);
}

.btn--primary:hover {
  filter: brightness(1.04);
}

.btn--outline {
  border-color: rgba(var(--oghma-steel-rgb), 0.32);
  background: linear-gradient(135deg, rgba(var(--oghma-gold-rgb), 0.16) 0%, rgba(var(--oghma-steel-rgb), 0.12) 100%);
}

.btn--ghost:hover {
  background: rgba(var(--oghma-steel-rgb), 0.1);
}

.btn--danger {
  color: #ffffff;
  background: var(--oghma-grad-danger);
  box-shadow: 0 8px 18px rgba(224, 62, 90, 0.28);
}

.btn--danger:hover {
  color: #ffffff;
  filter: brightness(1.05);
}

.btn--outline.btn--danger {
  color: var(--oghma-navy);
  border-color: rgba(224, 62, 90, 0.38);
  background: linear-gradient(
    135deg,
    rgba(255, 122, 122, 0.18) 0%,
    rgba(224, 62, 90, 0.14) 46%,
    rgba(198, 40, 40, 0.12) 100%
  );
  box-shadow: none;
}

/* Bouton d'ajout qui s'élargit au survol (.expandable-add-button) */
.btn--expand {
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  width: 28px;
  padding: 0 6px;
  gap: 0;
  overflow: hidden;
  font-size: 0.78rem;
  line-height: 28px;
  transition:
    width 0.25s ease,
    padding 0.25s ease;
}

.btn--expand .icon {
  font-size: 16px;
}

.btn--expand .btn__label {
  display: inline-block;
  max-width: 0;
  margin-left: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition:
    max-width 0.3s ease,
    opacity 0.2s ease,
    margin-left 0.25s ease;
}

.btn--expand:hover:not(:disabled),
.btn--expand:focus-visible:not(:disabled) {
  width: auto;
  padding: 0 10px;
}

.btn--expand:hover:not(:disabled) .btn__label,
.btn--expand:focus-visible:not(:disabled) .btn__label {
  max-width: 220px;
  margin-left: 4px;
  opacity: 1;
}

/* Boutons-icônes (mat-icon-button, 36 px) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--oghma-navy);
  background: transparent;
  font-size: 20px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  color: var(--oghma-navy);
  background: rgba(var(--oghma-steel-rgb), 0.12);
}

.icon-btn--gold,
.icon-btn--gold:hover {
  background: var(--oghma-grad);
}

.icon-btn--gold {
  box-shadow: 0 4px 12px rgba(var(--oghma-gold-rgb), 0.28);
}

.icon-btn--danger,
.icon-btn--danger:hover {
  color: #ffffff;
  background: var(--oghma-grad-danger);
}

.icon-btn--danger {
  box-shadow: 0 4px 12px rgba(224, 62, 90, 0.24);
}

/* Champs de formulaire (mat-form-field outline) */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field__label {
  color: var(--oghma-navy);
  font-size: 0.875rem;
  font-weight: 600;
}

.field--checkbox .field__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.field__help {
  color: var(--oghma-muted);
  font-size: 0.8125rem;
}

.field__error {
  color: var(--oghma-error);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* Ajout d'une ressource : l'URL ou le fichier selon le type coché, sans JavaScript */
.field--type div[id] {
  display: flex;
  gap: 16px;
}

.resource-form:has(input[name='type'][value='UPLOAD']:checked) .field--url,
.resource-form:has(input[name='type'][value='LINK']:checked) .field--file {
  display: none;
}

/* Filtre par catégorie */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-chip {
  padding: 2px 12px;
  border-radius: 999px;
  color: var(--oghma-navy);
  background: rgba(var(--oghma-steel-rgb), 0.12);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.filter-chip.is-active {
  background: rgba(var(--oghma-gold-rgb), 0.35);
}

/* Journaux : filtres (formulaire GET) et pagination */
.log-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.log-filters .field {
  min-width: min(240px, 100%);
  margin-bottom: 0;
}

.log-filters__actions {
  display: flex;
  gap: 8px;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.pager__status {
  color: var(--oghma-muted);
  font-size: 0.875rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* Cartes (mat-card) */
.card {
  border: 1px solid rgba(var(--oghma-steel-rgb), 0.12);
  border-radius: var(--oghma-radius);
  background: #ffffff;
  box-shadow: var(--oghma-shadow);
}

.card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 16px 0 20px;
}

.card__title {
  margin: 0;
  font-family: var(--oghma-font-display);
  font-size: 1.125rem;
  font-weight: 700;
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
  margin-left: auto;
}

.card__body {
  padding: 16px 20px 20px;
}

/* Tableaux (mat-table) */
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

table.data-table {
  background: transparent;
}

.data-table thead tr {
  background: rgba(var(--oghma-steel-rgb), 0.08);
}

.data-table th {
  color: var(--oghma-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table td {
  border-bottom: 1px solid var(--oghma-line);
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

/* Pastilles */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--oghma-navy);
  background: rgba(var(--oghma-steel-rgb), 0.12);
  font-size: 0.8125rem;
  font-weight: 600;
}

.chip--gold {
  background: rgba(var(--oghma-gold-rgb), 0.22);
}

.chip--private {
  margin-left: 6px;
  background: rgba(var(--oghma-gold-rgb), 0.22);
}

.field--visibility > div {
  display: flex;
  gap: 16px;
}

/* Messages */
.alert {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-left: 0.25rem solid var(--oghma-steel);
  border-radius: 8px;
  background: #ffffff;
}

.alert--error {
  border-left-color: var(--oghma-error);
  background: rgba(224, 62, 90, 0.08);
}

.alert--success {
  border-left-color: #2e8b57;
  background: rgba(46, 139, 87, 0.1);
}

.empty-state {
  padding: 2rem 1rem;
  color: var(--oghma-muted);
  text-align: center;
}

.hint {
  color: var(--oghma-muted);
  font-size: 0.875rem;
}

/* Infobulle CSS (matTooltip) */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  z-index: 50;
  padding: 4px 8px;
  border-radius: 6px;
  color: #ffffff;
  background: var(--oghma-navy);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.15s ease;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
}

/* Dialogues natifs (MatDialog) */
.dialog {
  width: 100%;
  max-width: min(560px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: var(--oghma-radius);
  color: var(--oghma-ink);
  background: #ffffff;
  box-shadow: var(--oghma-shadow);
}

.dialog::backdrop {
  background: rgba(var(--oghma-navy-rgb), 0.45);
}

.dialog__title {
  margin: 0 0 16px;
  font-family: var(--oghma-font-display);
  font-size: 1.375rem;
  font-weight: 600;
}

.dialog__form {
  display: block;
  margin: 0;
}

/* Couvertures de projet (dégradés de project-display.ts) */
.cover-0 {
  background: linear-gradient(135deg, #162331, #4c658f);
}

.cover-1 {
  background: linear-gradient(135deg, #4c658f, #e4bc6a);
}

.cover-2 {
  background: linear-gradient(135deg, #162331, #e4bc6a);
}

.cover-3 {
  background: linear-gradient(135deg, #e4bc6a, #4c658f);
}

.cover-4 {
  background: linear-gradient(135deg, #1c2c3d, #4c658f 52%, #e4bc6a);
}

.cover-5 {
  background: linear-gradient(135deg, #4c658f, #162331);
}

/* Indicateur htmx (includeIndicatorStyles désactivé pour respecter la CSP) */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

/* Avis d'erreur htmx (réponses non échangées : 403, 404, 413, 5xx, réseau), rempli par oghma.js */
.htmx-error {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-left: 0.25rem solid var(--oghma-error);
  border-radius: 8px;
  background: rgba(224, 62, 90, 0.08);
}

.secret-value {
  white-space: pre-wrap;
}

.slug-preview {
  margin: 0.35rem 0 0;
  min-height: 1.4em;
  font-size: 0.9rem;
}

.slug-preview--ok {
  color: var(--oghma-success);
}

.slug-preview--ko {
  color: var(--oghma-error);
}
