/* ─── Bootstrap CSS compat ────────────────────────────────────────────────────
 * Bootstrap JS est conservé (window.bootstrap.Modal, Dropdown, Collapse…)
 * mais Bootstrap CSS est supprimé. Ce fichier fournit le CSS minimal pour que
 * les composants Bootstrap JS fonctionnent, avec les tokens Bazyl.
 *
 * RÈGLE : ne jamais toucher au JS ni aux data-* attributes.
 * ─────────────────────────────────────────────────────────────────────────── */

/* ── 1. Utilitaires critiques ─────────────────────────────────────────────── */

/* d-none est utilisé par time_tracker_controller.js (classList.add/remove) */
.d-none   { display: none !important; }
.d-block  { display: block !important; }
.d-flex   { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-inline { display: inline !important; }

/* Responsive visibility (navbar top) */
@media (min-width: 992px) {
  .d-lg-none  { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-flex  { display: flex !important; }
}

/* Spacing shims — Bootstrap naming */
.ms-auto { margin-left: auto !important; }
.me-auto { margin-right: auto !important; }
.me-1 { margin-right: 4px !important; }
.me-2 { margin-right: 8px !important; }
.me-3 { margin-right: 12px !important; }
.ms-1 { margin-left: 4px !important; }
.ms-2 { margin-left: 8px !important; }
.ms-3 { margin-left: 12px !important; }

/* Alignment shims */
.align-items-center  { align-items: center !important; }
.align-items-start   { align-items: flex-start !important; }
.align-items-end     { align-items: flex-end !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end     { justify-content: flex-end !important; }

/* Other layout shims */
.w-100  { width: 100% !important; }
.h-100  { height: 100% !important; }
.gap-2  { gap: 8px !important; }   /* déjà dans utilities mais avec !important */
.gap-3  { gap: 12px !important; }

/* Typography shims */
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-center   { text-align: center !important; }
.fw-bold       { font-weight: 700 !important; }
.fw-semibold   { font-weight: 600 !important; }
.small         { font-size: 0.875em; }

/* Display size — utilisé dans _active_modal (.display-3.fw-bold) */
.display-3 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  font-family: var(--font);
}

/* Background shims */
.bg-light { background-color: var(--gray-50) !important; }

/* Border radius shims */
.rounded-circle { border-radius: 50% !important; }

/* ── 2. Bootstrap Modal ───────────────────────────────────────────────────── */
/*
 * _modals.css définit .modal avec display:flex (pattern Bazyl).
 * On écrase ici pour Bootstrap JS qui attend display:none → display:block.
 * Les vues Bazyl utilisent .modal-overlay > .modal mais aucune vue n'utilise
 * actuellement .modal-overlay, donc ce reset est sans impact.
 */

.modal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1055 !important;
  display: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  /* reset propriétés visuelles de _modals.css (la boîte blanche va dans .modal-content) */
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  max-width: none !important;
  max-height: none !important;
  width: auto !important;
  flex-direction: unset !important;
  padding: 0 !important;
}

.modal.show { display: block !important; }

/* Backdrop — inséré par Bootstrap JS dans <body> */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(30, 10, 2, 0.45);
  backdrop-filter: blur(2px);
}
.modal-backdrop.fade  { opacity: 0; transition: opacity 200ms ease; }
.modal-backdrop.show  { opacity: 1; }

/* Body state — Bootstrap JS ajoute .modal-open sur <body> */
body.modal-open { overflow: hidden; }

/* Dialog — centrage horizontal */
.modal-dialog {
  position: relative;
  width: auto;
  margin: 28px auto;
  max-width: 520px;
  pointer-events: none;
}

.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 56px);
}

/* Tailles */
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

/* Content — boîte blanche */
.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  background: #fff;
  border-radius: var(--r-xl);
  box-shadow: 0 20px 60px rgba(30, 10, 2, 0.18), 0 4px 16px rgba(30, 10, 2, 0.1);
  overflow: hidden;
}

/* Header / Body / Footer */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.modal-body {
  flex: 1 1 auto;
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
}

/* Transition fade */
.modal.fade { transition: opacity 200ms ease; opacity: 0; }
.modal.show { opacity: 1 !important; }

/* ── 3. Bouton fermeture (btn-close) ──────────────────────────────────────── */
.btn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--gray-100) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3E%3C/svg%3E") center / 10px no-repeat;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition), background var(--transition);
  flex-shrink: 0;
}
.btn-close:hover { opacity: 1; background-color: var(--gray-200); }

/* ── 4. Bootstrap Dropdown ────────────────────────────────────────────────── */
.dropdown { position: relative; }

.dropdown-toggle::after {
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
  content: "";
  border-top: 4px solid currentColor;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 180px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md), 0 8px 24px rgba(30, 10, 2, 0.08);
  margin-top: 4px;
}
.dropdown-menu.show { display: block; }
.dropdown-menu-end { left: auto; right: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-700);
  text-decoration: none;
  border-radius: var(--r-md);
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.dropdown-item:hover { background: var(--gray-100); color: var(--gray-900); }
.dropdown-item.active,
.dropdown-item:active { background: var(--brand-primary-light); color: var(--brand-primary); }

.dropdown-divider {
  height: 1px;
  background: var(--gray-100);
  border: none;
  margin: 4px 0;
}

/* ── 5. Bootstrap Collapse ────────────────────────────────────────────────── */
.collapse:not(.show) { display: none; }

.collapsing {
  height: 0;
  overflow: hidden;
  transition: height 300ms ease;
}

/* ── 6. Bootstrap Alert (flash messages) ──────────────────────────────────── */
.alert {
  position: relative;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-dismissible { padding-right: 40px; }
.alert-dismissible .btn-close {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Transitions Bootstrap (fade/show) */
.alert.fade  { opacity: 0; transition: opacity 200ms ease; }
.alert.show  { opacity: 1; }

/* Variants sémantiques */
.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #bbf7d0;
}
.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: #fecaca;
}
.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: #fde68a;
}
.alert-info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: #bfdbfe;
}
.alert-notice { /* Rails flash :notice → alias success */
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #bbf7d0;
}

/* ── 7. Bootstrap Grid minimal (utilisé dans _active_modal) ─────────────── */
.container-fluid {
  width: 100%;
  padding-left: 16px;
  padding-right: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -8px;
  margin-right: -8px;
}

/* Gutter shims */
.g-3  > * { padding: 8px; }
.g-2  > * { padding: 4px; }

.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-6  { flex: 0 0 50%;  max-width: 50%; }
.col-4  { flex: 0 0 33.333%; max-width: 33.333%; }
.col-3  { flex: 0 0 25%;  max-width: 25%; }

/* ── 8. Variants de boutons manquants ────────────────────────────────────── */

/* btn-warning — utilisé dans le widget timer (btn-warning) */
.btn-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: transparent;
}
.btn-warning:hover {
  background: #fde68a;
  color: var(--warning-text);
}

/* btn-success */
.btn-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: transparent;
}
.btn-success:hover {
  background: #bbf7d0;
  color: var(--success-text);
}

/* Outline variants */
.btn-outline-primary {
  background: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline-primary:hover {
  background: var(--brand-primary-light);
}

.btn-outline-secondary {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-300);
}
.btn-outline-secondary:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  border-color: var(--gray-400);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* ── 9. Formulaires Bootstrap ─────────────────────────────────────────────── */
.form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--gray-900);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--r-md);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(251, 118, 44, 0.15);
  outline: none;
}

.form-control::placeholder { color: var(--gray-400); }

.form-select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%239E9B94' d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}

.form-control-sm,
.form-select-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: var(--r-sm);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 1.5rem;
  padding-left: 0;
  margin-bottom: 4px;
}

.form-check-input {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--r-sm);
  background: #fff;
  cursor: pointer;
  appearance: none;
  transition: border-color var(--transition), background var(--transition);
}
.form-check-input[type="radio"] { border-radius: 50%; }
.form-check-input:checked {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.form-check-label {
  font-size: 13.5px;
  color: var(--gray-700);
  cursor: pointer;
}

/* ── 10. Badge couleurs Bootstrap (bg-*) ──────────────────────────────────── */
/* Bazyl .badge existe déjà dans _badges.css — on ajoute les variants bg-* */
.badge.bg-primary   { background: var(--brand-primary) !important; color: #fff; }
.badge.bg-success   { background: var(--success) !important;       color: #fff; }
.badge.bg-danger    { background: var(--danger) !important;        color: #fff; }
.badge.bg-warning   { background: var(--warning) !important;       color: #fff; }
.badge.bg-secondary { background: var(--gray-400) !important;      color: #fff; }
.badge.bg-info      { background: var(--info) !important;          color: #fff; }
.badge.bg-light     { background: var(--gray-100) !important;      color: var(--gray-700); }
.badge.bg-dark      { background: var(--brand-dark) !important;    color: #fff; }

/* ── 11. Card body (simple shim) ─────────────────────────────────────────── */
.card-body { padding: 16px; }

/* ── 12. Navbar collapse (top navbar) ─────────────────────────────────────── */
/* Bootstrap .navbar-* utilisé dans _top_navbar.html.slim */
.navbar-collapse { flex-basis: 100%; flex-grow: 1; align-items: center; }
.navbar-collapse.collapse:not(.show) { display: none; }
@media (min-width: 992px) {
  .navbar-collapse.collapse { display: flex !important; }
}
