:root {
  --duration: 0.6s;
  --book-w: 350px;
  --book-h: 500px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-family: "Kalam", cursive;
  overflow-x: hidden;
  padding: 20px;
}

/* ===== HEADER & CONTROLS ===== */
.header {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 15px 25px;
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  margin-bottom: 20px;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-selector select,
.month-selector input {
  padding: 10px 15px;
  font-size: 1rem;
  border: 2px solid #667eea;
  border-radius: 8px;
  font-family: "Kalam", cursive;
  cursor: pointer;
}

.month-selector select:focus,
.month-selector input:focus {
  outline: none;
  border-color: #764ba2;
}

.current-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-family: "Kalam", cursive;
  transition: transform 0.2s, box-shadow 0.2s;
}

.current-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* ===== ARCHIVE BADGE ===== */
.archive-badge {
  background: #ff6b6b;
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  display: none;
}

.archive-badge.visible {
  display: inline-block;
}

/* ===== INDICATORS ===== */
.indicators {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
}

.page-indicator,
.date-indicator {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

/* ===== BOOK CONTAINER ===== */
.book-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 520px;
  width: 100%;
}

.book {
  position: relative;
  width: var(--book-w);
  height: var(--book-h);
  transition: transform 0.5s;
}

/* ===== PAPER & PAGES ===== */
.paper {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  perspective: 1500px;
}

.content {
  position: absolute;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--duration) cubic-bezier(0.25, 1, 0.5, 1);
  transform-origin: left top;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  border-radius: 5px;
}

.front,
.back {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #fdfbf7;
  backface-visibility: hidden;
  padding: 20px 20px 50px 50px;

  background-image: linear-gradient(
      90deg,
      transparent 39px,
      #ff9999 39px,
      #ff9999 41px,
      transparent 41px
    ),
    linear-gradient(#e1e1e1 1px, transparent 1px);
  background-size: 100% 100%, 100% 30px;
}

.back {
  transform: rotateY(180deg);
  padding: 20px 50px 50px 20px;
  background-image: linear-gradient(
      90deg,
      transparent calc(100% - 41px),
      #ff9999 calc(100% - 41px),
      #ff9999 calc(100% - 39px),
      transparent calc(100% - 39px)
    ),
    linear-gradient(#e1e1e1 1px, transparent 1px);
}

.flipped .content {
  transform: rotateY(-180deg);
}

/* ===== COVERS ===== */
.front-cover {
  background: var(--cover-color, #2c3e50) !important;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 3px solid rgba(255, 255, 255, 0.3);
  background-image: none !important;
  text-align: center;
}

.front-cover h2 {
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 15px 25px;
  margin: 0;
  font-size: 1.5rem;
}

.front-cover .year {
  margin-top: 15px;
  font-size: 1.2rem;
  opacity: 0.8;
}

.back-cover {
  background: var(--cover-color, #2c3e50) !important;
  background-image: none !important;
}

/* ===== PAGE CONTENT ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px dashed #ccc;
}

.page-date {
  font-size: 0.95rem;
  color: #666;
  font-weight: bold;
}

.page-day {
  font-size: 0.85rem;
  color: #888;
  text-transform: capitalize;
}

.page-number {
  position: absolute;
  bottom: 15px;
  font-size: 0.9rem;
  color: #666;
}

.front .page-number {
  right: 20px;
}

.back .page-number {
  left: 20px;
}

/* ===== TEXTAREA ===== */
textarea {
  width: 100%;
  height: calc(100% - 50px);
  background: transparent;
  border: none;
  resize: none;
  font-family: "Kalam", cursive;
  font-size: 1.1rem;
  line-height: 30px;
  outline: none;
  color: #333;
  overflow: hidden; /* Désactiver le scroll */
}

textarea:disabled {
  color: #333;
  cursor: default;
}

/* ===== NAVIGATION BUTTONS ===== */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 15px 20px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  font-size: 1.2rem;
  transition: all 0.2s;
  z-index: 100;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.nav-btn:hover:not(:disabled) {
  background: white;
  transform: translateY(-50%) scale(1.1);
}

.nav-btn.next {
  right: 10px;
}

.nav-btn.prev {
  left: 10px;
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ===== ARCHIVES PANEL ===== */
.archives-panel {
  position: fixed;
  top: 0;
  right: -350px;
  width: 350px;
  height: 100%;
  background: white;
  box-shadow: -5px 0 20px rgba(0, 0, 0, 0.2);
  transition: right 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

.archives-panel.open {
  right: 0;
}

.archives-header {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.archives-header h3 {
  margin: 0;
}

.close-archives {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.archives-list {
  padding: 15px;
}

.archive-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  margin-bottom: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.archive-item:hover {
  background: #e9ecef;
  transform: translateX(-5px);
}

.archive-item.current {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.archive-item .month-name {
  font-weight: bold;
}

.archive-item .entries-count {
  font-size: 0.85rem;
  opacity: 0.7;
}

.toggle-archives {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-family: "Kalam", cursive;
  font-size: 1rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  z-index: 500;
  transition: all 0.2s;
}

.toggle-archives:hover {
  transform: scale(1.05);
}

/* ===== MONTH COLORS ===== */
.month-1 {
  --cover-color: #3498db;
} /* Janvier - Bleu */
.month-2 {
  --cover-color: #e91e63;
} /* Février - Rose */
.month-3 {
  --cover-color: #4caf50;
} /* Mars - Vert */
.month-4 {
  --cover-color: #ff9800;
} /* Avril - Orange */
.month-5 {
  --cover-color: #9c27b0;
} /* Mai - Violet */
.month-6 {
  --cover-color: #00bcd4;
} /* Juin - Cyan */
.month-7 {
  --cover-color: #f44336;
} /* Juillet - Rouge */
.month-8 {
  --cover-color: #ff5722;
} /* Août - Orange foncé */
.month-9 {
  --cover-color: #795548;
} /* Septembre - Marron */
.month-10 {
  --cover-color: #607d8b;
} /* Octobre - Gris bleu */
.month-11 {
  --cover-color: #673ab7;
} /* Novembre - Violet foncé */
.month-12 {
  --cover-color: #1a237e;
} /* Décembre - Bleu nuit */

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  :root {
    --book-w: 300px;
    --book-h: 420px;
  }

  .header {
    padding: 10px 15px;
  }

  .nav-btn {
    padding: 10px 15px;
  }

  .archives-panel {
    width: 100%;
    right: -100%;
  }

  .indicators {
    flex-direction: column;
    gap: 10px;
  }
}
