/* === Main Structure === */
/* test */
main,
#main-content {
  padding: 1.5rem;
  padding-bottom: 140px; /* Pour éviter le footer */
  padding-top: 65px !important; /* Pour éviter l'entête */
  position: relative;
  overflow-y: auto;
  min-height: calc(100vh - 120px); /* Ajuste hauteur */
}

/* Assure que le contenu s’affiche bien */
#main-content {
  display: block;
  overflow-x: hidden;
}

.primary-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 10px 0 20px;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(120deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.primary-action-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(37, 99, 235, 0.2);
}

.primary-action-button:active {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}

.load-more-tasks-button {
  background: linear-gradient(120deg, #93c5fd, #60a5fa);
  color: #0f172a;
  box-shadow: 0 12px 24px rgba(96, 165, 250, 0.24);
}

.load-more-tasks-button:hover {
  box-shadow: 0 16px 28px rgba(96, 165, 250, 0.28);
}

.load-more-tasks-button:active {
  box-shadow: 0 10px 20px rgba(96, 165, 250, 0.24);
}

.dashboard-stable-plan-shell {
  background: #ffffff;
  border: 1px solid #d8e0da;
  border-radius: 8px;
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.dashboard-stable-plan-header {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashboard-stable-plan-header h2,
.dashboard-stable-plan-element h3 {
  color: #1d2b21;
  margin: 0;
}

.dashboard-stable-plan-header label {
  display: grid;
  gap: 0.3rem;
  font-weight: 700;
  min-width: 0;
  width: 100%;
}

.dashboard-stable-plan-date-controls {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
}

.dashboard-stable-plan-search-toggle.primary-action-button {
  margin: 0;
  padding: 0.55rem 1rem;
}

.dashboard-stable-plan-search {
  align-items: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
}

.dashboard-stable-plan-search[hidden] {
  display: none;
}

.dashboard-stable-plan-search .visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.dashboard-stable-plan-search input {
  border: 1px solid #c7d2cc;
  border-radius: 8px;
  font: inherit;
  min-height: 40px;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

.dashboard-stable-plan-search-submit.primary-action-button {
  margin: 0;
  min-height: 40px;
  padding: 0.45rem 1rem;
  width: 100%;
}

.dashboard-stable-plan-search-message {
  color: #52645a;
  font-weight: 700;
  margin: 0;
}

.dashboard-stable-plan-search-message:empty {
  display: none;
}

.dashboard-stable-plan-header select {
  border: 1px solid #c7d2cc;
  border-radius: 8px;
  font: inherit;
  min-height: 40px;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

.dashboard-stable-plan-date-label {
  color: #52645a;
  font-weight: 700;
  margin: 0;
}

.dashboard-stable-plan-element {
  display: grid;
  gap: 0.8rem;
}

.dashboard-stable-plan-element-title {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
}

.dashboard-stable-plan-element-title span {
  color: #52645a;
  font-size: 0.9rem;
}

.dashboard-stable-plan-animal-count {
  color: #2f4f3a;
  font-size: 0.88rem;
  font-weight: 700;
  margin: 0.25rem 0 0;
}

.dashboard-stable-plan-grid {
  --stable-plan-cell-size: minmax(28px, 1fr);
  background: #ffffff;
  display: grid;
  grid-template-columns: repeat(var(--stable-plan-cols), var(--stable-plan-cell-size));
  grid-template-rows: repeat(var(--stable-plan-rows), var(--stable-plan-cell-size));
  gap: 1px;
  overflow-x: auto;
  padding: 0.35rem;
  width: 100%;
}

.dashboard-stable-plan-block {
  align-items: center;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font: inherit;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  padding: 0.15rem;
  text-align: center;
}

.dashboard-stable-plan-block.has-animal-grid {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0.3rem;
  text-align: left;
}

.dashboard-stable-plan-block:disabled {
  cursor: default;
}

.dashboard-stable-plan-block.is-aisle {
  background: #d1d5db;
}

.dashboard-stable-plan-block.is-stall,
.dashboard-stable-plan-block.is-box,
.dashboard-stable-plan-block.is-group_area {
  background: #f8fafc;
  border: 1px solid #111827;
}

.dashboard-stable-plan-empty-label {
  color: #8b949e;
  font-size: 0.78rem;
  font-weight: 700;
}

.dashboard-stable-plan-animal {
  align-items: center;
  display: grid;
  gap: 0.12rem;
  justify-items: center;
  line-height: 1.05;
}

.dashboard-stable-plan-animal-stack {
  align-items: center;
  display: grid;
  gap: 0.15rem;
  justify-items: center;
}

.dashboard-stable-plan-animal-grid {
  align-content: flex-start;
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-start;
  width: 100%;
}

.dashboard-stable-plan-animal-grid .dashboard-stable-plan-animal,
.dashboard-stable-plan-animal-more {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  min-height: 1.35rem;
  padding: 0.16rem 0.42rem;
}

.dashboard-stable-plan-animal-more {
  color: #475569;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
}

.dashboard-stable-plan-animal strong {
  color: #111827;
  font-size: 0.82rem;
}

.dashboard-stable-plan-animal.is-clickable {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
  padding: 0.08rem 0.2rem;
}

.dashboard-stable-plan-animal.has-task-color {
  background: var(--stable-plan-animal-task-color);
  border-color: var(--stable-plan-animal-task-color);
}

.dashboard-stable-plan-block.is-search-highlighted,
.dashboard-stable-plan-animal.is-search-highlighted {
  animation: dashboard-stable-plan-search-pulse 1.15s ease-in-out infinite;
  border-color: #d4a900;
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.38);
}

@keyframes dashboard-stable-plan-search-pulse {
  0%, 100% {
    background: #ffffff;
  }
  50% {
    background: #fde768;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-stable-plan-block.is-search-highlighted,
  .dashboard-stable-plan-animal.is-search-highlighted {
    animation-duration: 2.5s;
  }
}

.dashboard-stable-plan-animal-grid .dashboard-stable-plan-animal.is-clickable {
  padding: 0.12rem 0.4rem;
}

.dashboard-stable-plan-task-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.12rem;
  justify-content: center;
}

.dashboard-stable-plan-task-dots i {
  border: 1px solid rgba(17, 24, 39, 0.45);
  border-radius: 999px;
  display: block;
  height: 7px;
  width: 7px;
}

@media (max-width: 720px) {
  .dashboard-stable-plan-grid {
    --stable-plan-cell-size: minmax(24px, 1fr);
  }
}

.event-panel-button-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-panel-back-actions {
  padding-top: 2rem;
}

.event-panel-placeholder {
  color: #475569;
  margin: 0 0 1rem;
}

.event-action-button {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(120deg, #2563eb, #4f46e5);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.event-action-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(37, 99, 235, 0.2);
}

.event-action-button:active {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}

.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.pill-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.18);
}

.pill-button:active {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
}

.pill-blue {
  background: linear-gradient(120deg, #2563eb, #4f46e5);
  color: #fff;
}

.pill-green {
  background: linear-gradient(120deg, #16a34a, #15803d);
  color: #fff;
}

.pill-red {
  background: linear-gradient(120deg, #dc2626, #b91c1c);
  color: #fff;
}

.pill-yellow {
  background: linear-gradient(120deg, #facc15, #eab308);
  color: #1f2937;
}

.calving-form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 0.5rem;
}

.calving-form-actions .pill-button {
  width: 100%;
}

.task-form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 0.5rem;
}

.task-form-actions .pill-button {
  width: 100%;
}

/* === Animal Cards === */

.animal-card {
  border: 1px solid #ccc;
  background-color: #fdfdfd;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.1s ease;
  cursor: pointer;
}

.animal-card:hover {
  transform: scale(1.01);
  background-color: #fefeff;
}

.animal-card h3 {
  margin-top: 0;
  font-size: 1.2rem;
}

.animal-card .metadata {
  font-size: 0.9rem;
  color: #666;
}

#animal-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* === Loader === */

.loader {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 10px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* === Cow Profile Panel === */

#cow-profile {
position: fixed; /* 🚀 reste fixé dans la fenêtre */
top: 65px; /* 📏 respecter la topbar */
right: 0;
width: 100%;
max-width: 400px;
height: calc(100vh - 65px - 60px); /* 🌟 Hauteur totale - topbar - footer */
background: #fff;
box-shadow: -2px 0 5px rgba(0,0,0,0.2);
overflow-y: auto; /* 🚀 scrolle seulement à l’intérieur du panneau */
z-index: 10;
transform: translateX(100%);
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
opacity: 0;
visibility: hidden;
padding-bottom: 120px; /* 📦 espace pour voir les boutons même en bas */
}

/* Cow-profile ouvert */
#cow-profile.open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}

/* Bouton de fermeture du Cow Profile */
#cow-profile .close-btn {
  position: fixed; /* Corrigé pour éviter d'être masqué */
  top: 70px; /* Juste sous ton header */
  right: 20px;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #333;
  z-index: 999; /* Plus haut que tout */
}

#cow-profile .close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
}
/* Pour le modal overlay */
#overlay-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

#overlay-modal.visible {
  opacity: 1;
  pointer-events: all;
}
#task-panel {
  position: fixed;
  top: 65px;
  right: 0;
  width: 100%;
  max-width: 400px;
  height: calc(100vh - 65px - 60px);
  background: #fff;
  box-shadow: -2px 0 5px rgba(0,0,0,0.2);
  overflow-y: auto;
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
  opacity: 0;
  visibility: hidden;
  padding-bottom: 120px;
}

#task-panel.open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}

#task-panel .close-btn {
  position: fixed;
  top: 70px;
  right: 20px;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #333;
  z-index: 999;
}

#task-panel .close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
}
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.settings-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-main {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 120px;
}

.settings-hero {
  text-align: center;
  margin-bottom: 0.5rem;
}

.settings-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.settings-card h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.settings-card p {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #475569;
}

.settings-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-card label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #0f172a;
}

.settings-card input,
.settings-card select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid #cbd5f5;
  font-size: 1rem;
  background-color: #f8fafc;
}

.settings-card button {
  align-self: flex-start;
  padding: 0.65rem 1.5rem;
  background: linear-gradient(120deg, #2563eb, #4f46e5);
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.settings-card button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-field label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}

.danger-zone {
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(254, 226, 226, 0.4);
}

.danger-zone .danger-button {
  background: #dc2626;
}

.members-placeholder {
  padding: 1rem;
  border-radius: 8px;
  background: #f1f5f9;
  text-align: center;
  color: #475569;
}

#animal-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

/* === Inventory Mobile Tweaks === */
@media (max-width: 480px) {
  #add-lot-btn {
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: normal; /* autorise le retour à la ligne */
  }

  .semen-table th,
  .semen-table td {
    padding: 10px 6px;
  }
}

/* === Tab Panels === */
.page-intro {
  margin-bottom: 1.5rem;
}

.page-intro p {
  color: #475569;
  margin: 0.4rem 0 0;
}

.tab-panel {
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.tab-panel__list {
  display: flex;
  gap: 0;
  padding: 0 0.5rem;
  margin: 0;
  background: #e2e8f0;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  align-items: stretch;
  touch-action: pan-x;
  cursor: grab;
}

.tab-panel__tab {
  flex: 0 0 auto;
  border: none;
  background: #e2e8f0;
  color: #475569;
  font-weight: 600;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  border-bottom: 3px solid transparent;
  min-height: 4.5rem;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
  scroll-snap-align: start;
}

.tab-panel__tab-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  text-align: center;
  width: 100%;
}

.tab-panel__tab-text span {
  display: block;
}

.tab-panel__list--dragging {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

.tab-panel__tab + .tab-panel__tab {
  border-left: 1px solid rgba(148, 163, 184, 0.8);
}

.tab-panel__tab.active {
  background: #fff;
  color: #0f172a;
  border-bottom-color: #2563eb;
}

.tab-panel__tab:not(.active):hover {
  background: #cbd5f5;
}

.tab-panel__tab:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -4px;
}

.tab-panel__content {
  display: none;
  padding: 1.75rem;
}

.tab-panel__content.active {
  display: block;
}

.tab-panel__header h2 {
  margin: 0 0 0.35rem;
}

.tab-panel__header p {
  margin: 0 0 1rem;
  color: #475569;
}

.tab-panel__placeholder {
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  background: #f8fafc;
  color: #475569;
}

.table-card {
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 14px;
  overflow: hidden;
}

.calving-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.calving-table thead {
  background: #0f172a;
  color: #fff;
}

.calving-table th,
.calving-table td {
  padding: 0.9rem 1rem;
  text-align: left;
}

.calving-table tbody tr:nth-child(odd) {
  background: #fff;
}

.calving-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.calving-table tbody td {
  border-bottom: 2px solid #0f172a;
}

.calving-table tbody tr:last-child td {
  border-bottom: none;
}

.calving-table tbody tr:hover td {
  background: #e0f2fe;
}

.row-with-actions {
  position: relative;
  overflow: hidden;
  --row-actions-width: 130px;
  touch-action: pan-y;
}

.row-with-actions .row-actions {
  right: 0;
}

.row-with-actions > td {
  padding-right: 1rem;
  transition: transform 0.2s ease;
  will-change: transform;
}

.row-actions-dragging {
  user-select: none;
}

.row-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  min-width: var(--row-actions-width);
  background: linear-gradient(90deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.08) 24%, rgba(15, 23, 42, 0.12) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.row-actions-visible .row-actions {
  opacity: 1;
  pointer-events: auto;
}

.row-actions-visible > td {
  transform: translateX(calc(-1 * var(--row-actions-width)));
}

.row-action-btn {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
  transition: transform 0.1s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.row-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.28);
  background: #1d4ed8;
}

.row-action-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.22);
}

.row-inline-edit {
  padding: 6px 10px;
  font-size: 0.85rem;
  line-height: 1.2;
}

.action-header {
  background: #0f172a;
}

.service-edit-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.service-edit-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.service-summary {
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: #0f172a;
}

.table-placeholder {
  text-align: center;
  font-style: italic;
  color: #475569;
}

.table-placeholder.error {
  color: #dc2626;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  background: linear-gradient(120deg, #16a34a, #22c55e);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  margin-top: 1rem;
  border: none;
  cursor: pointer;
}

.button-link:hover {
  opacity: 0.9;
}

.table-actions {
  display: flex;
  justify-content: center;
  padding: 1rem;
  gap: 0.5rem;
}

.load-more-btn[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .tab-panel {
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
  }

  .tab-panel__content {
    padding: 1.25rem;
  }

  .table-card {
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
}
