/* General & Mobile-First Styles */
:root {
  --primary-bg: #f8f9fa;
  --text-color: #212529;
  --border-color: #dee2e6;
  --header-bg: #6a82fb;
  --header-text: #ffffff;
  --button-bg: #8c9eff;
  --button-hover-bg: #7b8dfc;
  --today-highlight: #fffae1;
  --selected-day-bg: #e6eaff;
  --selected-day-text: #0025e6;
}

body {
  font-family: "Nunito", sans-serif;
  background-color: var(--primary-bg);
  color: var(--text-color);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

#app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem;
}

#header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#grandma-photo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
}


header {
  text-align: center;
  background-color: var(--header-bg);
  color: var(--header-text);
  padding: 1rem;
  border-radius: 12px;
}

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

#calendar-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
}

#current-month-year {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

button {
  font-family: "Nunito", sans-serif;
  font-weight: 700;
  background-color: var(--button-bg);
  color: var(--header-text);
  border: none;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
button:hover {
  background-color: var(--button-hover-bg);
}

/* --- Mobile Calendar View --- */
#calendar-view-container {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
}

#calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 5px;
}

.calendar-day-header,
.calendar-day {
  text-align: center;
}

.calendar-day-header {
  font-weight: 700;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.calendar-day {
  padding: 0.2rem;
  cursor: pointer;
}

.date-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin: 0 auto;
  font-size: 1rem;
  position: relative;
}

.calendar-day.other-month .date-number {
  color: #aaa;
  cursor: default;
}

.calendar-day .date-number.today {
  background-color: var(--today-highlight);
  font-weight: 700;
}

.calendar-day.selected .date-number {
  background-color: var(--header-bg);
  color: var(--header-text);
  font-weight: 700;
}

.event-dot {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  background-color: var(--button-bg);
  border-radius: 50%;
}

.event-bar {
  display: none;
} /* Hide bars on mobile, use event list instead */

#daily-events-display {
  background-color: #fff;
  margin-top: 1rem;
  padding: 1.5rem;
  border-radius: 12px;
  min-height: 200px;
  border: 1px solid var(--border-color);
}

#daily-events-title {
  margin-top: 0;
}
#daily-events-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
#daily-events-list li {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#daily-events-list li:last-child {
  border-bottom: none;
}
#daily-events-list .delete-icon {
  cursor: pointer;
  font-size: 1.2rem;
}

.event-details-text {
  font-weight: 700;
}
.event-details-text span {
  font-weight: 400;
  padding: 4px 8px;
  border-radius: 4px;
  color: white;
  margin-left: 8px;
}

#daily-action-container {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}
#add-call-for-day-btn {
  width: 100%;
  background-color: #28a745;
  font-size: 1rem;
  padding: 0.8rem;
}
#add-call-for-day-btn:hover {
  background-color: #218838;
}

/* --- Info & Actions Section --- */
#info-section {
  margin-top: 2rem;
  padding: 1rem;
  background-color: #f0f2f5;
  border-radius: 12px;
}
#legend-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
#legend-list li {
  display: flex;
  align-items: center;
  font-weight: 700;
}
.color-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  margin-right: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}
#instructions ol {
  padding-left: 20px;
}
#instructions li {
  margin-bottom: 0.5rem;
}
#actions-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
#sync-calendar-btn {
  background-color: #17a2b8;
}
#sync-calendar-btn:hover {
  background-color: #138496;
}
#print-btn {
  background-color: #6c757d;
}
#print-btn:hover {
  background-color: #5a6268;
}

/* --- Modal --- */
.hidden {
  display: none !important;
}
#event-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
#modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
#modal-title {
  margin-top: 0;
  color: var(--header-bg);
  text-align: center;
}
#event-form label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}
#event-form input,
#event-form select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
}
.recurring-option {
  display: flex;
  align-items: center;
  margin-top: 1rem;
}
.recurring-option input {
  width: auto;
  margin-right: 10px;
}
.modal-buttons {
  margin-top: 2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.modal-buttons button {
  width: 100%;
  font-size: 1rem;
}
#cancel-btn {
  background-color: #6c757d;
}
#cancel-btn:hover {
  background-color: #5a6268;
}

/* --- Loader --- */
#loader {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid var(--header-bg);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 2000;
  transform: translate(-50%, -50%);
}
@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* --- Desktop Styles --- */
@media (min-width: 768px) {
  #app-container {
    padding: 1rem;
  }
  h1 {
    font-size: 2.25rem;
  }
  #calendar-grid {
    gap: 5px;
  }
  #daily-events-display {
    display: none;
  } /* Hide event list on desktop */

  .calendar-day {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
  }
  .date-number {
    display: block;
    text-align: left;
    width: auto;
    height: auto;
    border-radius: 0;
    margin: 0 0 0.25rem 0;
  }
  .calendar-day.selected .date-number,
  .calendar-day .date-number.today {
    background: none;
    color: var(--text-color);
  }
  .calendar-day.selected {
    background-color: var(--selected-day-bg);
  }
  .calendar-day .date-number.today {
    font-weight: 700;
    color: var(--selected-day-text);
  }

  .event-dot {
    display: none;
  } /* Hide dots on desktop */
  .event-bar {
    /* Show bars on desktop */
    display: block;
    color: white;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 4px;
    transition: opacity 0.2s ease;
    cursor: pointer;
  }
  .event-bar:hover {
    opacity: 0.8;
  }

  #info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
  }
  #actions-section {
    grid-column: 1 / -1;
    flex-direction: row;
  }
}

/* --- Print Styles (Now in Color) --- */
@media print {
  body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  #info-section,
  #event-modal,
  #loader,
  #daily-events-display,
  #actions-section,
  h1 {
    display: none;
  }

  header {
    background: none;
    padding: 0;
    margin-bottom: 1rem;
    border-radius: 0;
    text-align: center;
  }
  header #calendar-controls button {
    display: none;
  }

  #app-container {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }
  #current-month-year {
    display: block !important;
    color: #000 !important;
    font-size: 22pt;
    font-weight: bold;
  }

  #calendar-view-container {
    margin-top: 0;
  }
  #calendar-grid {
    border: 1px solid #ccc;
  }
  .calendar-day,
  .calendar-day-header {
    border: 1px solid #ccc;
    min-height: 100px;
  }
  .calendar-day.other-month {
    visibility: hidden;
  }
  .event-bar {
    display: block !important;
    border: 1px solid rgba(0, 0, 0, 0.2);
  }
  .calendar-day-header {
    min-height: 40px !important;
    font-size: 0.75rem !important;
    padding: 0.25rem 0 !important;
  }

  @page {
    size: landscape;
  }
}
#success-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1100;
}

#success-modal-content {
  background: #d4edda;
  color: #155724;
  padding: 1.5rem 2rem;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: bold;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  text-align: center;
}
