/* BloomMachine Content Calendar Styles */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F8F5EF;
  --bg-alt: #F0EDE6;
  --fg: #1E3A1E;
  --fg-mid: #3D5C3A;
  --fg-light: #5A7A52;
  --accent: #8FAF7C;
  --accent-dark: #6B8F5C;
  --accent-light: #B8CFAB;
  --cream: #FDFBF7;
  --border: rgba(143, 175, 124, 0.3);
  --terracotta: #C4724D;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* Top nav */
.topnav {
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 40px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  font-weight: 600;
}
.nav-tagline {
  font-size: 0.85rem;
  color: var(--fg-light);
  flex: 1;
}
.nav-back {
  font-size: 0.85rem;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 500;
}
.nav-back:hover { text-decoration: underline; }

/* Calendar page */
.calendar-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 40px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.cal-month-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.month-label {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--fg);
  min-width: 200px;
  text-align: center;
}

.nav-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fg-mid);
  transition: background 0.15s, border-color 0.15s;
}
.nav-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-dark);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.add-btn:hover { background: var(--fg); }

/* Calendar grid */
.cal-grid {
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.cal-weekdays span {
  padding: 12px 16px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--fg-light);
  text-transform: uppercase;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day {
  min-height: 100px;
  padding: 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day:nth-last-child(-n+7) { border-bottom: none; }
.cal-day.empty { background: var(--bg-alt); cursor: default; }
.cal-day:hover:not(.empty) { background: rgba(143,175,124,0.08); }

.cal-day.today .day-num {
  background: var(--accent-dark);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-num {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--fg-mid);
  margin-bottom: 6px;
  display: inline-block;
}

/* Entry dots */
.entry-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 2px;
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.1s, opacity 0.1s;
}
.entry-dot:hover { transform: scale(1.4); opacity: 0.85; }
.entry-dot.draft     { background: #C4724D; }
.entry-dot.scheduled { background: var(--accent-dark); }
.entry-dot.published { background: var(--fg); }
.entry-dot.ai-done   {
  background: linear-gradient(135deg, #8FAF7C 50%, #4CAF50 50%);
}

/* Legend */
.cal-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--fg-light);
  padding: 0 4px;
}
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.legend-dot.draft     { background: #C4724D; }
.legend-dot.scheduled { background: var(--accent-dark); }
.legend-dot.published { background: var(--fg); }
.legend-dot.ai-done   { background: linear-gradient(135deg, #8FAF7C 50%, #4CAF50 50%); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 58, 30, 0.4);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(30,58,30,0.15);
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--fg);
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-light);
  padding: 8px;
  min-height: 44px;
  min-width: 44px;
  border-radius: 6px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-btn:hover { background: var(--bg-alt); }

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-mid);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.15s;
  min-height: 44px;
}
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.15s;
  min-height: 88px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-group textarea { resize: vertical; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-end;
}
.form-actions .btn-delete { margin-right: auto; }

.btn-cancel {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--fg-mid);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-cancel:hover { background: var(--bg-alt); }

.btn-delete {
  background: none;
  border: 1.5px solid var(--terracotta);
  border-radius: 8px;
  padding: 10px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--terracotta);
  cursor: pointer;
  transition: background 0.15s;
}
.btn-delete:hover { background: rgba(196,114,77,0.08); }

.btn-save {
  background: var(--accent-dark);
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-save:hover { background: var(--fg); }

.published-at-label {
  display: block;
  font-size: 0.78rem;
  color: var(--accent-dark);
  margin-top: 4px;
  font-weight: 500;
}

/* Day-of-week label shown only in single-column mobile view */
.day-dow { display: none; }

/* Responsive */
@media (max-width: 768px) {
  .calendar-page { padding: 24px 16px; }
  .topnav-inner { padding: 0 16px; }
  .calendar-header { flex-wrap: wrap; gap: 12px; }
  .month-label { min-width: 0; }
  .cal-day { min-height: 72px; padding: 6px; }
  .day-num { font-size: 0.75rem; }
  .form-row { grid-template-columns: 1fr; row-gap: 16px; }
  .modal-box { padding: 24px 20px; }
}

/* AI generation button */
.btn-generate {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid #7B68EE;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #7B68EE;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-generate:hover:not(:disabled) {
  background: rgba(123,104,238,0.08);
}
.btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Inline generation error */
.generation-error {
  font-size: 0.78rem;
  color: var(--terracotta);
  margin-top: 6px;
}
.generation-error.hidden { display: none; }

/* Queue as GBP Post button */
.btn-queue-gbp {
  background: none;
  border: 1.5px solid var(--accent-dark);
  border-radius: 8px;
  padding: 10px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-dark);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-queue-gbp:hover:not(:disabled) {
  background: rgba(107, 143, 92, 0.1);
  color: var(--fg);
}
.btn-queue-gbp:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Inline queue GBP subfields (image URL + publish date) */
.queue-gbp-subfields {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.queue-gbp-subfields.hidden { display: none; }

/* GBP toggle + subfields */
.gbp-toggle-row {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg);
}
.gbp-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-mid);
  margin-bottom: 0;
  cursor: pointer;
  letter-spacing: 0.03em;
}
.gbp-toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-dark);
  cursor: pointer;
}
.gbp-subfields {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.gbp-subfields.hidden { display: none; }
.gbp-subfields .form-group { margin-bottom: 12px; }

.gbp-publish-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(143, 175, 124, 0.12);
  border: 1px solid var(--border);
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  color: var(--accent-dark);
  font-style: italic;
}
.gbp-publish-status.hidden { display: none; }

/* Post to Instagram button */
.btn-post-instagram {
  background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, filter 0.15s;
}
.btn-post-instagram:hover:not(:disabled) {
  filter: brightness(0.95);
}
.btn-post-instagram:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-post-instagram.hidden { display: none; }

/* Inline Instagram publish subfields */
.post-instagram-subfields {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.post-instagram-subfields.hidden { display: none; }

/* Instagram toggle + subfields (mirror of GBP) */
.insta-toggle-row {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg);
  margin-bottom: 12px;
}
.insta-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-mid);
  margin-bottom: 0;
  cursor: pointer;
  letter-spacing: 0.03em;
}
.insta-toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-dark);
  cursor: pointer;
}
.insta-subfields {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.insta-subfields.hidden { display: none; }
.insta-subfields .form-group { margin-bottom: 12px; }

.insta-publish-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(143, 175, 124, 0.12);
  border: 1px solid var(--border);
  font-family: 'Playfair Display', serif;
  font-size: 0.85rem;
  color: var(--accent-dark);
  font-style: italic;
}
.insta-publish-status.hidden { display: none; }

@media (max-width: 480px) {
  .cal-weekdays { display: none; }
  .cal-days { grid-template-columns: 1fr; }
  .cal-day {
    min-height: auto;
    padding: 12px 14px;
    border-right: none;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .cal-day.empty { display: none; }
  /* border-right on :nth-child(7n) is a no-op in single-column layout */
  .cal-day:nth-last-child(-n+7) { border-bottom: 1px solid var(--border); }
  .day-num { min-width: 0; font-size: 0.85rem; margin-bottom: 0; }
  .day-dow { display: inline; font-size: 0.7rem; color: var(--fg-light); margin-left: 4px; font-weight: 400; }
  .entry-dot { width: 12px; height: 12px; }
  .cal-legend { flex-wrap: wrap; gap: 12px; font-size: 0.82rem; }
  .modal-box { width: calc(100% - 32px); margin: 16px; padding: 20px 16px; border-radius: 12px; }
  .add-btn { padding: 9px 14px; font-size: 0.85rem; }
}

/* Keyword trends panel */
.keyword-panel {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg);
}
.keyword-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.keyword-hint {
  font-size: 0.78rem;
  color: var(--fg-light);
  font-style: italic;
}
.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--accent-dark);
  border-radius: 8px;
  color: var(--accent-dark);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover { background: rgba(107, 143, 92, 0.08); }
#insertKeywordsBtn { margin-top: 10px; }
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 4px;
}
.keyword-chip {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: var(--fg-mid);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.keyword-chip:hover { border-color: var(--accent-dark); color: var(--accent-dark); }
.keyword-chip.selected {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--cream);
}
.hidden { display: none; }
}