/* === Variáveis Globais === */
:root {
  --cor-primaria: #f9c74f;    /* amarelo */
  --cor-secundaria: #90be6d;  /* verde */
  --cor-terciaria: #f9844a;   /* laranja */
  --cor-fundo: #f9fff5;
  --cor-texto: #2c6130;
  --font-family: 'Comic Sans MS', cursive, sans-serif;
}

/* === Reset Básico === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #e4f0d9, #d4ead6);
  color: var(--cor-texto);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

/* === Header === */
header {
  width: 100%;
  max-width: 950px;
  text-align: center;
  margin-bottom: 2rem;
}

h1 {
  font-family: var(--font-family);
  font-size: 3rem;
  color: var(--cor-secundaria);
  text-shadow: 0 0 5px #90be6d88;
  animation: brilho 3.5s ease-in-out infinite;
}

/* === Container Principal === */
main {
  width: 100%;
  max-width: 950px;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
}

/* === Calendário === */
.calendar-container {
  background: var(--cor-fundo);
  border-radius: 30px;
  padding: 2rem 2.5rem 3rem 2.5rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 700px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.calendar-header button {
  background-color: var(--cor-secundaria);
  border: none;
  border-radius: 18px;
  color: white;
  font-weight: 700;
  font-size: 1.5rem;      /* reduzido para melhor mobile */
  padding: 0.3rem 1rem;   /* mais compacto */
  cursor: pointer;
  box-shadow: 0 4px 12px #6e8f4570;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.calendar-header button:hover,
.calendar-header button:focus {
  background-color: var(--cor-terciaria);
  outline: none;
  transform: scale(1.05);
}

#monthYear {
  font-size: 1.8rem;      /* reduzido para mobile */
  font-weight: 900;
  color: var(--cor-secundaria);
  text-shadow: 0 0 5px #90be6d66;
}

/* === Tabela do Calendário === */
.calendar {
  width: 100%;
  border-collapse: separate;
  border-spacing: 6px;     /* espaçamento um pouco menor */
  text-align: center;
  user-select: none;
}

.calendar th {
  font-weight: 900;
  font-size: 1.1rem;      /* menor no mobile */
  color: var(--cor-secundaria);
  padding-bottom: 0.5rem;
  text-shadow: 0 0 4px #90be6d55;
}

.calendar td {
  width: 14.28%;
  padding: 0.8rem 0;      /* mais compacto */
  font-weight: 700;
  font-size: 1rem;        /* menor para caber melhor */
  border-radius: 20px;
  cursor: pointer;
  background-color: #d7f3be;
  box-shadow: inset 0 2px 6px rgba(42,98,25,0.2);
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.15s ease;
  color: #2a5c1a;
  user-select: none;
}

.calendar td:hover,
.calendar td:focus {
  background-color: var(--cor-terciaria);
  color: white;
  box-shadow: 0 0 12px 5px #f9844aaa;
  outline: none;
  transform: scale(1.05);
}

.calendar td.inactive {
  color: #9dbba3;
  background-color: transparent;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.calendar td.today {
  border: 3px solid var(--cor-secundaria);
  font-weight: 900;
  box-shadow: 0 0 10px 3px #90be6dbb;
}

.calendar td.event {
  background-color: var(--cor-secundaria);
  font-weight: 900;
  box-shadow: 0 0 10px 3px #90be6dbb inset;
  color: white;
}

.calendar td.has-diary {
  background-color: var(--cor-primaria);
  color: #443e00;
  box-shadow: 0 0 12px 4px #f9c74faa inset;
}

.calendar td.selected {
  background-color: var(--cor-terciaria);
  color: white;
  box-shadow: 0 0 15px 6px #f9844aaa;
}

/* === Painéis Inferiores === */
.bottom-panels {
  margin-top: 3rem;
  display: flex;
  gap: 1.5rem;  /* gap menor para mobile */
  justify-content: space-between;
  flex-wrap: wrap;
}

.month-summary,
.daily-diary {
  background: #fef9e7;
  border-radius: 25px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  padding: 1.2rem 1.5rem;  /* padding reduzido */
  flex: 1 1 280px;         /* largura mínima menor */
  max-height: 320px;       /* altura menor */
  overflow-y: auto;
  color: #555;
  font-weight: 700;
  font-size: 1rem;
  font-family: var(--font-family);
}

.month-summary h3,
.daily-diary h3 {
  color: var(--cor-secundaria);
  margin-bottom: 1rem;
  font-weight: 900;
  font-size: 1.5rem;      /* título menor no mobile */
  text-align: center;
  text-shadow: 0 0 6px #90be6d88;
}

/* Lista do resumo do mês */
#monthSummaryList {
  list-style: inside square;
  color: #355e10;
  line-height: 1.5;
  padding-left: 1rem;
  margin-top: 0.7rem;
}

#monthSummaryList li {
  margin-bottom: 0.5rem;
}

/* Exibição da data selecionada */
.daily-diary p#selectedDateDisplay {
  font-weight: 900;
  margin-bottom: 1rem;
  color: var(--cor-secundaria);
  text-align: center;
  font-size: 1.2rem;
  min-height: 28px;
}

/* === Sentimentos (emoticons) === */
.sentiments {
  margin-bottom: 1.3rem;
  text-align: center;
}

.sentiments label {
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.6rem;
  display: block;
  color: var(--cor-secundaria);
}

#sentimentOptions label {
  cursor: pointer;
  font-size: 2rem;
  margin: 0 8px;
  user-select: none;
  transition: transform 0.2s ease;
  display: inline-block;
  padding: 5px 7px;
  border-radius: 14px;
}

#sentimentOptions label:hover,
#sentimentOptions input[type="radio"]:checked + span {
  transform: scale(1.2);
  box-shadow: 0 0 12px 4px #90be6daa;
  border: 2px solid var(--cor-secundaria);
  background: #d4f4b4;
}

#sentimentOptions input[type="radio"] {
  display: none;
}

/* === Campo de texto diário === */
/* Ajuste para o textarea do diário - auto expand */
#diaryInput {
  width: 100%;
  font-size: 1.25rem;
  padding: 1rem 1.5rem;
  border-radius: 25px;
  border: 2px solid var(--cor-secundaria);
  box-shadow: inset 0 1px 6px #a7d080;
  font-family: var(--font-family);
  min-height: 140px; /* mínimo para ficar visível */
  max-height: none;  /* sem limite máximo */
  resize: none;      /* desabilita redimensionamento manual */
  overflow: hidden;  /* remove scroll */
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

/* Remover overflow do container para não gerar scroll */
.daily-diary {
  max-height: none !important;
  overflow: visible !important;
}

#diaryInput:focus {
  outline: none;
  border-color: var(--cor-terciaria);
  box-shadow: 0 0 10px 4px #f9844aaa inset;
}

/* === Botão Salvar === */
#saveDiaryBtn {
  margin-top: 1rem;
  width: 100%;
  background-color: var(--cor-secundaria);
  border: none;
  color: white;
  font-weight: 900;
  font-size: 1.2rem;
  padding: 0.6rem 0;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 6px 15px #6e8f4570;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#saveDiaryBtn:hover:not(:disabled),
#saveDiaryBtn:focus:not(:disabled) {
  background-color: var(--cor-terciaria);
  outline: none;
  transform: scale(1.05);
}

#saveDiaryBtn:disabled {
  background-color: #b9d1a7;
  cursor: not-allowed;
}

/* === Toast (notificação) === */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: var(--cor-primaria);
  color: #3b3b3b;
  padding: 1rem 1.5rem;
  border-radius: 30px;
  font-weight: 700;
  box-shadow: 0 6px 20px #f9c74faa;
  font-size: 1.2rem;
  z-index: 1000;
  opacity: 0;
  transform: translateX(100%);
  animation-fill-mode: forwards;
}

.toast.show {
  animation: toastIn 0.4s forwards;
}

.toast.hide {
  animation: toastOut 0.4s forwards;
}

@keyframes toastIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* === Botão Voltar === */
.back-btn {
  background-color: var(--cor-secundaria);
  color: white;
  border: none;
  border-radius: 25px;
  padding: 0.5rem 1.3rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 5px 15px #6e8f4570;
  transition: background-color 0.3s ease, transform 0.2s ease;
  margin-top: 1rem;
}

.back-btn:hover,
.back-btn:focus {
  background-color: var(--cor-terciaria);
  outline: none;
  transform: scale(1.05);
}

/* === Footer === */
footer {
  text-align: center;
  margin-top: 3rem;
  padding: 1rem 0;
  font-size: 1rem;
  color: var(--cor-secundaria);
  font-family: var(--font-family);
  user-select: none;
}

/* === Animações brilho === */
@keyframes brilho {
  0%, 100% {
    text-shadow: 0 0 6px var(--cor-secundaria);
    color: var(--cor-secundaria);
  }
  50% {
    text-shadow: 0 0 20px var(--cor-terciaria);
    color: var(--cor-terciaria);
  }
}

/* === Responsividade === */
@media (max-width: 820px) {
  main {
    flex-direction: column;
    align-items: center;
  }
  .calendar-container {
    max-width: 100%;
    padding: 1.5rem 1.8rem 2rem 1.8rem; /* padding reduzido no mobile */
  }
  .calendar-header button {
    font-size: 1.3rem;
    padding: 0.25rem 0.8rem;
  }
  #monthYear {
    font-size: 1.6rem;
  }
  .calendar th {
    font-size: 1rem;
    padding-bottom: 0.4rem;
  }
  .calendar td {
    padding: 0.6rem 0;
    font-size: 0.9rem;
  }
  .bottom-panels {
    flex-direction: column;
    gap: 1.2rem;
  }
  .month-summary,
  .daily-diary {
    max-height: none;
    width: 100%;
    padding: 1rem 1.2rem;
    flex: 1 1 100%;
  }
  .month-summary h3,
  .daily-diary h3 {
    font-size: 1.3rem;
  }
  #diaryInput {
    font-size: 1.1rem;
    min-height: 110px;
  }
  #saveDiaryBtn {
    font-size: 1.1rem;
    padding: 0.5rem 0;
  }
  .sentiments label {
    font-size: 1.1rem;
  }
  #sentimentOptions label {
    font-size: 1.7rem;
    margin: 0 6px;
    padding: 4px 6px;
  }
  .back-btn {
    font-size: 0.95rem;
    padding: 0.4rem 1rem;
  }
}
.calendar td .emoji {
  font-size: 1.2rem;
  margin-left: 6px;
  vertical-align: middle;
  user-select: none;
}
