/* ---------------------------------------------------
   RESET & BASE
--------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", Helvetica, Arial, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------------------------------------------------
   TOP BAR
--------------------------------------------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.current-date {
  font-size: 0.9rem;
  color: #6b7280;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
}

.btn.primary {
  background: #2563eb;
  color: white;
}

.btn.danger {
  background: #b91c1c;
  color: white;
}

.btn.small {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Button icons */
.icon-btn {
  background: white;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.icon-btn:hover {
  transform: scale(1.05);
}

/* ---------------------------------------------------
   CALENDAR STRIP (BANDEAU)
--------------------------------------------------- */
.calendar-area {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.calendar-strip {
  flex: 1;
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  padding: 8px;
  gap: 8px;
  scroll-snap-type: x mandatory;
  background: white;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.calendar-day {
  flex: 0 0 auto;
  scroll-snap-align: center;
  min-width: 52px;
  text-align: center;
  padding: 6px 4px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #4b5563;
  position: relative;
}

.calendar-day .dow {
  display: block;
  font-weight: 500;
}

.calendar-day .num {
  display: block;
  font-size: 1rem;
}

.calendar-day.selected {
  background: #2563eb;
  color: white;
}

/* Point rouge dans bandeau */
.calendar-day .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  position: absolute;
  right: 6px;
  top: 6px;
}

.calendar-day .dot-active {
  background: #e11d48;
}

/* Colonne à droite du bandeau (icône + bouton Today) */
.calendar-side-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.today-btn {
  padding-inline: 10px;
}

/* ---------------------------------------------------
   TASK LIST
--------------------------------------------------- */
.main h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.task-checkbox {
  margin-top: 4px;
}

.task-title {
  font-size: 0.95rem;
  margin: 0;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 2px;
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: #9ca3af;
}

.task-item.completed {
  opacity: 0.7;
}

.completion-info {
  font-size: 0.8rem;
  color: #374151;
}

/* ---------------------------------------------------
   ADMIN PANEL
--------------------------------------------------- */
.admin-panel {
  margin-top: 24px;
  padding: 16px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.admin-content {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-users {
  flex: 2;
  min-width: 260px;
}

.admin-add-user {
  flex: 1;
  min-width: 220px;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.user-table th,
.user-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
}

.user-table th {
  text-align: left;
  background: #f9fafb;
}

/* ---------------------------------------------------
   FORMS & MODALS
--------------------------------------------------- */
.hidden {
  display: none !important;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.form-row label {
  font-size: 0.85rem;
  color: #4b5563;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="date"],
.form-row input[type="number"] {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  font-size: 0.9rem;
}

.weekday-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 16px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

#deleteRecurringModal .modal-content {
  max-width: 350px;
  text-align: center;
}

#deleteRecurringModal .modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 15px 0;
}

/* ---------------------------------------------------
   FULL CALENDAR (POPUP)
--------------------------------------------------- */
.fullcal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#fullCalTitle {
  margin: 0;
  font-size: 1rem;
  text-transform: capitalize;
}

.nav-btn {
  background: #e5e7eb;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #374151;
  padding: 4px 10px;
  border-radius: 999px;
  transition: background 0.2s, transform 0.1s;
}

.nav-btn:hover {
  background: #d1d5db;
  transform: scale(1.05);
}

.fc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.fc-weekday {
  font-weight: 600;
  text-align: center;
  padding: 4px 0;
  font-size: 0.8rem;
  color: #4b5563;
}

.fc-day {
  position: relative;
  background: white;
  border-radius: 6px;
  text-align: center;
  padding: 6px 0;
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 42px;
}

.fc-day:hover {
  background: #e5e7eb;
}

.fc-day.out-month {
  background: #f5f5f5;
  color: #9ca3af;
  cursor: default;
}

/* Aujourd’hui */
.fc-day.today {
  border: 2px solid #2563eb;
}

/* Sélection */
.fc-day.selected {
  background: #2563eb !important;
  color: white !important;
}

/* Assure que la position absolue fonctionne */
.fc-inner {
  position: relative;
}

/* Point rouge dans le coin supérieur droit */
.fc-inner .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  position: absolute;
  top: 2px;
  right: 6px;
}

.fc-inner .dot-active {
  background: #e11d48;
}

.fc-num {
  display: block;
  font-size: 0.9rem;
}

.task-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  margin-left: auto;
  padding: 4px;
  opacity: 0.6;
}

.task-delete-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* Jour actuel (comme sélectionné, mais fond transparent) */
.calendar-day.today {
  border: 2px solid #3b82f6;
  border-radius: 50%;
  padding: 6px;
  background-color: transparent;
  color: inherit;
}

/* Jour sélectionné */
.calendar-day.selected {
  border: 2px solid #3b82f6;
  border-radius: 50%;
  padding: 6px;
  background-color: #3b82f6;
  color: #fff;
}

/* ---------------------------------------------------
   PIN MODAL / KEYPAD iPHONE
--------------------------------------------------- */
#pinModal .modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-dots {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 20px 0 10px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid #111;
}

.pin-dot.filled {
  background: #111;
}

/* Keypad iOS */
.iphone-keypad {
  margin-top: 25px;
  display: grid;
  grid-template-columns: repeat(3, 90px);
  gap: 18px;
  justify-content: center;
}

/* Boutons iOS */
.iphone-keypad button {
  height: 90px;
  width: 90px;
  border-radius: 50%;
  background: #e6e7eb;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  border: none;

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Helvetica, Arial, sans-serif;
  font-weight: 500;
  font-size: 32px;
  color: #111;

  display: flex;
  justify-content: center;
  align-items: center;

  user-select: none;
  -webkit-user-select: none;
  -webkit-text-fill-color: #111 !important;
  -webkit-tap-highlight-color: transparent;

  transition: transform 0.12s ease, background 0.12s ease;
}

/* Effet pressé */
.iphone-keypad button:active {
  transform: scale(0.92);
  background: #d4d5d9;
}

/* Bouton OK — style iOS */
.iphone-keypad button.primary {
  font-weight: 600;
  font-size: 26px;
}

/* Icône delete */
.delete-icon {
  width: 34px;
  height: 34px;
  display: block;
  fill: #111;
  transform: translate(-1px, 2px); /* (X, Y) → un peu à droite + un peu en bas */
}

/* Bouton Annuler sous le keypad */
#pinCancelBtn {
  margin-top: 28px;
  display: block;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* MODALE HISTORIQUE */
#historyModal .modal-content {
  width: 95%;
  max-width: 900px;
  max-height: 85vh;
  overflow: auto;
  padding: 20px;
}

.history-container {
  margin-top: 20px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.history-table th {
  text-align: left;
  background: #f3f4f6;
  padding: 8px;
  border-bottom: 2px solid #ddd;
}

.history-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.history-table tr:nth-child(even) {
  background: #fafafa;
}

.close-btn {
  float: right;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

.btn.secondary {
  background: #e5e7eb;
  color: #111;
}

#btnHistory {
  display: none;
}



/* ---------------------------------------------------
   RESPONSIVE
--------------------------------------------------- */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-area {
    flex-direction: column;
    align-items: stretch;
  }

  .calendar-side-controls {
    flex-direction: row;
    justify-content: flex-end;
  }

  .admin-content {
    flex-direction: column;
  }

  .iphone-keypad {
    grid-template-columns: repeat(3, 70px);
    gap: 12px;
  }

  .iphone-keypad button {
    width: 70px;
    height: 70px;
    font-size: 24px;
  }
}
