/**
 * TASKMATE - Calendar Styles
 * ==========================
 * Kalender-Ansicht - Modernes Light Theme
 */

/* ========================================
   CALENDAR VIEW
   ======================================== */

.view-calendar {
  display: none;
  flex-direction: column;
  padding: var(--spacing-6);
  gap: var(--spacing-4);
  background: var(--bg-main);
  height: 100%;
}

.view-calendar.active {
  display: flex !important;
}

/* Calendar Header */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-4);
  padding: var(--spacing-4) var(--spacing-5);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

.calendar-nav h2 {
  min-width: 200px;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.calendar-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
}

/* View Toggle Buttons */
.calendar-view-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: 3px;
}

.btn-toggle {
  padding: var(--spacing-2) var(--spacing-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-toggle:hover {
  color: var(--text-primary);
}

.btn-toggle.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Calendar Filter Checkbox */
.calendar-filter-checkbox {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: var(--spacing-2) var(--spacing-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.calendar-filter-checkbox:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.calendar-filter-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Calendar Filter Dropdown */
.calendar-filter-dropdown {
  position: relative;
}

.calendar-filter-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
}

.calendar-filter-btn .icon {
  width: 16px;
  height: 16px;
}

.calendar-filter-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--spacing-2);
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: var(--spacing-2);
}

.calendar-filter-menu.hidden {
  display: none;
}

.calendar-filter-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.calendar-filter-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.calendar-filter-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.calendar-filter-item.checked {
  color: var(--text-primary);
}

/* Weekday Headers */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
}

.calendar-weekday {
  padding: var(--spacing-3) var(--spacing-2);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-light);
}

.calendar-weekday:last-child {
  border-right: none;
}

/* Weekend headers */
.calendar-weekday:nth-child(6),
.calendar-weekday:nth-child(7) {
  background: rgba(0, 0, 0, 0.04);
}

/* Calendar Grid Container */
.calendar-grid {
  flex: 1;
  display: grid;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-top: none;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  min-height: 400px;
}

/* Month View Grid */
.calendar-grid.calendar-month-view {
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(100px, 1fr);
}

/* Week View Grid */
.calendar-grid.calendar-week-view {
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: 1fr;
}

/* ========================================
   MONTH VIEW - CALENDAR DAY
   ======================================== */

.calendar-day {
  padding: var(--spacing-2);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
  background: var(--bg-card);
  min-height: 100px;
  overflow: visible;
  position: relative;
}

.calendar-day:nth-child(7n) {
  border-right: none;
}

.calendar-day:hover {
  background: var(--bg-tertiary);
}

.calendar-day.other-month {
  opacity: 0.4;
  background: var(--bg-tertiary);
}

.calendar-day.today {
  background: var(--primary-light);
}

.calendar-day-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--spacing-1);
  box-sizing: border-box;
  flex-shrink: 0;
  /* Reserve same space with transparent border for consistent sizing */
  border: 2px solid transparent;
  border-radius: var(--radius-full);
}

.calendar-day.today .calendar-day-number {
  background: var(--primary);
  color: var(--text-inverse);
  /* Border is already set, no size change occurs */
}

/* Calendar Tasks in Month View */
.calendar-day-tasks {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  margin-left: calc(-1 * var(--spacing-2));
  margin-right: calc(-1 * var(--spacing-2));
  padding-left: var(--spacing-2);
  padding-right: var(--spacing-2);
}

.calendar-task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: var(--font-medium);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid #6B7280;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-primary);
}

.calendar-task:hover {
  filter: brightness(0.92);
}

.calendar-task-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User badges container - for multiple assignees */
.calendar-task-badges {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* User badge - shows initials with user color */
.calendar-task-user-badge {
  flex-shrink: 0;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: var(--font-bold);
  color: white;
  background: #6B7280;
  border-radius: var(--radius-sm);
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

.calendar-task.overdue {
  position: relative;
}

.calendar-task.overdue::after {
  content: '!';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  font-size: 10px;
  font-weight: bold;
  line-height: 14px;
  text-align: center;
  color: white;
  background: var(--error);
  border-radius: 50%;
}

/* Multi-day task range styles */
.calendar-task.has-range {
  border-radius: 0;
  /* Extend beyond cell boundaries including 1px cell border for seamless connection */
  margin-left: calc(-1 * var(--spacing-2) - 1px);
  margin-right: calc(-1 * var(--spacing-2));
  padding: 4px var(--spacing-2);
  /* Fixed height for consistent bar thickness across all days */
  height: 24px;
  box-sizing: border-box;
  line-height: 16px;
  /* Transparent border for middle/end - color set via inline style on start */
  border-left: 3px solid transparent;
}

.calendar-task.has-range.range-start {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  /* Start doesn't extend left into previous cell */
  margin-left: 0;
  /* Compensate for the 1px difference to maintain same width */
  padding-left: calc(var(--spacing-2) + 1px);
  /* Border color set via inline style */
}

.calendar-task.has-range.range-end {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  /* End doesn't extend right into next cell */
  margin-right: 0;
}

.calendar-task.has-range.range-middle {
  color: transparent;
}

/* Search highlight - highlighted task in calendar search */
.calendar-task.search-highlight,
.calendar-week-task.search-highlight {
  border: 3px solid var(--primary);
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
  z-index: 10;
  position: relative;
  animation: pulse-highlight 2s ease-in-out infinite;
}

/* Continuous border for multi-day tasks */
.calendar-task.search-highlight.has-range.range-start {
  border-right: none;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.calendar-task.search-highlight.has-range.range-middle {
  border-left: none;
  border-right: none;
  border-radius: 0;
}

.calendar-task.search-highlight.has-range.range-end {
  border-left: none;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

@keyframes pulse-highlight {
  0%, 100% {
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.6);
  }
}

/* Hide user badge on middle/end parts of range */
.calendar-task.has-range.range-middle .calendar-task-user-badge,
.calendar-task.has-range.range-end .calendar-task-user-badge {
  display: none;
}

.calendar-more {
  padding: 2px 6px;
  font-size: 10px;
  color: var(--text-tertiary);
  cursor: pointer;
}

.calendar-more:hover {
  color: var(--primary);
}

/* Weekends styling */
.calendar-day:nth-child(7n-1),
.calendar-day:nth-child(7n) {
  background: rgba(0, 0, 0, 0.02);
}

/* Has tasks indicator */
.calendar-day.has-tasks {
  background: var(--bg-card);
}


/* ========================================
   WEEK VIEW
   ======================================== */

.calendar-week-day {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
  background: var(--bg-card);
  min-height: 400px;
}

.calendar-week-day:last-child {
  border-right: none;
}

.calendar-week-day.today {
  background: var(--primary-light);
}


/* Week Day Header */
.calendar-week-day-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-3);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.calendar-week-day-name {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.calendar-week-day-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  margin-top: var(--spacing-1);
}

.calendar-week-day-number.today {
  background: var(--primary);
  color: var(--text-inverse);
}

/* Week Day Tasks */
.calendar-week-day-tasks {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  padding: var(--spacing-3);
  overflow-y: auto;
}

.calendar-week-empty {
  text-align: center;
  padding: var(--spacing-4);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.calendar-week-task {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  border-left: 3px solid #6B7280;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calendar-week-task:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}

.calendar-week-task.overdue {
  position: relative;
}

.calendar-week-task.overdue::after {
  content: '!';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  font-size: 11px;
  font-weight: bold;
  line-height: 16px;
  text-align: center;
  color: white;
  background: var(--error);
  border-radius: 50%;
}

.calendar-week-task-title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Week view multi-day task range styles - continuous bars like month view */
.calendar-week-task.has-range {
  border-radius: 0;
  /* Extend beyond cell boundaries for seamless connection */
  margin-left: calc(-1 * var(--spacing-3));
  margin-right: calc(-1 * var(--spacing-3));
  padding: 4px var(--spacing-3);
  /* Fixed height for consistent bar thickness */
  height: 24px;
  box-sizing: border-box;
  line-height: 16px;
  /* Transparent border for middle/end - color set via inline style on start */
  border-left: 3px solid transparent;
  position: relative;
}

.calendar-week-task.has-range.range-start {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  /* Start doesn't extend left into previous cell */
  margin-left: 0;
  /* Compensate for width difference */
  padding-left: calc(var(--spacing-3) + 3px);
  /* Border color set via inline style */
}

.calendar-week-task.has-range.range-end {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  /* End doesn't extend right into next cell */
  margin-right: 0;
  padding-right: calc(var(--spacing-3) + 3px);
}

.calendar-week-task.has-range.range-middle:empty {
  /* Hide empty middle segments that have no content */
  opacity: 0.3;
}

.calendar-week-task.has-range.range-middle:not(:empty) {
  /* Show middle segments that have content (first day of week) */
  opacity: 1;
}

/* Week Add Task Button */
.calendar-week-add-task {
  margin: var(--spacing-2) var(--spacing-3) var(--spacing-3);
  padding: var(--spacing-2);
  background: transparent;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calendar-week-add-task:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary);
  color: var(--primary);
}

/* ========================================
   REMINDER ITEMS
   ======================================== */

.calendar-reminder-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.calendar-reminder-bell {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}

/* Week view reminder styling */
.calendar-week-task.calendar-reminder-item {
  padding-right: 20px; /* Space for bell icon */
}

.calendar-week-task.calendar-reminder-item .calendar-reminder-bell {
  font-size: 12px;
}

/* Month view reminder styling */
.calendar-task.calendar-reminder-item {
  padding-right: 16px; /* Space for bell icon */
}

/* ========================================
   DAY DETAIL POPUP
   ======================================== */

.calendar-day-detail {
  position: fixed;
  min-width: 280px;
  max-width: 350px;
  max-height: 80vh;
  padding: var(--spacing-4);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calendar-day-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-4);
  padding-bottom: var(--spacing-3);
  border-bottom: 1px solid var(--border-light);
}

.calendar-day-detail-date {
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.calendar-day-detail-tasks {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  flex: 1;
  overflow-y: auto;
  margin-bottom: var(--spacing-3);
}

.calendar-detail-task {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.calendar-detail-task:hover {
  background: var(--bg-hover);
  transform: translateX(4px);
}

/* Priority Stars - siehe components.css */

.calendar-detail-title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .view-calendar {
    padding: var(--spacing-3);
  }

  .calendar-header {
    flex-direction: column;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
  }

  .calendar-nav {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-nav h2 {
    min-width: auto;
    font-size: var(--text-base);
  }

  .calendar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-weekday {
    font-size: var(--text-xs);
    padding: var(--spacing-2);
  }

  .calendar-day {
    min-height: 60px;
    padding: var(--spacing-1);
  }

  .calendar-day-number {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    font-size: var(--text-xs);
  }

  .calendar-task {
    font-size: 9px;
    padding: 1px 4px;
  }

  /* Week view on mobile - scroll horizontally */
  .calendar-grid.calendar-week-view {
    overflow-x: auto;
  }

  .calendar-week-day {
    min-width: 140px;
    min-height: 300px;
  }
}
