/*
 * SecMet — démo : réplique du thème GTK 4 par défaut (Adwaita) sur lequel
 * l'application s'affiche, en sombre et en clair. Les couleurs sont des
 * jetons ; `resources/secmet.css` (porté dans secmet.css) s'appuie dessus
 * comme sur @theme_fg_color, @theme_bg_color et @theme_selected_bg_color.
 */
:root,
.gtk-dark {
  --fg: #ffffff;
  --fg-rgb: 255, 255, 255;
  --bg: #242424;
  --bg-rgb: 36, 36, 36;
  --view-bg: #1e1e1e;
  --headerbar-bg: #303030;
  --headerbar-shade: rgba(0, 0, 0, 0.36);
  --dialog-bg: #383838;
  --popover-bg: #383838;
  --accent: #3584e4;
  --accent-rgb: 53, 132, 228;
  --accent-fg: #78aeed;
  --destructive: #c01c28;
  --destructive-hover: #d02e3a;
  --entry-bg: rgba(255, 255, 255, 0.08);
  --scroll-thumb: rgba(255, 255, 255, 0.35);
  --shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.45), 0 2px 14px 5px rgba(0, 0, 0, 0.35);
  --font-ui: Verdana, 'DejaVu Sans', 'Bitstream Vera Sans', Geneva, sans-serif;
  --font-mono: 'DejaVu Sans Mono', 'Liberation Mono', Menlo, Consolas, monospace;
}
.gtk-light {
  --fg: rgba(0, 0, 0, 0.8);
  --fg-rgb: 0, 0, 0;
  --bg: #fafafa;
  --bg-rgb: 250, 250, 250;
  --view-bg: #ffffff;
  --headerbar-bg: #ebebeb;
  --headerbar-shade: rgba(0, 0, 0, 0.07);
  --dialog-bg: #fafafa;
  --popover-bg: #ffffff;
  --accent: #3584e4;
  --accent-rgb: 53, 132, 228;
  --accent-fg: #1c71d8;
  --destructive: #c01c28;
  --destructive-hover: #a51d2d;
  --entry-bg: rgba(0, 0, 0, 0.06);
  --scroll-thumb: rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 3px 1px rgba(0, 0, 0, 0.12), 0 2px 14px 5px rgba(0, 0, 0, 0.12);
}

/* ── Fenêtre ─────────────────────────────────────────────────────────── */
.gtk-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.25);
  font-family: var(--font-ui);
  font-weight: bold;
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  min-width: 0;
}
.gtk-window.maximized {
  border-radius: 0;
}
.gtk-window.inactive .gtk-headerbar {
  color: rgba(var(--fg-rgb), 0.55);
}
.gtk-window.inactive .gtk-headerbar .gtk-title {
  opacity: 0.6;
}

.gtk-headerbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 6px;
  background: var(--headerbar-bg);
  box-shadow: inset 0 -1px var(--headerbar-shade);
  cursor: default;
  user-select: none;
  position: relative;
}
.gtk-headerbar .gtk-title {
  position: absolute;
  left: 120px;
  right: 120px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.gtk-headerbar .start,
.gtk-headerbar .end {
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1;
}
.gtk-headerbar .end {
  margin-left: auto;
}
.gtk-dialog-window .gtk-headerbar {
  min-height: 46px;
}

/* Boutons de titre (fermer, réduire, agrandir) */
.gtk-wbtn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  margin: 0 4px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--fg-rgb), 0.1);
  color: var(--fg);
  cursor: default;
}
.gtk-wbtn:hover {
  background: rgba(var(--fg-rgb), 0.15);
}
.gtk-wbtn:active {
  background: rgba(var(--fg-rgb), 0.3);
}
.gtk-wbtn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.gtk-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Boutons ─────────────────────────────────────────────────────────── */
.gtk-button {
  font: inherit;
  font-weight: bold;
  color: var(--fg);
  background: rgba(var(--fg-rgb), 0.1);
  border: none;
  border-radius: 6px;
  min-height: 34px;
  padding: 5px 10px;
  cursor: default;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.gtk-button:hover:not(:disabled) {
  background: rgba(var(--fg-rgb), 0.15);
}
.gtk-button:active:not(:disabled) {
  background: rgba(var(--fg-rgb), 0.3);
}
.gtk-button:disabled {
  opacity: 0.5;
}
.gtk-button:focus-visible,
.gtk-check:focus-visible,
.gtk-entry:focus-visible,
.gtk-combo:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.5);
  outline-offset: 1px;
}
.gtk-button.suggested-action {
  background: var(--accent);
  color: #fff;
}
.gtk-button.suggested-action:hover:not(:disabled) {
  background: #4a90e8;
}
.gtk-button.destructive-action {
  background: var(--destructive);
  color: #fff;
}
.gtk-button.destructive-action:hover:not(:disabled) {
  background: var(--destructive-hover);
}
.gtk-button.icon {
  width: 34px;
  padding: 0;
}
.gtk-button.icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.gtk-button.flat {
  background: transparent;
}
.gtk-button.flat:hover:not(:disabled) {
  background: rgba(var(--fg-rgb), 0.07);
}

/* ── Case à cocher ───────────────────────────────────────────────────── */
.gtk-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: default;
  user-select: none;
  min-height: 24px;
}
.gtk-check .box {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 2px solid rgba(var(--fg-rgb), 0.3);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gtk-check.checked .box {
  background: var(--accent);
  border-color: var(--accent);
}
.gtk-check.checked .box::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.gtk-check.disabled {
  opacity: 0.5;
}

/* ── Saisie, liste déroulante ────────────────────────────────────────── */
.gtk-entry {
  font: inherit;
  font-weight: bold;
  color: var(--fg);
  background: var(--entry-bg);
  border: none;
  border-radius: 6px;
  min-height: 34px;
  padding: 0 9px;
  outline: none;
  box-sizing: border-box;
  width: 100%;
}
.gtk-entry:focus {
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.5);
}
.gtk-entry::placeholder {
  color: rgba(var(--fg-rgb), 0.5);
}
.gtk-password {
  position: relative;
  display: flex;
  align-items: center;
}
.gtk-password .peek {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: rgba(var(--fg-rgb), 0.7);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: default;
}
.gtk-password .peek:hover {
  background: rgba(var(--fg-rgb), 0.1);
}
.gtk-combo {
  font: inherit;
  font-weight: bold;
  color: var(--fg);
  background-color: rgba(var(--fg-rgb), 0.1);
  border: none;
  border-radius: 6px;
  min-height: 34px;
  padding: 0 32px 0 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  width: 100%;
  cursor: default;
}
.gtk-combo option {
  background: var(--popover-bg);
  color: var(--fg);
}
.gtk-combo:disabled {
  opacity: 0.5;
}

/* ── Barre de progression ────────────────────────────────────────────── */
.gtk-progress {
  height: 8px;
  border-radius: 99px;
  background: rgba(var(--fg-rgb), 0.15);
  overflow: hidden;
  position: relative;
}
.gtk-progress .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.25s linear;
}
.gtk-progress.pulse .fill {
  width: 18% !important;
  animation: gtk-pulse 1.6s ease-in-out infinite alternate;
  transition: none;
}
@keyframes gtk-pulse {
  from {
    left: 0;
  }
  to {
    left: 82%;
  }
}

/* ── Défilement ──────────────────────────────────────────────────────── */
.gtk-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
  min-height: 0;
}
.gtk-scroll::-webkit-scrollbar {
  width: 8px;
}
.gtk-scroll::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
}

/* ── Spinner GTK ─────────────────────────────────────────────────────── */
.gtk-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(var(--fg-rgb), 0.2);
  border-top-color: var(--fg);
  animation: gtk-spin 0.8s linear infinite;
  flex: none;
}
@keyframes gtk-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Dialogue (Gtk.Dialog avec titre) ────────────────────────────────── */
.gtk-dialog-window {
  background: var(--dialog-bg);
  border-radius: 12px;
}
.gtk-dialog-window .gtk-headerbar {
  background: var(--dialog-bg);
  box-shadow: none;
}

/* ── Gtk.MessageDialog : texte centré, boutons en pied, séparés ──────── */
.gtk-message {
  background: var(--dialog-bg);
  border-radius: 12px;
}
.gtk-message .message-area {
  padding: 30px 30px 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}
.gtk-message .message-text {
  font-size: 15px;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.gtk-message .message-extra {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.gtk-message .action-area {
  display: flex;
  border-top: 1px solid rgba(var(--fg-rgb), 0.15);
  flex: none;
}
.gtk-message .action-area button {
  flex: 1;
  font: inherit;
  font-weight: bold;
  color: var(--fg);
  background: transparent;
  border: none;
  min-height: 46px;
  cursor: default;
}
.gtk-message .action-area button + button {
  border-left: 1px solid rgba(var(--fg-rgb), 0.15);
}
.gtk-message .action-area button:hover {
  background: rgba(var(--fg-rgb), 0.07);
}
.gtk-message .action-area button:active {
  background: rgba(var(--fg-rgb), 0.16);
}
.gtk-message .action-area button.default {
  color: var(--accent-fg);
}
.gtk-message .action-area button:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.5);
  outline-offset: -2px;
}

.dim-label {
  opacity: 0.55;
}
small {
  font-size: 0.83em;
}
.pango-large {
  font-size: 1.2em;
  font-weight: bold;
}
