/* General style for the table */
.database-table {
  width: 95%; /* Table width */
  margin: 20px auto; /* Horizontal centering */
  border-collapse: collapse; /* Collapse borders */
  text-align: center; /* Center text in cells */
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #fff; /* White background */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow */
  border-radius: 8px; /* Rounded borders */
  overflow: hidden;
}

/* Table headers and cells */
.database-table th,
.database-table td {
  padding: 5px 5px;
  border: 1px solid #ddd;
}

/* Table header */
.database-table th {
  background-color: #f2f2f2;
  font-weight: bold;
  color: #333;
  padding: 10px;
}

/* Alternate rows */
.database-table tr:nth-child(even) {
  background-color: #fafafa;
}

/* Hover effect on rows */
.database-table tr:hover {
  background-color: #f1f1f1;
}

/* Style for buttons inside the table */
.database-table .btn-standard {
  padding: 8px 8px; /* Less horizontal padding (between text and borders) */
  font-size: 1rem; /* Keep the text small if needed */
  cursor: pointer;
  border: none;
  color: white;
  border-radius: 8px;
  transition: background-color 0.3s ease;
  max-width: 120px; /* Maximum width in pixels */
  width: 100%;
}

.database-table th.id-col,
.database-table td.id-col {
  width: 50px; /* Adjust as needed */
  max-width: 50px;
  min-width: 50px;
  text-align: center; /* Optional */
}

.database-table th.action-col,
.database-table td.action-col {
  width: 50px; /* Adjust as needed */
  max-width: 50px;
  min-width: 50px;
  text-align: center; /* Optional */
}

.database-table th.champ-col,
.database-table td.champ-col {
  width: 300px; /* Adjust as needed */
  max-width: 400px;
  min-width: 400px;
  text-align: center; /* Optional */
}

.database-table th.day-col,
.database-table td.day-col {
  width: 110px;
  max-width: 110px;
  min-width: 110px;
  text-align: center;
}

.database-table td.hour-col {
  font-weight: 600;
  color: #2980b9;
  text-align: center;
}

/* ===== DESKTOP STYLES (default) ===== */

.database-table th.note-col,
.database-table td.note-col {
  width: 400px;
  max-width: 500px;
  min-width: 400px;
  text-align: center;
  vertical-align: top;
  word-wrap: break-word;
  white-space: normal;
  overflow-wrap: break-word;
}

.database-table td.note-col {
  text-align: left;
  padding: 10px;
  vertical-align: top;
}

.database-table .note-item {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 15px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.database-table .note-header {
  display: block;
  margin-bottom: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

.database-table .note-header strong {
  font-weight: bold;
  display: block;
  white-space: normal;
}

.database-table .note-content {
  margin-top: 0;
  padding-top: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ===== MOBILE STYLES ===== */

@media (max-width: 767px) {
  .database-table {
    display: block;
    width: 95%;
    overflow-x: auto;
    box-shadow: none;
  }

  .database-table thead {
    display: none;
  }

  .database-table tbody,
  .database-table tr,
  .database-table td {
    display: block;
    width: 95%;
    margin: auto;
    text-align: center;
  }

  .database-table tr {
    margin-bottom: 1.5rem;
    background: #fff;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
  }

  .database-table td {
    padding: 10px;
    border: none;
    border-bottom: 1px solid #eee;
  }

  .database-table td:last-child {
    border-bottom: none;
  }

  .database-table td::before {
    content: none !important;
  }

  /* Note column and content */
  .database-table th.note-col,
  .database-table td.note-col {
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
    text-align: center;
    padding: 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    box-sizing: border-box;
  }

  .database-table .note-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    word-break: break-word;
  }

  .database-table .note-header,
  .database-table .note-content {
    width: 100%;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    display: block;
    box-sizing: border-box;
  }

  .database-table .note-header strong {
    display: block;
    font-weight: bold;
  }
}

/* ===== TABLET STYLES ===== */

@media (min-width: 768px) and (max-width: 1024px) {
  .database-table {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    width: 95%;
    margin: auto;
    border: none;
    box-shadow: none;
    background: none;
    margin-top: 10px;
  }

  .database-table thead {
    display: none;
  }

  .database-table tbody {
    display: contents;
  }

  .database-table tr {
    display: block;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    margin: 0;
    width: 100%;
  }

  .database-table td {
    display: block;
    width: 100%;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 10px;
    text-align: center;
    box-sizing: border-box;
    word-wrap: break-word;
    white-space: normal;
  }

  .database-table tbody,
  .database-table tr,
  .database-table td {
    text-align: center;
  }

  .database-table td:last-child {
    border-bottom: none;
  }

  .database-table td::before {
    content: none !important;
  }

  /* ===== Notes responsive inside tablet view ===== */
  .database-table th.note-col,
  .database-table td.note-col {
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
    text-align: center;
    padding: 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    box-sizing: border-box;
  }

  .database-table .note-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .database-table .note-header,
  .database-table .note-content {
    display: block;
    width: 100%;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
  }

  .database-table .note-header strong {
    display: block;
    font-weight: bold;
  }
}

@media (max-width: 1024px) {
  /* Select the last few td cells inside a row — assuming 1 button per cell */
  .database-table tr {
    display: block;
  }

  .database-table tr td:nth-last-child(-n + 3) {
    display: inline-block;
    width: auto;
    padding: 5px;
    border: none;
  }

  .database-table tr td:nth-last-child(-n + 3) form {
    display: inline-block;
    margin: 5px;
  }

  .database-table tr td:nth-last-child(-n + 3) .btn-standard {
    display: inline-block;
    min-width: 20px;
    padding: 6px 10px;
    font-size: 0.9rem;
  }
}

@media (max-width: 1024px) {
  /* Step 1: Stack the full row if it contains a toggle group */
  .database-table tr:has(.toggle-group-cell) {
    display: block;
    margin-bottom: 1.5rem;
    background: #fff;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
  }

  .database-table tr:has(.toggle-group-cell) td {
    display: block;
    width: 100%;
    border: none;
    border-bottom: 1px solid #eee;
    padding: 10px;
    text-align: center;
    box-sizing: border-box;
  }

  .database-table tr:has(.toggle-group-cell) td:last-child {
    border-bottom: none;
  }

  .database-table tr:has(.toggle-group-cell) td::before {
    content: none !important;
  }

  /* Step 2: Make button/toggle containers wrap properly */
  .database-table tr:has(.toggle-group-cell) td,
  .database-table tr:has(.toggle-group-cell) td > div,
  .database-table tr:has(.toggle-group-cell) td > form,
  .database-table tr:has(.toggle-group-cell) td > .toggle-group-cell {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
  }

  /* Step 3: Button and toggle sizing */
  .database-table tr:has(.toggle-group-cell) .btn-standard,
  .database-table tr:has(.toggle-group-cell) .table-toggle {
    flex: 1 1 auto;
    max-width: 100px;
    min-width: 30px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .database-table:has(.toggle-group-cell) {
    display: block !important;
  }
}

.pastel-red-row {
  background-color: #f3b4b4;
}

/* Container cell alignment */
.toggle-cell {
  text-align: center;
  vertical-align: middle;
}

/* New class for grouping the toggles in a single row */
.toggle-group-cell {
  display: flex;
  justify-content: space-around; /* Center the toggles horizontally */
  gap: 5px; /* Space between the toggles */
  align-items: center; /* Align them vertically */
  margin-bottom: 10px;
}

/* Toggle switch base */
.table-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 18px;
}

.table-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* Slider track and knob */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: background-color 0.2s ease;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: transform 0.2s ease;
  border-radius: 50%;
}

/* Checked state */
.table-toggle input:checked + .slider {
  background-color: var(--color-primary, #4caf50);
}

.table-toggle input:checked + .slider:before {
  transform: translateX(18px);
}

/* Container for working hours */
.database-table td.working-hours-cell {
  padding: 15px;
}

/* List container for working slots */
.database-table td.working-hours-cell ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Each day entry appears on a single horizontal row */
.database-table td.working-hours-cell ul li {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: #f9f9f9;
  padding: 10px 12px;
  border-radius: 8px;
  flex-wrap: wrap; /* Allows wrap on small screens */
  justify-content: space-around;
}

/* Weekday label (e.g., Lundi) */
.database-table td.working-hours-cell .weekday {
  font-weight: bold;
  color: #333;
  font-size: 0.95rem;
  min-width: 70px;
}

/* Labels for Début, Fin, Durée */
.database-table td.working-hours-cell .slot-label {
  color: #555;
  font-size: 0.85rem;
}

/* Input fields */
.database-table td.working-hours-cell input {
  padding: 6px 10px;
  font-size: 0.9rem;
  width: 100px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

/* Message when no schedule is defined */
.database-table td.working-hours-cell em {
  color: #888;
  font-style: italic;
  padding: 5px;
  display: block;
  text-align: center;
}

/* Disable hover effect for no-hover table */
.database-table.no-hover tr:hover {
  background-color: inherit !important;
}

/* === Bigger Stylish Green Table Checkbox === */

.check-cell {
  text-align: center;
  vertical-align: middle;
  padding: 12px;
  position: relative;
}

/* Wrapper for checkbox */
.table-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

/* Hide native checkbox */
.table-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  cursor: pointer;
}

/* Custom checkbox box */
.checkmark {
  display: inline-block;
  width: 26px;
  height: 26px;
  background-color: #f0f0f0;
  border: 2px solid #ccc;
  border-radius: 6px;
  transition: all 0.1s ease-in-out;
  box-sizing: border-box;
  position: relative;
}

/* Checked state – green background */
.table-check input:checked ~ .checkmark {
  background-color: #39aa99;
  border-color: #39aa99;
}

/* Checkmark tick hidden by default */
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

/* Show tick when checked */
.table-check input:checked ~ .checkmark:after {
  display: block;
}

/* Tick shape */
.checkmark:after {
  left: 8px;
  top: 5px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.database-table td.working-hours-cell .delete-btn {
  margin-left: auto;
  margin-right: 10px;
}

/* Beautified inline-edit inputs */
.database-table input.inline-edit {
  padding: 6px 10px;
  font-size: 0.9rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  width: 100%;
  max-width: 180px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
  background-color: #fefefe;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.database-table input.inline-edit:focus {
  border-color: #4caf50;
  outline: none;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

/* Layout wrapper */
.holiday-color-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 5px;
}

/* Color display box */
.color-box {
  width: 24px;
  height: 24px;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Color input styling */
.color-picker {
  width: 36px;
  height: 36px;
  border: 2px solid #ccc;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  background: none;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Add this class for hidden but interactive color picker */
.color-picker-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Utility class for hiding elements */
.d-none {
  display: none;
}
