/* ============================
   ДНЕВНИК ПРОГРЕССА — Progress Diary
   ============================ */

/* Кнопка дневника рядом с заметками */
#diaryBtn {
  position: absolute;
  right: 28px;
  top: -7px;
  font-size: 18px;
  /* background: none; */
  border: none;
  cursor: pointer;
  padding: 4px;
  z-index: 10;
  transition: transform 0.2s ease;
}
#diaryBtn:hover {
  transform: scale(1.15);
}
#diaryBtn .diary-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  border-radius: 50%;
  font-size: 9px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(245,87,108,.4);
  animation: diaryBadgePulse 2s ease-in-out infinite;
}
@keyframes diaryBadgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Панель дневника (выезжает справа) */
.diary-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 88vw);
  height: 100%;
  background: #f8f9fb;
  z-index: 1200;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
}
.diary-drawer.open {
  transform: translateX(0);
}

/* Оверлей */
.diary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.diary-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Шапка */
.diary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  flex-shrink: 0;
}
.diary-header-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.diary-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.diary-close:hover {
  background: rgba(255,255,255,0.35);
}

/* Контент */
.diary-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

/* Вкладки */
.diary-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.diary-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 4px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}
.diary-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.diary-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.diary-tab:not(.active):hover {
  background: #f3f4f6;
  color: #6b7280;
}
.diary-tab-icon {
  font-size: 15px;
}
.diary-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  position: absolute;
  top: 6px;
  right: 8px;
}
.diary-tab.active .diary-tab-dot {
  background: #fff;
}

/* Состояние: нет плана */
.diary-empty {
  text-align: center;
  padding: 40px 20px;
}
.diary-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.diary-empty-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-bottom: 8px;
}
.diary-empty-text {
  font-size: 14px;
  color: #888;
  line-height: 1.5;
  margin-bottom: 24px;
}
.diary-empty-roles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diary-role-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.diary-role-btn:hover {
  border-color: #667eea;
  box-shadow: 0 2px 12px rgba(102,126,234,0.15);
  transform: translateY(-1px);
}
.diary-role-btn:active {
  transform: translateY(0);
}
.diary-role-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.diary-role-info {
  flex: 1;
}
.diary-role-name {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}
.diary-role-desc {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

/* Карточка плана */
.diary-plan {
  animation: diaryFadeIn 0.4s ease;
}
@keyframes diaryFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.diary-plan-header {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.diary-plan-title {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  margin-bottom: 6px;
}
.diary-plan-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.diary-plan-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.diary-plan-badge.burnout {
  background: #f3e8ff;
  color: #7c3aed;
}
.diary-plan-badge.money {
  background: #fef3c7;
  color: #d97706;
}
.diary-plan-methodology {
  font-size: 12px;
  color: #888;
}

/* Прогресс бар */
.diary-progress {
  height: 8px;
  background: #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.diary-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 10px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.diary-progress-text {
  font-size: 12px;
  color: #888;
  text-align: right;
}

/* Шаги плана */
.diary-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diary-step {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.diary-step::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #e5e7eb;
  transition: background 0.3s ease;
}
.diary-step.completed::before {
  background: linear-gradient(180deg, #34d399, #10b981);
}
.diary-step.current::before {
  background: linear-gradient(180deg, #667eea, #764ba2);
  animation: stepPulse 2s ease-in-out infinite;
}
@keyframes stepPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.diary-step.completed {
  background: #f0fdf4;
}
.diary-step:hover:not(.completed) {
  box-shadow: 0 3px 12px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

.diary-step-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.diary-step-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s ease;
  font-size: 14px;
  color: transparent;
}
.diary-step.completed .diary-step-check {
  background: linear-gradient(135deg, #34d399, #10b981);
  border-color: #10b981;
  color: #fff;
}
.diary-step.current .diary-step-check {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}

.diary-step-info {
  flex: 1;
}
.diary-step-day {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.diary-step-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}
.diary-step.completed .diary-step-title {
  color: #6b7280;
  text-decoration: line-through;
  text-decoration-color: #34d399;
}
.diary-step-type {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f3f4f6;
  color: #6b7280;
  flex-shrink: 0;
}

/* Описание шага (раскрывается) */
.diary-step-desc {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 0 0 40px;
  font-size: 13px;
  line-height: 1.6;
  color: #6b7280;
}
.diary-step.expanded .diary-step-desc {
  max-height: 270px;
  padding: 8px 0 4px 40px;
}

/* Действия шага (Выполнено + Запиши) */
.diary-step-actions {
  display: none;
  margin-top: 10px;
  margin-left: 5px;
  gap: 8px;
  flex-wrap: wrap;
}
.diary-step.expanded:not(.completed) .diary-step-actions {
  display: flex;
}

.diary-step-complete-btn {
  padding: 8px 10px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.diary-step-complete-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

.diary-step-note-btn {
  padding: 8px 10px;
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.diary-step-note-btn:hover {
  background: #e5e7eb;
  color: #374151;
}

/* Область заметки */
.diary-step-note-area {
  margin-top: 10px;
  margin-left: 40px;
}
.diary-note-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 200px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #374151;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.diary-note-textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}
.diary-note-textarea::placeholder {
  color: #9ca3af;
}
.diary-note-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.diary-note-save {
  padding: 7px 18px;
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.diary-note-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(16,185,129,0.3);
}
.diary-note-cancel {
  padding: 7px 14px;
  background: none;
  color: #9ca3af;
  border: none;
  font-size: 12px;
  cursor: pointer;
}

/* Сохранённая заметка */
.diary-step-saved-notes {
  display: none;
  margin: 8px 0 0 40px;
  padding: 8px 12px;
  background: #f0f9ff;
  border-left: 3px solid #667eea;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  line-height: 1.5;
  color: #4b5563;
  word-break: break-word;
}
.diary-step.expanded .diary-step-saved-notes {
  display: block;
}
.diary-step-saved-notes b {
  color: #667eea;
}

/* Кнопки управления планом */
.diary-plan-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.diary-abandon-btn {
  padding: 8px 16px;
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.diary-abandon-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* Анимация выполнения шага */
@keyframes stepComplete {
  0% { transform: scale(1); }
  30% { transform: scale(1.05); }
  60% { transform: scale(0.98); }
  100% { transform: scale(1); }
}
.diary-step.just-completed {
  animation: stepComplete 0.5s ease;
}

/* Конфетти при завершении плана */
.diary-confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1300;
}

/* Модал завершения */
.diary-complete-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  z-index: 1250;
  animation: diaryFadeIn 0.3s ease;
}
.diary-complete-modal.active {
  display: flex;
}
.diary-complete-card {
  width: min(380px, 90vw);
  background: #fff;
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: diarySlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes diarySlideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
.diary-complete-icon {
  font-size: 56px;
  margin-bottom: 12px;
}
.diary-complete-title {
  font-size: 20px;
  font-weight: 700;
  color: #333;
  margin-bottom: 8px;
}
.diary-complete-text {
  font-size: 14px;
  color: #888;
  margin-bottom: 20px;
  line-height: 1.5;
}
.diary-feedback-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}
.diary-feedback-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(102,126,234,0.35);
}
.diary-skip-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
}

/* Загрузка */
.diary-loading {
  text-align: center;
  padding: 40px;
  color: #9ca3af;
}
.diary-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: diarySpin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes diarySpin {
  to { transform: rotate(360deg); }
}

/* Создание плана — загрузка */
.diary-creating {
  text-align: center;
  padding: 30px;
}
.diary-creating-icon {
  font-size: 40px;
  margin-bottom: 12px;
  animation: diaryBrain 2s ease-in-out infinite;
}
@keyframes diaryBrain {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-5deg); }
  75% { transform: scale(1.1) rotate(5deg); }
}
.diary-creating-text {
  font-size: 14px;
  color: #667eea;
  font-weight: 500;
}
.diary-creating-subtext {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 6px;
}

/* Мобайл */
@media (max-width: 480px) {
  .diary-drawer {
    width: min(380px, 88vw);
  }
  .diary-header {
    padding: 12px 16px;
  }
  .diary-content {
    padding: 12px;
  }
  .diary-step {
    padding: 12px 14px;
  }
  #diaryBtn {
    right: 28px;
  }
}
