/* =========================================================
   ContractPulse - Calendar & Time Blocking Module Styles
   Path: css/modules/calendar.css
   ---------------------------------------------------------
   Module: js/modules/calendar.js
   Berisi SEMUA CSS untuk tab Time Blocking (FullCalendar):
   - Calendar toolbar (view switcher, nav, templates)
   - Stats cards (blocks, hours, conflicts, focus)
   - FullCalendar theme overrides (light + dark)
   - Event custom styles (conflict, completed, focus)
   - Templates drawer content
   - Recurring rule editor
   - Focus mode (Pomodoro) overlay
   - Empty state
   ========================================================= */

/* ============================================
   1. ROOT
   ============================================ */
#calendarRoot {
  width: 100%;
}

.calendar-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================
   2. TOOLBAR
   ============================================ */
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
}

[data-theme="dark"] .calendar-toolbar {
  background: #1a1f2e;
  border-color: #2a3142;
}

.calendar-toolbar .calendar-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

[data-theme="dark"] .calendar-toolbar .calendar-toolbar-group {
  background: #232838;
  border-color: #2a3142;
}

.calendar-toolbar button {
  padding: 6px 11px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.calendar-toolbar button:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.calendar-toolbar button[data-active="true"] {
  background: #4f46e5;
  color: #ffffff;
  box-shadow: 0 2px 6px -1px rgba(79, 70, 229, 0.35);
}

.calendar-toolbar button[data-active="true"]:hover {
  background: #4338ca;
}

[data-theme="dark"] .calendar-toolbar button {
  color: #cbd5e1;
}
[data-theme="dark"] .calendar-toolbar button:hover {
  background: #2a3142;
  color: #ffffff;
}
[data-theme="dark"] .calendar-toolbar button[data-active="true"] {
  background: #4f46e5;
  color: #ffffff;
}

.calendar-toolbar .calendar-toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.calendar-toolbar .calendar-cta {
  padding: 8px 14px !important;
  background: #4f46e5 !important;
  color: #ffffff !important;
  border-radius: 10px !important;
  font-weight: 800 !important;
  box-shadow: 0 2px 8px -2px rgba(79, 70, 229, 0.4);
}

.calendar-toolbar .calendar-cta:hover {
  background: #4338ca !important;
  transform: translateY(-1px);
}

/* View switch label */
.calendar-view-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

[data-theme="dark"] .calendar-view-switch {
  background: #232838;
  border-color: #2a3142;
}

/* ============================================
   3. STATS CARDS
   ============================================ */
.calendar-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 900px) {
  .calendar-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .calendar-stats { grid-template-columns: 1fr; }
}

.calendar-stat {
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.15s ease;
}

.calendar-stat:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.06);
}

[data-theme="dark"] .calendar-stat {
  background: #1a1f2e;
  border-color: #2a3142;
}
[data-theme="dark"] .calendar-stat:hover {
  border-color: #3a4457;
}

.calendar-stat .calendar-stat-label {
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.calendar-stat .calendar-stat-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

[data-theme="dark"] .calendar-stat .calendar-stat-value {
  color: #e4e7eb;
}

.calendar-stat .calendar-stat-sub {
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
  margin-top: 2px;
}

.calendar-stat[data-tone="indigo"] .calendar-stat-value { color: #4f46e5; }
.calendar-stat[data-tone="emerald"] .calendar-stat-value { color: #059669; }
.calendar-stat[data-tone="rose"] .calendar-stat-value { color: #e11d48; }
.calendar-stat[data-tone="amber"] .calendar-stat-value { color: #d97706; }

[data-theme="dark"] .calendar-stat[data-tone="indigo"] .calendar-stat-value { color: #818cf8; }
[data-theme="dark"] .calendar-stat[data-tone="emerald"] .calendar-stat-value { color: #34d399; }
[data-theme="dark"] .calendar-stat[data-tone="rose"] .calendar-stat-value { color: #fb7185; }
[data-theme="dark"] .calendar-stat[data-tone="amber"] .calendar-stat-value { color: #fbbf24; }

/* ============================================
   4. CONFLICT BANNER
   ============================================ */
.calendar-conflict-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  color: #991b1b;
  font-size: 11px;
}

[data-theme="dark"] .calendar-conflict-banner {
  background: #3f1218;
  border-color: #7f1d1d;
  color: #fecaca;
}

.calendar-conflict-banner svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.calendar-conflict-banner strong {
  font-weight: 800;
}

/* ============================================
   5. FULLCALENDAR — THEME OVERRIDES (LIGHT)
   ============================================ */
#calendarRoot .fc {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 12px;
  --fc-border-color: #e2e8f0;
  --fc-today-bg-color: rgba(99, 102, 241, 0.06);
  --fc-neutral-bg-color: #f8fafc;
  --fc-page-bg-color: #ffffff;
}

#calendarRoot .fc .fc-toolbar-title {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.2px;
}

#calendarRoot .fc .fc-button {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 8px;
  text-transform: capitalize;
  box-shadow: none;
  transition: all 0.12s ease;
}

#calendarRoot .fc .fc-button:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

#calendarRoot .fc .fc-button:focus {
  box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.3);
  outline: none;
}

#calendarRoot .fc .fc-button-primary:not(:disabled).fc-button-active,
#calendarRoot .fc .fc-button-primary:not(:disabled):active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #ffffff;
}

#calendarRoot .fc .fc-col-header-cell {
  background: #f8fafc;
  padding: 8px 0;
  font-weight: 800;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #475569;
  border-color: #e2e8f0;
}

#calendarRoot .fc .fc-col-header-cell-cushion {
  padding: 4px 6px;
  text-decoration: none;
  color: inherit;
}

#calendarRoot .fc .fc-timegrid-slot-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #94a3b8;
  padding-right: 6px;
}

#calendarRoot .fc .fc-timegrid-slot {
  height: 40px;
  border-color: #f1f5f9;
}

#calendarRoot .fc .fc-timegrid-slot-minor {
  border-top-style: dashed;
  border-color: #f8fafc;
}

#calendarRoot .fc .fc-day-today {
  background: rgba(99, 102, 241, 0.06) !important;
}

#calendarRoot .fc .fc-timegrid-now-indicator-line {
  border-color: #ef4444;
  border-width: 2px;
}

#calendarRoot .fc .fc-timegrid-now-indicator-arrow {
  border-color: #ef4444;
  border-top-width: 6px;
  border-bottom-width: 6px;
}

#calendarRoot .fc .fc-daygrid-day-number {
  color: #475569;
  font-weight: 700;
  font-size: 11px;
  text-decoration: none;
  padding: 4px 6px;
}

#calendarRoot .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  color: #4f46e5;
  font-weight: 800;
}

/* ============================================
   6. FULLCALENDAR — THEME OVERRIDES (DARK)
   ============================================ */
[data-theme="dark"] #calendarRoot .fc {
  --fc-border-color: #2a3142;
  --fc-today-bg-color: rgba(99, 102, 241, 0.12);
  --fc-neutral-bg-color: #131824;
  --fc-page-bg-color: #1a1f2e;
}

[data-theme="dark"] #calendarRoot .fc .fc-toolbar-title {
  color: #e4e7eb;
}

[data-theme="dark"] #calendarRoot .fc .fc-button {
  background: #232838;
  border-color: #2a3142;
  color: #cbd5e1;
}

[data-theme="dark"] #calendarRoot .fc .fc-button:hover {
  background: #2a3142;
  border-color: #3a4457;
  color: #ffffff;
}

[data-theme="dark"] #calendarRoot .fc .fc-button-primary:not(:disabled).fc-button-active,
[data-theme="dark"] #calendarRoot .fc .fc-button-primary:not(:disabled):active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #ffffff;
}

[data-theme="dark"] #calendarRoot .fc .fc-col-header-cell {
  background: #131824;
  color: #9ca3af;
  border-color: #2a3142;
}

[data-theme="dark"] #calendarRoot .fc .fc-timegrid-slot {
  border-color: #1f2532;
}

[data-theme="dark"] #calendarRoot .fc .fc-timegrid-slot-minor {
  border-color: #1a1f2e;
}

[data-theme="dark"] #calendarRoot .fc .fc-day-today {
  background: rgba(99, 102, 241, 0.12) !important;
}

[data-theme="dark"] #calendarRoot .fc .fc-daygrid-day-number {
  color: #9ca3af;
}

[data-theme="dark"] #calendarRoot .fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  color: #a5b4fc;
}

/* ============================================
   7. FULLCALENDAR — EVENTS
   ============================================ */
#calendarRoot .fc .fc-event {
  border-radius: 7px;
  border: none;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 4px;
  cursor: pointer;
  overflow: hidden;
  transition: filter 0.12s ease, transform 0.12s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

#calendarRoot .fc .fc-event:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
}

#calendarRoot .fc .fc-event-main {
  padding: 2px 3px;
  color: inherit;
}

#calendarRoot .fc .fc-event-title {
  font-weight: 800;
  line-height: 1.25;
}

#calendarRoot .fc .fc-event-time {
  font-size: 9px;
  opacity: 0.85;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

#calendarRoot .fc .fc-timegrid-event-harness {
  z-index: 1;
}

/* Event states */
#calendarRoot .fc .fc-event.calendar-event-conflict {
  box-shadow: inset 0 0 0 2px #ef4444, 0 1px 2px rgba(15, 23, 42, 0.1);
  z-index: 3;
}

#calendarRoot .fc .fc-event.calendar-event-completed {
  opacity: 0.5;
  text-decoration: line-through;
}

#calendarRoot .fc .fc-event.calendar-event-completed .fc-event-title::before {
  content: "✓ ";
  text-decoration: none;
}

#calendarRoot .fc .fc-event.calendar-event-focus {
  box-shadow: inset 0 0 0 2px #f59e0b, 0 1px 2px rgba(15, 23, 42, 0.1);
}

#calendarRoot .fc .fc-event.calendar-event-focus .fc-event-title::before {
  content: "🎯 ";
}

/* ============================================
   8. TEMPLATES DRAWER CONTENT
   ============================================ */
.calendar-templates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calendar-template-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.12s ease;
}

.calendar-template-item:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
}

[data-theme="dark"] .calendar-template-item {
  background: #232838;
  border-color: #2a3142;
}
[data-theme="dark"] .calendar-template-item:hover {
  background: #2a3142;
  border-color: #4f46e5;
}

.calendar-template-item .calendar-template-info {
  flex: 1;
  min-width: 0;
}

.calendar-template-item .calendar-template-name {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-template-item .calendar-template-meta {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 3px;
  font-family: 'JetBrains Mono', monospace;
}

[data-theme="dark"] .calendar-template-item .calendar-template-name {
  color: #e4e7eb;
}

.calendar-template-item .calendar-template-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.calendar-template-item .calendar-template-actions button {
  padding: 5px 10px;
  border: none;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}

.calendar-template-item .calendar-template-use {
  background: #4f46e5;
  color: #ffffff;
}
.calendar-template-item .calendar-template-use:hover {
  background: #4338ca;
}

.calendar-template-item .calendar-template-delete {
  background: #fef2f2;
  color: #e11d48;
}
.calendar-template-item .calendar-template-delete:hover {
  background: #fee2e2;
}

/* ============================================
   9. RECURRING RULE EDITOR
   ============================================ */
.calendar-recurring-preview {
  padding: 10px 12px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  font-size: 11px;
  color: #3730a3;
  font-weight: 600;
}

[data-theme="dark"] .calendar-recurring-preview {
  background: #1e1b4b;
  border-color: #3730a3;
  color: #c7d2fe;
}

.calendar-recurring-days {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.calendar-recurring-days .calendar-day-chip {
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
}

.calendar-recurring-days .calendar-day-chip:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.calendar-recurring-days .calendar-day-chip[data-active="true"] {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4f46e5;
}

/* ============================================
   10. FOCUS MODE (Pomodoro) OVERLAY
   ============================================ */
.calendar-focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.calendar-focus-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.calendar-focus-card {
  max-width: 420px;
  width: 100%;
  padding: 32px 28px;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  text-align: center;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.calendar-focus-overlay.active .calendar-focus-card {
  transform: scale(1);
}

[data-theme="dark"] .calendar-focus-card {
  background: #1a1f2e;
}

.calendar-focus-card .calendar-focus-label {
  font-size: 11px;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.calendar-focus-card .calendar-focus-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 64px;
  font-weight: 800;
  color: #4f46e5;
  margin: 12px 0;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}

.calendar-focus-card .calendar-focus-task {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

[data-theme="dark"] .calendar-focus-card .calendar-focus-task {
  color: #e4e7eb;
}

.calendar-focus-card .calendar-focus-client {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 20px;
}

.calendar-focus-card .calendar-focus-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.calendar-focus-card .calendar-focus-actions button {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.calendar-focus-card .calendar-focus-pause {
  background: #f1f5f9;
  color: #475569;
}
.calendar-focus-card .calendar-focus-pause:hover {
  background: #e2e8f0;
}

.calendar-focus-card .calendar-focus-stop {
  background: #be123c;
  color: #ffffff;
}
.calendar-focus-card .calendar-focus-stop:hover {
  background: #9f1239;
}

/* ============================================
   11. EMPTY STATE
   ============================================ */
.calendar-empty {
  padding: 60px 24px;
  text-align: center;
}

.calendar-empty .calendar-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 12px;
  background: #eef2ff;
  border-radius: 16px;
  color: #6366f1;
}

.calendar-empty h3 {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.calendar-empty p {
  margin: 0 auto;
  font-size: 12px;
  color: #64748b;
  max-width: 400px;
}

[data-theme="dark"] .calendar-empty h3 { color: #e4e7eb; }
[data-theme="dark"] .calendar-empty p { color: #9ca3af; }
[data-theme="dark"] .calendar-empty .calendar-empty-icon {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

/* ============================================
   12. LOADING STATE
   ============================================ */
.calendar-loading {
  padding: 60px 24px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

.calendar-loading::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid #cbd5e1;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: calendar-spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes calendar-spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   13. LEGEND
   ============================================ */
.calendar-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 10px;
  color: #64748b;
}

[data-theme="dark"] .calendar-legend {
  background: #131824;
  border-color: #2a3142;
  color: #9ca3af;
}

.calendar-legend .calendar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
}

.calendar-legend .calendar-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.calendar-legend .calendar-legend-dot[data-type="conflict"] { background: #ef4444; }
.calendar-legend .calendar-legend-dot[data-type="completed"] { background: #10b981; }
.calendar-legend .calendar-legend-dot[data-type="focus"] { background: #f59e0b; }
.calendar-legend .calendar-legend-dot[data-type="normal"] { background: #6366f1; }