/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --li-blue: #0A66C2;
  --ig-pink: #E1306C;
  --status-draft: #9CA3AF;
  --status-scheduled: #3B82F6;
  --status-published: #10B981;
  --status-needs-review: #F59E0B;
  --bg: #FAFAFA;
  --card-bg: #FFFFFF;
  --text: #1F2937;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --brand: #0EA5E9;
  --teal: #14B8A6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 960px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
}

/* === Month Nav === */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 12px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:active { background: var(--border); }

.month-title {
  font-size: 20px;
  font-weight: 700;
  min-width: 160px;
  text-align: center;
}

.today-btn {
  padding: 8px 16px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: transparent;
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.today-btn:active { background: var(--brand); color: #fff; }

/* === Weekday header === */
.weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 4px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === Calendar Grid === */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 4px 16px;
}

.day-cell {
  min-height: 72px;
  background: var(--card-bg);
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.15s;
}

.day-cell:hover { background: #F3F4F6; }
.day-cell.empty { background: transparent; cursor: default; }
.day-cell.empty:hover { background: transparent; }
.day-cell.past .day-number { color: var(--text-muted); }

.day-number {
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 3px;
}

.day-number.today {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

/* Post row in cell */
.post-row {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 2px;
  line-height: 1.2;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 18px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.badge-li { background: var(--li-blue); }
.badge-ig { background: var(--ig-pink); }

.post-title-cell {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 30px);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.draft { background: var(--status-draft); }
.status-dot.needs-review { background: var(--status-needs-review); }
.status-dot.approved { background: var(--status-scheduled); }
.status-dot.scheduled { background: var(--status-scheduled); }
.status-dot.published { background: var(--status-published); }
.status-dot.archived { background: var(--text-muted); }
.status-dot.rejected { background: #EF4444; }

.overflow-indicator {
  font-size: 11px;
  color: var(--teal);
  font-weight: 600;
  cursor: pointer;
  padding: 1px 0;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 16px; margin-bottom: 4px; }
.empty-sub { font-size: 14px; }

/* === Overlay === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 50;
}

/* === Day Sheet (Mobile: bottom sheet / Desktop: popover) === */
.day-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  padding: 8px 16px 24px;
  z-index: 60;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 12px;
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.sheet-list { display: flex; flex-direction: column; gap: 2px; }

.sheet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.sheet-row:hover { background: #F3F4F6; }

.sheet-row .post-title-sheet {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-row .post-status {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sheet-row .post-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sheet-row .chevron {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

/* === Detail Drawer === */
.detail-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  padding: 0;
  z-index: 70;
  max-height: 92vh;
  height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}

.detail-drawer-header {
  flex-shrink: 0;
  padding: 8px 20px 0;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.detail-close:hover { background: var(--border); }

.detail-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 20px 16px;
  -webkit-overflow-scrolling: touch;
}

.detail-platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.detail-platform .badge { width: 28px; height: 20px; font-size: 11px; }

.detail-platform-name {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: #F3F4F6;
}

.detail-status-pill .status-dot { width: 8px; height: 8px; }

.detail-date {
  font-size: 13px;
  color: var(--text-muted);
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.detail-hook {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-line;
  margin-bottom: 16px;
  padding: 12px;
  background: #F9FAFB;
  border-radius: 8px;
  border-left: 3px solid var(--li-blue);
}

.detail-body {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}

.detail-field {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 4px;
}

.detail-field strong {
  color: var(--text-muted);
  font-weight: 600;
}

.detail-hashtags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hashtag {
  display: inline-block;
  padding: 3px 8px;
  background: #FDF2F8;
  color: var(--ig-pink);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.detail-media {
  margin-top: 12px;
  padding: 16px;
  background: #F3F4F6;
  border-radius: 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.detail-media-preview {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: #F3F4F6;
}

.detail-media-preview img,
.detail-media-preview video {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  display: block;
}

.detail-carousel {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  padding-bottom: 4px;
}

.detail-carousel img,
.detail-carousel video {
  flex-shrink: 0;
  width: 80%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
  scroll-snap-align: start;
}

.carousel-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 200px;
  height: 120px;
  background: #F3F4F6;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px;
  text-align: center;
  word-break: break-all;
}

.detail-nav {
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  padding: 12px 20px 16px;
  margin-top: 0;
  border-top: 1px solid var(--border);
}

.detail-nav-btn {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}

.detail-nav-btn:hover { background: #F3F4F6; }
.detail-nav-btn:disabled { opacity: 0.3; cursor: default; }

/* === Desktop overrides === */
@media (min-width: 768px) {
  .day-cell { min-height: 120px; padding: 6px; }
  .day-number { font-size: 14px; }
  .post-title-cell { font-size: 12px; }

  .day-sheet {
    position: fixed;
    bottom: auto;
    left: auto;
    right: auto;
    width: 300px;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  }

  .day-sheet .sheet-handle { display: none; }

  .detail-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 420px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  }

  .desktop-hide { display: none; }
}
