/* ── Calendar page ── */

.cal-page {
  max-width: 900px;
  margin: 0 auto;
}

/* ── Header ── */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.cal-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}
.cal-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: #888;
  cursor: pointer;
  transition: all 0.12s;
}
.cal-nav-btn:hover {
  background: rgba(0,0,0,0.04);
  color: #333;
}
.cal-today-btn {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #555;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
}
.cal-today-btn:hover {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.15);
  color: #333;
}

/* ── Mini-month ── */
.cal-month {
  margin-bottom: 24px;
}
.cal-month-title {
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dow {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  text-align: center;
  padding: 4px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cal-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px 4px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.cal-day:hover {
  background: rgba(0,0,0,0.04);
}
.cal-day-num {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.12s;
}
.cal-day-other .cal-day-num {
  color: #ccc;
}
.cal-day-today .cal-day-num {
  background: #144629;
  color: #fff;
  font-weight: 600;
}
.cal-day-selected {
  background: rgba(20,70,41,0.06);
}
.cal-day-selected .cal-day-num {
  font-weight: 700;
  color: #144629;
}
.cal-day-today.cal-day-selected .cal-day-num {
  background: #144629;
  color: #fff;
}

/* Dot indicators */
.cal-day-dots {
  display: flex;
  gap: 3px;
  height: 5px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.cal-dot-event {
  background: #039be5;
}
.cal-dot-task {
  background: #144629;
}

/* ── Connect banner ── */
.cal-connect-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #888;
  background: rgba(20,70,41,0.03);
  border: 1px solid rgba(20,70,41,0.08);
  border-radius: 10px;
}
.cal-connect-banner svg {
  flex-shrink: 0;
  color: #144629;
  opacity: 0.6;
}
.cal-connect-banner span {
  flex: 1;
}
.cal-connect-link {
  font-size: 12px;
  font-weight: 600;
  color: #144629;
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 6px;
  transition: background 0.12s;
  white-space: nowrap;
}
.cal-connect-link:hover {
  background: rgba(20,70,41,0.08);
}

/* ── Day detail ── */
.cal-day-detail {
  margin-bottom: 24px;
}
.cal-day-title {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

/* ── AI Suggestions ── */
.cal-suggestions {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cal-briefing {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.6;
  color: #555;
  padding: 14px 16px;
  background: rgba(20,70,41,0.03);
  border: 1px solid rgba(20,70,41,0.08);
  border-radius: 10px;
  animation: cal-fade-in 0.4s ease both;
}
.cal-briefing-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}
.cal-briefing-text {
  flex: 1;
  min-width: 0;
}

/* Conversation starter chips */
.cal-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.cal-starter-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: #144629;
  background: rgba(20,70,41,0.08);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1.3;
}
.cal-starter-chip:hover {
  background: rgba(20,70,41,0.14);
}
.cal-starter-chip:active {
  transform: scale(0.97);
}
.cal-starter-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cal-suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 10px;
  animation: cal-fade-in 0.4s ease both;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.cal-suggestion:hover {
  border-color: rgba(20,70,41,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.cal-suggestion-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 15px;
}
.cal-suggestion-icon[data-type="prep"] { background: rgba(121,134,203,0.12); }
.cal-suggestion-icon[data-type="focus"] { background: rgba(20,70,41,0.08); }
.cal-suggestion-icon[data-type="break"] { background: rgba(246,191,38,0.12); }
.cal-suggestion-icon[data-type="follow_up"] { background: rgba(3,155,229,0.12); }
.cal-suggestion-icon[data-type="proactive"] { background: rgba(142,36,170,0.12); }
.cal-suggestion-body {
  flex: 1;
  min-width: 0;
}
.cal-suggestion-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}
.cal-suggestion-reason {
  font-size: 12px;
  color: #888;
  margin-top: 1px;
}
.cal-suggestion-action {
  flex-shrink: 0;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #144629;
  background: rgba(20,70,41,0.06);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.cal-suggestion-action:hover {
  background: rgba(20,70,41,0.12);
}
.cal-suggestion-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.cal-suggestions-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #999;
  animation: cal-fade-in 0.3s ease both;
}
.cal-suggestions-loading .cal-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(20,70,41,0.15);
  border-top-color: #144629;
  border-radius: 50%;
  animation: cal-spin 0.6s linear infinite;
}

/* ── Ask Pine ── */
.cal-ask {
  display: flex;
  align-items: flex-end;
  gap: 0;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--color-input-bg);
  border-radius: 16px;
  transition: box-shadow 0.2s;
}
.cal-ask:focus-within {
  box-shadow: 0 0 0 3px var(--color-brand-subtle);
}
.cal-ask-avatar {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 8px;
  margin-bottom: 2px;
}
.cal-ask-avatar img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  opacity: 0.5;
}
.cal-ask-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text-primary);
  background: transparent;
  padding: 6px 8px;
  line-height: 1.5;
  margin-bottom: 2px;
}
.cal-ask-input::placeholder {
  color: #bbb;
}
.cal-ask-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--color-brand);
  color: var(--color-brand-text);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.cal-ask-btn svg { width: 16px; height: 16px; stroke-width: 2.5; }
.cal-ask-btn:hover { background: var(--color-brand-hover); }
.cal-ask-btn:active { transform: scale(0.93); }

/* ── Timeline ── */
.cal-timeline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Calendar event */
.cal-event {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  transition: box-shadow 0.12s;
  animation: cal-item-in 0.3s ease both;
}
.cal-event:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.cal-event-pip {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--event-color, #039be5);
  margin-top: 5px;
}
.cal-event-content {
  flex: 1;
  min-width: 0;
}
.cal-event-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.3;
}
.cal-event-title a {
  color: inherit;
  text-decoration: none;
}
.cal-event-title a:hover {
  text-decoration: underline;
}
.cal-event-time {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}
.cal-event-location {
  font-size: 12px;
  color: #aaa;
  margin-top: 2px;
}

/* ── Tasks section ── */
.cal-tasks-section {
  margin-top: 16px;
}
.cal-tasks-label {
  font-size: 11px;
  font-weight: 700;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.cal-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Task item */
.cal-task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.1s;
  animation: cal-item-in 0.3s ease both;
}
.cal-task:hover {
  background: rgba(0,0,0,0.02);
}
.cal-task-check {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.1s;
}
.cal-task-check:hover {
  background: rgba(20,70,41,0.06);
}
.cal-task-check:hover svg circle {
  stroke: #144629;
}
.cal-task-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.cal-task-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
}
.cal-task[data-task-status="completed"] .cal-task-title {
  color: #aaa;
  text-decoration: line-through;
}
.cal-task-badge {
  font-size: 10px;
  font-weight: 600;
  color: #144629;
  background: rgba(20,70,41,0.06);
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Empty day */
.cal-empty-day {
  padding: 32px 20px;
  text-align: center;
  font-size: 14px;
  color: #ccc;
}

/* ── Unscheduled tasks ── */
.cal-unscheduled {
  margin-bottom: 24px;
}
.cal-unscheduled-title {
  font-size: 13px;
  font-weight: 700;
  color: #999;
  margin: 0 0 8px 2px;
  text-transform: none;
}

/* ── Quick-add task ── */
.cal-quick-add {
  margin-bottom: 24px;
}
.cal-qa-collapsed {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  cursor: text;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  transition: border-color 0.15s;
  color: #ccc;
}
.cal-qa-collapsed:hover {
  border-color: rgba(0,0,0,0.12);
}
.cal-qa-placeholder {
  font-size: 14px;
  color: #ccc;
}
.cal-quick-add.open .cal-qa-collapsed {
  display: none;
}
.cal-qa-expanded {
  display: none;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  overflow: hidden;
  animation: cal-fade-in 0.2s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
.cal-quick-add.open .cal-qa-expanded {
  display: block;
}
.cal-qa-body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.cal-qa-body svg {
  flex-shrink: 0;
  color: #ccc;
}
.cal-qa-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: #1a1a1a;
  background: transparent;
  padding: 0;
}
.cal-qa-input::placeholder { color: #ccc; }
.cal-qa-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid rgba(0,0,0,0.05);
  background: rgba(0,0,0,0.015);
}
.cal-qa-date-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  color: #888;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: all 0.12s;
}
.cal-qa-date-btn:hover {
  background: rgba(0,0,0,0.03);
  color: #555;
}
.cal-qa-date-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.cal-qa-actions {
  display: flex;
  gap: 6px;
}
.cal-qa-cancel {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: #888;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.cal-qa-cancel:hover { color: #333; }
.cal-qa-save {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: #144629;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.cal-qa-save:hover { background: #1a5c36; }

/* ── Animations ── */
@keyframes cal-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cal-item-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cal-spin {
  to { transform: rotate(360deg); }
}

/* Staggered entrance for timeline items */
.cal-timeline > :nth-child(1) { animation-delay: 0s; }
.cal-timeline > :nth-child(2) { animation-delay: 0.03s; }
.cal-timeline > :nth-child(3) { animation-delay: 0.06s; }
.cal-timeline > :nth-child(4) { animation-delay: 0.09s; }
.cal-timeline > :nth-child(5) { animation-delay: 0.12s; }
.cal-timeline > :nth-child(6) { animation-delay: 0.15s; }
.cal-timeline > :nth-child(7) { animation-delay: 0.18s; }
.cal-timeline > :nth-child(8) { animation-delay: 0.21s; }

/* Date transition animation */
.cal-day-detail.sliding-left {
  animation: cal-slide-left 0.25s ease both;
}
.cal-day-detail.sliding-right {
  animation: cal-slide-right 0.25s ease both;
}
@keyframes cal-slide-left {
  0% { opacity: 0; transform: translateX(20px); }
  100% { opacity: 1; transform: translateX(0); }
}
@keyframes cal-slide-right {
  0% { opacity: 0; transform: translateX(-20px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* Task completion animation */
.cal-task-check.popping svg {
  animation: cal-check-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cal-check-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.cal-task.completing {
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0;
  transform: translateX(-20px);
}

/* ── Dark mode ── */
[data-theme="wistful_juniper"],
[data-theme="deep_current"] {
  .cal-header h1 { color: var(--color-text-primary); }

  .cal-nav-btn { color: var(--color-text-muted); }
  .cal-nav-btn:hover { background: rgba(255,255,255,0.05); color: var(--color-text-primary); }
  .cal-today-btn {
    color: var(--color-text-secondary);
    border-color: rgba(255,255,255,0.1);
  }
  .cal-today-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-text-primary);
  }

  .cal-month-title { color: var(--color-text-primary); }
  .cal-dow { color: var(--color-text-muted); }
  .cal-day:hover { background: rgba(255,255,255,0.05); }
  .cal-day-num { color: var(--color-text-primary); }
  .cal-day-other .cal-day-num { color: var(--color-text-muted); opacity: 0.4; }
  .cal-day-today .cal-day-num { background: var(--color-brand); color: var(--color-brand-text); }
  .cal-day-selected { background: rgba(255,255,255,0.06); }
  .cal-day-selected .cal-day-num { color: var(--color-brand); }
  .cal-day-today.cal-day-selected .cal-day-num { background: var(--color-brand); color: var(--color-brand-text); }

  .cal-connect-banner {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.08);
    color: var(--color-text-muted);
  }
  .cal-connect-banner svg { color: var(--color-text-muted); }
  .cal-connect-link { color: var(--color-text-primary); }

  .cal-day-title { color: var(--color-text-primary); }

  .cal-briefing {
    background: rgba(255,255,255,0.03);
    color: var(--color-text-secondary);
    border-color: rgba(255,255,255,0.08);
  }
  .cal-starter-chip {
    color: var(--color-brand);
    background: rgba(255,255,255,0.06);
  }
  .cal-starter-chip:hover {
    background: rgba(255,255,255,0.1);
  }
  .cal-suggestion {
    background: var(--color-card);
    border-color: rgba(255,255,255,0.06);
  }
  .cal-suggestion:hover {
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }
  .cal-suggestion-title { color: var(--color-text-primary); }
  .cal-suggestion-reason { color: var(--color-text-muted); }
  .cal-suggestion-action {
    color: var(--color-brand);
    background: rgba(255,255,255,0.05);
  }
  .cal-suggestion-action:hover { background: rgba(255,255,255,0.08); }
  .cal-suggestions-loading { color: var(--color-text-muted); }

  .cal-ask-input::placeholder { color: var(--color-text-muted); }

  .cal-event {
    background: var(--color-card);
    border-color: rgba(255,255,255,0.06);
  }
  .cal-event:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
  .cal-event-title { color: var(--color-text-primary); }
  .cal-event-title a { color: inherit; }
  .cal-event-time { color: var(--color-text-muted); }
  .cal-event-location { color: var(--color-text-muted); }

  .cal-task:hover { background: rgba(255,255,255,0.03); }
  .cal-task-check:hover { background: rgba(255,255,255,0.08); }
  .cal-task-check:hover svg circle { stroke: var(--color-brand); }
  .cal-task-title { color: var(--color-text-primary); }
  .cal-task[data-task-status="completed"] .cal-task-title { color: var(--color-text-muted); }
  .cal-task-badge {
    color: var(--color-brand);
    background: rgba(255,255,255,0.05);
  }

  .cal-empty-day { color: var(--color-text-muted); }

  .cal-tasks-label { color: var(--color-text-muted); }

  .cal-unscheduled-title { color: var(--color-text-muted); }

  .cal-qa-collapsed {
    border-color: rgba(255,255,255,0.06);
    color: var(--color-text-muted);
  }
  .cal-qa-collapsed:hover { border-color: rgba(255,255,255,0.12); }
  .cal-qa-placeholder { color: var(--color-text-muted); }
  .cal-qa-expanded {
    background: var(--color-card);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  }
  .cal-qa-input { color: var(--color-text-primary); }
  .cal-qa-input::placeholder { color: var(--color-text-muted); }
  .cal-qa-toolbar {
    border-color: rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
  }
  .cal-qa-date-btn {
    color: var(--color-text-muted);
    border-color: rgba(255,255,255,0.1);
  }
  .cal-qa-date-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--color-text-secondary);
  }
  .cal-qa-cancel { color: var(--color-text-muted); }
  .cal-qa-cancel:hover { color: var(--color-text-primary); }
  .cal-qa-save { background: var(--color-brand); color: var(--color-brand-text); }
  .cal-qa-save:hover { background: var(--color-brand-hover); }
}
