/* Google Calendar sync controls */
.google-sync-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.google-sync-button {
  background: var(--pill-surface);
  color: #55617a;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(31, 41, 55, 0.04);
}

.google-sync-button:hover:not(:disabled) {
  background: var(--pill-surface-hover);
}

.google-sync-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.google-sync-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .google-sync-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* =========================================================
   iPad / iPhone responsive layout fix
   Keeps Assignments visible and accessible on tablets/mobile.
   Desktop and iPad landscape: calendar + Assignments side by side.
   iPad portrait / phone: Assignments moves above the calendar.
   ========================================================= */

@media (min-width: 901px) and (max-width: 1200px) {
  .app {
    width: min(1180px, 98%);
  }

  .top-bar {
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0 18px;
  }

  .calendar-title-group {
    flex: 0 0 255px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.05;
  }

  .header-actions {
    flex: 1 1 auto;
    gap: 10px;
    row-gap: 10px;
    justify-content: flex-end;
  }

  .calendar-view-switcher,
  .calendar-switcher,
  .google-sync-actions {
    margin: 0;
    gap: 6px;
  }

  .calendar-pill,
  .calendar-view-pill,
  .google-sync-button,
  #todayButton {
    padding: 9px 14px;
    font-size: 13px;
  }

  .google-sync-status {
    max-width: 130px;
  }

  .undo-button {
    width: 40px;
    height: 40px;
  }

  .main-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
    gap: 18px;
    align-items: start;
  }

  .tasks-panel {
    position: sticky;
    top: 100px;
    margin-top: 30px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 16px;
  }

  .month-card {
    grid-template-columns: 115px minmax(0, 1fr);
    gap: 16px;
    padding: 24px;
    border-radius: 24px;
  }

  .month-title h2 {
    font-size: 30px;
  }

  .week-days,
  .days-grid {
    gap: 8px;
  }

  .day-square {
    min-height: 84px;
    padding: 10px;
    border-radius: 16px;
  }

  .day-number {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .calendar-mini-item {
    font-size: 10px;
    padding: 4px 6px;
  }

  .task-card {
    padding: 14px;
  }

  .task-deadline {
    white-space: normal;
  }
}

@media (max-width: 900px) {
  .app {
    width: min(100% - 24px, 760px);
  }

  .top-bar {
    position: relative;
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 16px 0;
  }

  .calendar-title-group,
  .header-actions {
    width: 100%;
  }

  .header-actions {
    justify-content: flex-start;
    gap: 8px;
    row-gap: 10px;
  }

  .calendar-view-switcher,
  .calendar-switcher,
  .google-sync-actions {
    width: auto;
    justify-content: flex-start;
    margin: 0;
  }

  .google-sync-actions {
    width: 100%;
  }

  .google-sync-status {
    max-width: 100%;
  }

  .main-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .tasks-panel {
    order: -1;
    position: static;
    width: 100%;
    max-height: none;
    overflow: visible;
    margin-top: 18px;
    padding: 18px;
  }

  .calendar {
    padding-top: 0;
  }

  .month-card {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 22px;
  }

  .month-title {
    position: static;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }

  .month-title h2 {
    font-size: 30px;
  }

  .month-title span {
    margin-top: 0;
  }

  .task-deadline {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .app {
    width: min(100% - 16px, 480px);
  }

  .small-title {
    font-size: 11px;
  }

  h1 {
    font-size: 28px;
  }

  .title-pill {
    padding: 8px 12px;
    font-size: 12px;
  }

  .calendar-pill,
  .calendar-view-pill,
  .google-sync-button,
  #todayButton {
    padding: 8px 12px;
    font-size: 12px;
  }

  .undo-button {
    width: 38px;
    height: 38px;
  }

  .tasks-panel {
    border-radius: 22px;
    padding: 16px;
  }

  .add-task-button {
    padding: 12px 16px;
    font-size: 14px;
  }

  .tasks-title {
    font-size: 24px;
  }

  .task-card {
    padding: 14px;
  }

  .task-actions,
  .task-footer {
    flex-wrap: wrap;
    gap: 8px;
  }

  .month-card {
    padding: 16px;
    border-radius: 22px;
  }

  .week-days,
  .days-grid {
    gap: 5px;
  }

  .week-days div {
    font-size: 11px;
  }

  .day-square {
    min-height: 58px;
    padding: 5px;
    border-radius: 12px;
  }

  .day-number {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .day-items {
    margin-top: 4px;
    gap: 3px;
  }

  .calendar-mini-item {
    font-size: 9px;
    padding: 3px 4px;
  }

  .holiday-badge,
  .weekly-week-holiday {
    max-width: 76px;
    font-size: 9px;
    padding: 2px 6px;
  }
}

/* Firebase Tasks authentication controls */
.is-hidden {
  display: none !important;
}

.tasks-auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -8px 0 14px;
}

.tasks-auth-button {
  background: var(--pill-surface);
  color: #55617a;
  border: 1px solid var(--line);
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(31, 41, 55, 0.04);
}

.tasks-auth-button:hover:not(:disabled) {
  background: var(--pill-surface-hover);
}

.tasks-auth-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 760px) {
  .tasks-auth-actions {
    width: 100%;
  }

  .tasks-auth-button {
    flex: 1 1 100%;
  }
}

/* Color picker restore/fix: keep Add/Edit Event content scrollable and visible on every screen */
.event-modal-content {
  max-height: 92vh;
  overflow-y: auto;
}

.event-color-field {
  display: flex !important;
}


@media (max-width: 1050px) {
  .analysis-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .analysis-chart-card {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .analysis-controls-card,
  .analysis-hero-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .analysis-week-actions {
    justify-content: flex-start;
  }

  .analysis-summary-row {
    grid-template-columns: 1fr;
  }

  .analysis-chart-header {
    flex-direction: column;
  }

  .analysis-axis-note {
    white-space: normal;
  }
}


/* Backend Google login controls */
.backend-auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.backend-auth-button {
  background: var(--pill-surface);
  color: #55617a;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(31, 41, 55, 0.04);
}

.backend-auth-button:hover:not(:disabled) {
  background: var(--pill-surface-hover);
}

.backend-auth-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.backend-auth-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .backend-auth-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* Backend-only calendar sync status. Legacy Connect Google / Sync buttons are removed. */
.calendar-backend-status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.backend-sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  max-width: 260px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--pill-surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backend-sync-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--pill-surface);
  color: var(--accent, #1f6feb);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.backend-sync-link.is-hidden {
  display: none;
}

.backend-sync-debug {
  display: inline-flex;
  align-items: center;
  max-width: 360px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .calendar-backend-status-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .backend-sync-status {
    max-width: 100%;
  }
}
