/* ─────────────────────────────────────────────────────────────────────────────
   MVCalendar — custom calendar widget styles
   ───────────────────────────────────────────────────────────────────────────── */

.mvc-root {
  --mvc-bg:             #ffffff;
  --mvc-border:         #e5e7eb;
  --mvc-text:           #111827;
  --mvc-text-muted:     #6b7280;
  --mvc-text-faint:     #9ca3af;
  --mvc-other-bg:       #f9fafb;
  --mvc-today-bg:       #eff6ff;
  --mvc-today-border:   #3b82f6;
  --mvc-event-bg:       #3b82f6;
  --mvc-event-text:     #ffffff;
  --mvc-drag-over:      #dbeafe;
  --mvc-toolbar-bg:     #ffffff;
  --mvc-btn-bg:         #f3f4f6;
  --mvc-btn-hover:      #e5e7eb;
  --mvc-btn-active-bg:  #2563eb;
  --mvc-btn-active:     #ffffff;
  --mvc-radius:         8px;
  --mvc-font:           inherit;
  --mvc-shadow:         0 1px 4px rgba(0,0,0,.08);

  font-family: var(--mvc-font);
  background: var(--mvc-bg);
  border: 1px solid var(--mvc-border);
  border-radius: var(--mvc-radius);
  overflow: hidden;
  box-shadow: var(--mvc-shadow);
  display: flex;
  flex-direction: column;
}

.mvc-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* ── Loading ─────────────────────────────────────────────────────────────────── */

.mvc-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 60px 0;
}
.mvc-loading span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mvc-event-bg); opacity: 0.4;
  animation: mvc-pulse 1.2s ease-in-out infinite;
}
.mvc-loading span:nth-child(2) { animation-delay: .2s; }
.mvc-loading span:nth-child(3) { animation-delay: .4s; }
@keyframes mvc-pulse {
  0%, 80%, 100% { transform: scale(.6); opacity: .2; }
  40%           { transform: scale(1);  opacity: .9; }
}

/* ── Toolbar ─────────────────────────────────────────────────────────────────── */

.mvc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--mvc-toolbar-bg);
  border-bottom: 1px solid var(--mvc-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.mvc-toolbar-nav,
.mvc-toolbar-views {
  display: flex;
  align-items: center;
  gap: 3px;
}

.mvc-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--mvc-text);
  margin: 0;
  white-space: nowrap;
  letter-spacing: -.01em;
  flex: 1;
  text-align: center;
  min-width: 0;
}

.mvc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--mvc-border);
  border-radius: 6px;
  background: var(--mvc-btn-bg);
  color: var(--mvc-text);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  line-height: 1.4;
  white-space: nowrap;
}
.mvc-btn:hover  { background: var(--mvc-btn-hover); }
.mvc-btn.active,
.mvc-btn:active { background: var(--mvc-btn-active-bg); color: var(--mvc-btn-active); border-color: var(--mvc-btn-active-bg); }
.mvc-nav-btn    { font-size: 18px; padding: 3px 10px; font-weight: 400; }

/* Thin separator between work-week toggle and view buttons */
.mvc-view-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--mvc-border);
  margin: 0 3px;
  flex-shrink: 0;
  align-self: center;
}

/* Date jump input */
.mvc-date-input {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--mvc-border);
  border-radius: 6px;
  background: var(--mvc-btn-bg);
  color: var(--mvc-text);
  cursor: pointer;
  outline: none;
  height: 30px;
  transition: border-color .15s;
}
.mvc-date-input:hover  { border-color: var(--mvc-text-muted); }
.mvc-date-input:focus  { border-color: var(--mvc-today-border); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }

/* ── Event filter input ──────────────────────────────────────────────────────── */

.mvc-filter-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.mvc-filter-input {
  padding: 4px 8px 4px 28px;
  font-size: 12px;
  border: 1px solid var(--mvc-border);
  border-radius: 6px;
  background: var(--mvc-btn-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 8px center;
  color: var(--mvc-text);
  outline: none;
  height: 30px;
  width: 140px;
  transition: border-color .15s, width .2s, background-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
.mvc-filter-input::-webkit-search-cancel-button { cursor: pointer; }
.mvc-filter-input:hover  { border-color: var(--mvc-text-muted); }
.mvc-filter-input:focus  {
  border-color: var(--mvc-today-border);
  box-shadow: 0 0 0 2px rgba(59,130,246,.15);
  width: 180px;
  background-color: #fff;
}
/* Highlight border when filter is active */
.mvc-filter-input:not(:placeholder-shown) {
  border-color: var(--mvc-today-border);
  background-color: #fff;
}

/* ── Body ─────────────────────────────────────────────────────────────────────── */

.mvc-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative; /* anchor for filter empty overlay */
}

/* ── Filter empty-state overlay ──────────────────────────────────────────────── */

.mvc-filter-empty {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--mvc-text-muted);
  font-size: 13px;
  line-height: 1.7;
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
}
.mvc-filter-empty-icon {
  font-size: 28px;
  margin-bottom: 6px;
  opacity: .55;
}

/* ── Month view ──────────────────────────────────────────────────────────────── */

.mvc-month {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.mvc-month-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--mvc-other-bg);
  border-bottom: 1px solid var(--mvc-border);
  flex-shrink: 0;
}
.mvc-month-dow {
  padding: 7px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--mvc-text-muted);
}

/* Month grid: flex column of week rows */
.mvc-month-grid {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

/* Each week is a row containing a span-bar section + cells section */
.mvc-week-row {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--mvc-border);
  flex-shrink: 0;
}
.mvc-week-row:last-child {
  border-bottom: none;
}

/* Multi-day span bars */
.mvc-week-spans {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  /* grid-template-rows set inline by JS */
  row-gap: 2px;
  padding: 2px 0 0;
}

.mvc-span-bar {
  display: flex;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  height: 20px;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 11.5px;
  font-weight: 500;
  transition: filter .1s, opacity .1s;
  margin: 0 3px;
}
.mvc-span-bar:hover    { filter: brightness(.93); }
.mvc-span-bar.mvc-dragging { opacity: .45; }

/* Bars that continue from the previous week: no left margin/rounding */
.mvc-span-bar.mvc-span-from-prev,
.mvc-tg-allday-bar.mvc-span-from-prev {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: 0;
}
/* Bars that continue into the next week: no right margin/rounding */
.mvc-span-bar.mvc-span-to-next,
.mvc-tg-allday-bar.mvc-span-to-next {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  margin-right: 0;
}

.mvc-span-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Day cells row inside a week row */
.mvc-week-cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.mvc-day-cell {
  min-height: 120px;
  padding: 6px 5px 4px;
  border-right: 1px solid var(--mvc-border);
  background: var(--mvc-bg);
  cursor: pointer;
  transition: background .1s;
  overflow: hidden;
}
.mvc-day-cell:hover { background: #f8fafc; }
.mvc-day-cell:last-child { border-right: none; }
.mvc-day-cell.mvc-other-month { background: var(--mvc-other-bg); }
.mvc-day-cell.mvc-today { background: var(--mvc-today-bg); border-top: 2px solid var(--mvc-today-border); }

.mvc-day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--mvc-text-muted);
  margin-bottom: 3px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.mvc-today .mvc-day-num         { background: var(--mvc-today-border); color: #fff; font-weight: 700; }
.mvc-other-month .mvc-day-num   { color: var(--mvc-text-faint); }

.mvc-day-events { display: flex; flex-direction: column; gap: 2px; }

.mvc-more-link {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--mvc-text-muted);
  padding: 1px 4px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 3px;
  transition: background .1s, color .1s;
  text-align: left;
}
.mvc-more-link:hover { background: var(--mvc-btn-hover); color: var(--mvc-text); }

/* ── Events ──────────────────────────────────────────────────────────────────── */

.mvc-event {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  transition: filter .1s, opacity .1s;
}
.mvc-event:hover      { filter: brightness(.93); }
.mvc-event.mvc-dragging { opacity: .45; }

.mvc-event-chip {
  padding: 2px 6px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.5;
  min-width: 0;
}

.mvc-event-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Drop target ─────────────────────────────────────────────────────────────── */

.mvc-drag-over {
  background: var(--mvc-drag-over) !important;
  outline: 2px dashed var(--mvc-today-border);
  outline-offset: -2px;
}

/* ── Avatars ─────────────────────────────────────────────────────────────────── */

.mvc-avatars { display: flex; align-items: center; flex-shrink: 0; }
.mvc-avatar {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.25); color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; border: 1.5px solid rgba(255,255,255,.5);
  margin-left: -4px; flex-shrink: 0; position: relative;
}
.mvc-avatars .mvc-avatar:first-child { margin-left: 0; }
.mvc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mvc-avatar-overflow { font-size: 8px; background: rgba(0,0,0,.35); }

.mvc-avatar[data-mvc-tip] { cursor: default; }
.mvc-avatar[data-mvc-tip]::after {
  content: attr(data-mvc-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: rgba(17,24,39,.88); color: #fff;
  padding: 3px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 400; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .15s;
  z-index: 9999; letter-spacing: 0;
}
.mvc-avatar[data-mvc-tip]:hover::after { opacity: 1; }

/* ── Time-grid (week / day) ──────────────────────────────────────────────────── */

.mvc-timegrid { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.mvc-tg-header {
  display: flex;
  border-bottom: 1px solid var(--mvc-border);
  background: var(--mvc-other-bg);
  flex-shrink: 0;
}
.mvc-tg-corner  { width: 56px; flex-shrink: 0; border-right: 1px solid var(--mvc-border); }
.mvc-tg-day-head {
  flex: 1; text-align: center; padding: 8px 4px;
  border-left: 1px solid var(--mvc-border);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.mvc-tg-day-head.mvc-today { background: var(--mvc-today-bg); }
.mvc-tg-dow      { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--mvc-text-muted); }
.mvc-tg-date-num {
  font-size: 18px; font-weight: 600; color: var(--mvc-text); line-height: 1.2;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
}
.mvc-tg-day-head.mvc-today .mvc-tg-date-num { background: var(--mvc-today-border); color: #fff; }

/* ── All-day section ─────────────────────────────────────────────────────────── */

.mvc-tg-allday-section {
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid var(--mvc-border);
  background: var(--mvc-toolbar-bg);
  flex-shrink: 0;
}

.mvc-tg-allday-corner {
  width: 56px;
  flex-shrink: 0;
  border-right: 1px solid var(--mvc-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 4px 6px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--mvc-text-faint);
  line-height: 1.2;
  text-align: right;
}

.mvc-tg-allday-grid {
  flex: 1;
  display: grid;
  /* grid-template-columns and grid-template-rows set inline by JS */
  padding: 4px 0;
  row-gap: 2px;
  min-height: 30px;
  align-content: start;
}

.mvc-tg-allday-bar {
  display: flex;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  height: 20px;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 11.5px;
  font-weight: 500;
  margin: 0 3px;
  transition: filter .1s, opacity .1s;
  align-self: center;
}
.mvc-tg-allday-bar:hover    { filter: brightness(.93); }
.mvc-tg-allday-bar.mvc-dragging { opacity: .45; }

.mvc-tg-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; }

.mvc-tg-body { display: flex; position: relative; }

.mvc-tg-times { width: 56px; flex-shrink: 0; position: relative; border-right: 1px solid var(--mvc-border); }
.mvc-tg-hour-label {
  position: absolute; right: 8px;
  font-size: 10px; color: var(--mvc-text-faint);
  transform: translateY(-50%); white-space: nowrap;
}

.mvc-tg-col { flex: 1; position: relative; border-left: 1px solid var(--mvc-border); cursor: pointer; }
.mvc-tg-col:first-of-type { border-left: none; }

.mvc-tg-hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--mvc-border); pointer-events: none; }

/* Timed event block */
.mvc-event-timed {
  position: absolute;
  left: 3px; right: 3px;
  padding: 3px 5px 12px; /* extra bottom padding for resize handle */
  font-size: 11.5px; font-weight: 500;
  border-radius: 4px;
  overflow: hidden;
  z-index: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.mvc-event-timed .mvc-event-title {
  white-space: normal;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Continuation indicators: flatten the touching edge */
.mvc-ev-from-prev { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 2px dashed rgba(255,255,255,.5); }
.mvc-ev-to-next   { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

/* ── Resize handle ───────────────────────────────────────────────────────────── */

.mvc-resize-handle {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 10px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mvc-resize-handle::after {
  content: '';
  width: 24px; height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.55);
}
.mvc-event-timed:hover .mvc-resize-handle::after { background: rgba(255,255,255,.85); }

.mvc-resizing {
  opacity: .85;
  z-index: 10;
  cursor: ns-resize;
}

/* ── "Now" line ──────────────────────────────────────────────────────────────── */

.mvc-now-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #ef4444;
  z-index: 3;
  pointer-events: none;
}
/* Red circle on left edge */
.mvc-now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
}

/* ── Drag-to-create selection rect ───────────────────────────────────────────── */

.mvc-create-sel {
  position: absolute;
  left: 3px; right: 3px;
  background: rgba(59,130,246,.18);
  border: 2px solid rgba(59,130,246,.5);
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  padding: 2px 4px;
  min-height: 16px;
}
.mvc-create-sel-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--mvc-today-border);
  white-space: nowrap;
}

/* ── Time tooltip (drag / resize) ────────────────────────────────────────────── */

.mvc-timetip {
  position: fixed;
  z-index: 99999;
  background: rgba(17,24,39,.88);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  pointer-events: none;
  white-space: nowrap;
  letter-spacing: .01em;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* ── Event hover tooltip ─────────────────────────────────────────────────────── */

.mvc-event-tooltip {
  position: fixed;
  z-index: 99998;
  background: #fff;
  border: 1px solid var(--mvc-border);
  border-left: 4px solid var(--mvc-event-bg); /* overridden inline per event */
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 160px;
  max-width: 260px;
  box-shadow: 0 4px 20px rgba(0,0,0,.13);
  pointer-events: none;
  font-size: 12.5px;
  line-height: 1.5;
}
.mvc-etip-title {
  font-weight: 700;
  color: var(--mvc-text);
  margin-bottom: 4px;
  word-break: break-word;
}
.mvc-etip-meta {
  color: var(--mvc-text-muted);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Year view ───────────────────────────────────────────────────────────────── */

.mvc-year {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; padding: 16px;
  overflow-y: auto; flex: 1;
}
@media (max-width: 900px) { .mvc-year { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .mvc-year { grid-template-columns: repeat(2, 1fr); } }

.mvc-mini-month { border: 1px solid var(--mvc-border); border-radius: 7px; overflow: hidden; background: var(--mvc-bg); }

.mvc-mini-title {
  padding: 7px 10px; font-size: 12px; font-weight: 700;
  background: var(--mvc-other-bg); border-bottom: 1px solid var(--mvc-border);
  cursor: pointer; color: var(--mvc-text); transition: color .1s; text-transform: capitalize;
}
.mvc-mini-title:hover { color: var(--mvc-today-border); }

.mvc-mini-dow-row { display: grid; grid-template-columns: repeat(7, 1fr); padding: 4px 6px 2px; gap: 1px; }
.mvc-mini-dow-row > div { text-align: center; font-size: 9px; font-weight: 700; text-transform: uppercase; color: var(--mvc-text-faint); }

.mvc-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); padding: 2px 6px 6px; gap: 1px; }
.mvc-mini-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 2px 0; cursor: pointer; border-radius: 4px; transition: background .1s;
}
.mvc-mini-day:hover         { background: var(--mvc-btn-hover); }
.mvc-mini-other             { color: var(--mvc-text-faint); cursor: default; }
.mvc-mini-other:hover       { background: none; }

.mvc-mini-day-num {
  font-size: 11px; color: var(--mvc-text-muted);
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; line-height: 1; font-weight: 500;
}
.mvc-mini-other .mvc-mini-day-num  { color: var(--mvc-text-faint); font-weight: 400; }
.mvc-mini-today .mvc-mini-day-num  { background: var(--mvc-today-border); color: #fff; font-weight: 700; }

.mvc-mini-dots { display: flex; align-items: center; justify-content: center; gap: 2px; height: 5px; }
.mvc-mini-dot  { width: 4px; height: 4px; border-radius: 50%; flex-shrink: 0; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .mvc-toolbar        { gap: 6px; }
  .mvc-title          { font-size: 13px; order: -1; width: 100%; text-align: left; flex: unset; }
  .mvc-date-input     { display: none; }
  .mvc-filter-input   { width: 110px; }
  .mvc-filter-input:focus { width: 130px; }
  .mvc-day-cell       { min-height: 70px; padding: 3px; }
  .mvc-event-chip     { font-size: 10px; padding: 1px 4px; }
  .mvc-btn            { font-size: 12px; padding: 4px 8px; }
}

/* ── Activity events (process + CRM activities with scheduled_at) ─────────── */
.mvc-event.mvc-activity {
  border-left: 3px solid currentColor !important;
  border-radius: 0 4px 4px 0 !important;
  font-style: italic;
  cursor: pointer;
}
.mvc-event.mvc-activity:not([draggable="true"]) {
  cursor: pointer;
}
/* Tooltip hint shown in the event tooltip for activities */
.mvc-activity-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  vertical-align: middle;
  margin-right: 4px;
}
