/* === CALENDAR UI === */

/* Nav */
.cal-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(240, 235, 227, 0.06);
}
.cal-nav-inner {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-nav-right { display: flex; align-items: center; gap: 28px; }
.cal-nav-link {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}
.cal-nav-link:hover { color: var(--text); }
.cal-nav-active { color: var(--amber); }

/* Main layout */
.cal-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 96px 40px 80px;
}

/* Header */
.cal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 32px;
}
.cal-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--amber);
  font-weight: 500;
  margin-bottom: 8px;
}
.label-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
}
.cal-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 6px;
}
.cal-subtitle { font-size: 0.9rem; color: var(--text-dim); }

.cal-header-right { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }

.cal-nav-week {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid rgba(240, 235, 227, 0.08);
  border-radius: 10px;
  padding: 4px;
}
.cal-nav-btn {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.cal-nav-btn:hover { background: var(--surface-raised); color: var(--amber); }
.cal-week-label {
  padding: 0 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  min-width: 180px;
  text-align: center;
}
.cal-generate-btn { align-self: center; }

/* Legend */
.cal-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot-empty {
  background: transparent;
  border: 1px dashed rgba(240, 235, 227, 0.2);
}
.legend-name { font-size: 0.78rem; color: var(--text-dim); }

/* Calendar Grid */
.cal-grid-wrap {
  overflow-x: auto;
  margin: 0 -40px;
  padding: 0 40px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(160px, 1fr));
  gap: 12px;
  min-width: 1120px;
}

/* Day Column */
.cal-day-col {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.cal-day-today .cal-day-header { background: var(--amber-dim); border-color: rgba(245,166,35,0.3); }
.cal-day-past { opacity: 0.65; }

/* Day Header */
.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-raised);
  border: 1px solid rgba(240, 235, 227, 0.06);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  gap: 8px;
}
.cal-day-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.cal-day-date {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.today-badge {
  color: var(--amber) !important;
  font-weight: 700;
}

/* Slots Container */
.cal-slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
}

/* Filled Slot (draggable post) */
.cal-slot-filled {
  background: var(--surface);
  border: 1px solid rgba(240, 235, 227, 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: grab;
  position: relative;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 80px;
}
.cal-slot-filled:hover {
  border-color: rgba(245, 166, 35, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.cal-slot-filled:active { cursor: grabbing; }
.cal-slot-filled.dragging {
  opacity: 0.4;
  border-style: dashed;
}
.cal-slot-filled.dragging * { pointer-events: none; }

/* Platform color bar on left */
.slot-platform-bar {
  width: 3px;
  border-radius: 2px;
  align-self: stretch;
  flex-shrink: 0;
  min-height: 40px;
}

/* Slot content */
.slot-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.slot-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.slot-platform-badge {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.slot-platform-badge.platform-twitter { background: rgba(29,161,242,0.2); color: #1da1f2; }
.slot-platform-badge.platform-instagram { background: rgba(225,48,108,0.2); color: #e1306c; }
.slot-platform-badge.platform-youtube { background: rgba(255,0,0,0.2); color: #ff0000; }
.slot-platform-badge.platform-linkedin { background: rgba(10,102,194,0.2); color: #0a66c2; }
.slot-platform-badge.platform-tiktok { background: rgba(105,201,208,0.2); color: #69c9d0; }
.slot-platform-empty { background: var(--surface-raised) !important; color: var(--text-muted) !important; }

.slot-time { font-size: 0.62rem; color: var(--text-muted); }

.slot-published-badge {
  display: inline-flex;
  align-items: center;
  width: 16px; height: 16px;
  background: rgba(40,200,64,0.2);
  color: #28c840;
  border-radius: 50%;
  justify-content: center;
}

.slot-pending-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 4px var(--amber-glow);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.slot-hook {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.slot-format {
  font-size: 0.58rem;
  color: var(--text-muted);
  background: rgba(240, 235, 227, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: capitalize;
  width: fit-content;
}

/* Drag handle */
.slot-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
  padding: 2px;
}
.cal-slot-filled:hover .slot-drag-handle { opacity: 1; }
.slot-drag-handle:active { cursor: grabbing; }

/* Empty slot (drop target) */
.cal-slot-empty {
  border: 1px dashed rgba(240, 235, 227, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
}
.cal-slot-empty:hover { border-color: rgba(245,166,35,0.2); background: var(--amber-dim); }
.cal-slot-empty.drop-target {
  border-color: var(--amber);
  background: var(--amber-dim);
  border-style: solid;
}
.slot-empty-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.slot-empty-label { font-size: 0.65rem; color: var(--text-muted); }

/* Draft slot (AI-recommended, not yet scheduled) */
.cal-slot-draft {
  background: var(--surface);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 80px;
}
.cal-slot-draft:hover {
  border-color: rgba(245, 166, 35, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.slot-draft-badge {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245, 166, 35, 0.15);
  color: #f5a623;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slot-confirm-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(245, 166, 35, 0.2);
  border: none;
  color: #f5a623;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}
.cal-slot-draft:hover .slot-confirm-btn { opacity: 1; }
.slot-confirm-btn:hover { background: rgba(245, 166, 35, 0.4); }

/* Drag hint */
.cal-drag-hint {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid rgba(245,166,35,0.3);
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--amber);
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 500;
  animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Edit Modal */
.cal-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cal-modal {
  background: var(--surface);
  border: 1px solid rgba(240, 235, 227, 0.1);
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.cal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 20px;
  border-bottom: 1px solid rgba(240, 235, 227, 0.06);
}
.cal-modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.cal-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
}
.cal-modal-close:hover { color: var(--text); background: var(--surface-raised); }

.cal-modal-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

.modal-field { display: flex; flex-direction: column; gap: 8px; }
.modal-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.modal-textarea {
  background: var(--obsidian);
  border: 1px solid rgba(240, 235, 227, 0.12);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.modal-textarea::placeholder { color: var(--text-muted); }
.modal-textarea:focus { border-color: var(--amber); }

.modal-meta-row { display: flex; gap: 16px; }
.modal-field-small { flex: 1; }

.modal-select, .modal-time {
  background: var(--obsidian);
  border: 1px solid rgba(240, 235, 227, 0.12);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  cursor: pointer;
  width: 100%;
}
.modal-select:focus, .modal-time:focus { border-color: var(--amber); }

.cal-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid rgba(240, 235, 227, 0.06);
}
.modal-cancel { }
.modal-save { min-width: 140px; justify-content: center; }

/* Toast */
.cal-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 28px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 2000;
  animation: toastIn 0.3s ease;
  white-space: nowrap;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.cal-toast-success { background: rgba(40,200,64,0.2); border: 1px solid rgba(40,200,64,0.4); color: #28c840; }
.cal-toast-error { background: rgba(255,107,107,0.2); border: 1px solid rgba(255,107,107,0.4); color: #ff6b6b; }
.cal-toast-info { background: var(--surface-raised); border: 1px solid rgba(240,235,227,0.1); color: var(--text); }

/* Responsive */
@media (max-width: 1100px) {
  .cal-grid { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
  .cal-grid-wrap { overflow-x: auto; }
}
@media (max-width: 768px) {
  .cal-main { padding: 88px 20px 60px; }
  .cal-grid-wrap { margin: 0 -20px; padding: 0 20px; }
  .cal-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .cal-title { font-size: 1.6rem; }
  .cal-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .modal-meta-row { flex-direction: column; }
}

/* Heatmap — best time to post (DOW × hour) */
.cal-heatmap-section {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid rgba(240,235,227,0.06);
}
.cal-heatmap-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-heatmap-sub {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
}
.cal-heatmap {
  display: grid;
  grid-template-columns: 56px repeat(24, minmax(22px, 1fr));
  grid-auto-rows: 28px;
  gap: 3px;
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow-x: auto;
  padding-bottom: 4px;
}
.cal-heatmap-corner,
.cal-heatmap-hour-label,
.cal-heatmap-day-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
}
.cal-heatmap-day-label {
  justify-content: flex-start;
  padding-left: 4px;
}
.cal-heatmap-cell {
  background: var(--surface-raised);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease;
}
.cal-heatmap-empty {
  background: rgba(240,235,227,0.04);
  cursor: default;
}
.cal-heatmap-best {
  box-shadow: 0 0 0 1.5px var(--amber) inset;
  cursor: pointer;
}
.cal-heatmap-best-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--amber);
  color: var(--obsidian);
  font-weight: 600;
  pointer-events: none;
}
.cal-heatmap-cell:hover:not(.cal-heatmap-empty):not(.cal-heatmap-best) {
  transform: scale(1.15);
  z-index: 2;
}
.cal-heatmap-best:hover {
  transform: scale(1.1);
  z-index: 2;
}