/* BASE TABLE STRUCTURE */

#calendar table {
  table-layout: fixed;
  width: 100%;
}

/* Override Bootstrap's table-bordered to ensure all borders are visible */
#calendar .table-bordered > :not(caption) > * {
  border-width: 1px !important;
}

#calendar .table-bordered > :not(caption) > * > * {
  border-width: 1px !important;
}

.first-column {
  width: 18em;
  min-width: 20em;
  font-weight: bold;
}

.allocation-row,
.project-row {
  border-bottom: 1px solid #dee2e6;
}

#calendar tbody tr {
  height: 4.5em !important;
  max-height: 4.5em !important;
}

#calendar tbody td {
  padding: 0 !important;
  vertical-align: middle !important;
}

#calendar tbody td.first-column {
  padding-left: 0.75rem !important;
}

.header-cell {
  font-weight: bold;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}

/* CELL STYLES */

.timesheet-cell {
  padding: 0 !important;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  background-color: white;
  border: 1px solid #dee2e6;
  vertical-align: middle;
  line-height: 1;
}

.cell-filled {
  background-color: #e0f0ff !important;
  color: #000 !important;
  font-weight: bold;
}

#calendar .bg-light.text-muted {
  background-color: #f8f9fa !important;
  color: #adb5bd !important;
}

/* SPECIAL DAY STATES */

/* Weekend and Non-Working Days */
.weekend-day,
.weekend-trace-marker,
.before-project,
.after-project {
  background-color: #f8f9fa !important;
  color: #888 !important;
  cursor: not-allowed;
}

#calendar .weekend-day.weekend-row,
#calendar .national-holiday {
  cursor: not-allowed;
}

.national-holiday {
  background-color: #f8f9fa !important;
  color: #888 !important;
  cursor: not-allowed;
}

.weekend-trace {
  opacity: 0.2;
  pointer-events: none;
  min-width: 8px;
  max-width: 8px;
  width: 8px;
}

/* Blocked Days */
.blocked-day {
  background-color: #ffcccc !important;
  opacity: 0.7;
}

.blocked-tag {
  color: #d9534f;
  font-weight: bold;
  font-size: 0.85em;
}

/* Today Highlighting */
.today-header {
  background-color: #e9f5ff !important;
  border-bottom: 2px solid #0d6efd !important;
}

/* LAYOUT UTILITIES */

.col-lg-2-5 {
  flex: 0 0 auto;
  width: 13.5%;
}

.col-lg-10-5 {
  flex: 0 0 auto;
  width: 86.5%;
}

/* BUTTON & DROPDOWN STYLES */

/* Button Groups */
.btn-group .dropdown-toggle {
  border-radius: 0.375rem !important;
}

.btn-group .dropdown-menu {
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-group .dropdown-item {
  transition: all 0.2s ease;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
}

.btn-group + .btn-group {
  margin-left: 0.5rem;
}

.btn-group .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Dropdown Menus */
.dropdown-menu {
  min-width: 200px;
  padding: 0.5rem 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  margin-right: 0.5rem;
}

.dropdown-item:hover,
.btn-group .dropdown-item:hover {
  background-color: #f8f9fa;
  color: #212529;
}

.dropdown-item.active,
.btn-group .dropdown-item.active {
  background-color: #0d6efd;
  color: white;
}

/* Accessibility - Focus States */
.dropdown-item:focus {
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
  background-color: #e9ecef;
}

.btn:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* YEARLY OVERVIEW */

.yearly-overview-card {
  transition: all 0.3s ease;
  cursor: default;
  border-radius: 8px;
  opacity: 1;
}

.monthly-grid {
  min-height: 140px;
}

.mini-calendar {
  font-size: 0.8em;
}

.weekday-header {
  font-weight: 600;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Allocation Level Indicators - High specificity to override weekend/holiday styles */
.yearly-overview-card .calendar-day.allocation-critical,
.calendar-day.allocation-critical {
  background-color: rgba(220, 53, 69, 0.8) !important; /* Red - 0-25% */
  border: 1px solid rgba(220, 53, 69, 0.9) !important;
  color: white !important;
  cursor: pointer !important;
}

.yearly-overview-card .calendar-day.allocation-low,
.calendar-day.allocation-low {
  background-color: rgba(255, 133, 27, 0.7) !important; /* Orange - 25-50% */
  border: 1px solid rgba(255, 133, 27, 0.8) !important;
  color: white !important;
  cursor: pointer !important;
}

.yearly-overview-card .calendar-day.allocation-medium,
.calendar-day.allocation-medium {
  background-color: rgba(255, 193, 7, 0.7) !important; /* Yellow - 50-75% */
  border: 1px solid rgba(255, 193, 7, 0.8) !important;
  color: #000 !important;
  cursor: pointer !important;
}

.yearly-overview-card .calendar-day.allocation-high,
.calendar-day.allocation-high {
  background-color: rgba(25, 135, 84, 0.8) !important; /* Green - 75-100% */
  border: 1px solid rgba(25, 135, 84, 0.9) !important;
  color: white !important;
  cursor: pointer !important;
}

/* National Holidays in Mini-Calendar */
.calendar-day.national-holiday {
  background-color: rgba(108, 117, 125, 0.3) !important;
  border: 1px solid rgba(108, 117, 125, 0.6) !important;
  color: #495057 !important;
  font-weight: 500 !important;
  position: relative;
}

/* Today Highlighting with Allocation */
.calendar-day.bg-primary.allocation-high,
.calendar-day.bg-primary.allocation-medium,
.calendar-day.bg-primary.allocation-low,
.calendar-day.bg-primary.allocation-critical {
  border: 2px solid #fff !important;
  box-shadow: 0 0 0 2px #0d6efd !important;
}

.yearly-overview-card .bg-primary {
  animation: pulse 2s infinite;
}

/* Monthly Statistics Styling */
.stat-item {
  padding: 2px;
  cursor: help;
  transition: transform 0.2s ease;
}

.stat-item:hover {
  transform: translateY(-1px);
}

.stat-number {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  transition: all 0.3s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Animation for Card Loading */
.col-lg-3:nth-child(1) .yearly-overview-card { animation-delay: 0.1s; }
.col-lg-3:nth-child(2) .yearly-overview-card { animation-delay: 0.2s; }
.col-lg-3:nth-child(3) .yearly-overview-card { animation-delay: 0.3s; }
.col-lg-3:nth-child(4) .yearly-overview-card { animation-delay: 0.4s; }
.col-lg-3:nth-child(5) .yearly-overview-card { animation-delay: 0.5s; }
.col-lg-3:nth-child(6) .yearly-overview-card { animation-delay: 0.6s; }
.col-lg-3:nth-child(7) .yearly-overview-card { animation-delay: 0.7s; }
.col-lg-3:nth-child(8) .yearly-overview-card { animation-delay: 0.8s; }
.col-lg-3:nth-child(9) .yearly-overview-card { animation-delay: 0.9s; }
.col-lg-3:nth-child(10) .yearly-overview-card { animation-delay: 1.0s; }
.col-lg-3:nth-child(11) .yearly-overview-card { animation-delay: 1.1s; }
.col-lg-3:nth-child(12) .yearly-overview-card { animation-delay: 1.2s; }

/* ANIMATIONS */

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.7);
  }
  70% {
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0);
  }
}

/* RESPONSIVE DESIGN */

/* Large Screens */
@media (max-width: 991.98px) {
  #allocationControls {
    margin-top: 1rem;
  }
  
  #allocationControls .btn-group {
    margin-bottom: 0.5rem;
  }
}

/* Tablets */
@media (max-width: 768px) {
  .monthly-grid {
    min-height: 120px;
  }
  
  .mini-calendar {
    font-size: 0.7em;
  }
  
  .calendar-day {
    min-height: 18px;
  }
  
  .project-indicator {
    width: 3px;
    height: 3px;
  }
  
  .yearly-overview-card {
    margin-bottom: 15px;
  }
}

/* Mobile */
@media (max-width: 576px) {
  .yearly-overview-card {
    margin-bottom: 20px;
  }
  
  .stat-number {
    font-size: 0.8em !important;
  }
  
  .stat-label {
    font-size: 0.6em !important;
  }
}

/* RESERVED ALLOCATIONS STYLING */

/* Reserved Allocation Visual Styling - Striped Background Pattern */
/* Apply pattern to the cell containing reserved allocations, not the icon */
.timesheet-cell:has(.allocation[data-status="reserved"]),
.timesheet-cell:has(.allocation-block[data-status="reserved"]) {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(127, 134, 140, 0.2) 4px,
    rgba(116, 123, 128, 0.2) 8px
  ) !important;
}

/* Keep allocation icon transparent so pattern shows through */
.allocation[data-status="reserved"],
.allocation-block[data-status="reserved"],
a.allocation[data-status="reserved"],
a.allocation-block[data-status="reserved"],
.allocation.allocation-block[data-status="reserved"] {
  background-color: transparent;
  background-image: none;
}

/* Prevent table hover from overriding reserved allocation background */
.table-hover tbody tr:hover {
  background-color: transparent !important;
}

.table > :not(caption) > * > * {
  box-shadow: none !important;
}

/* RESERVED ALLOCATIONS FILTER */

/* Hide Reserved Allocations */
body.hide-reserved-allocations .allocation[data-status="reserved"],
body.hide-reserved-allocations .allocation-block[data-status="reserved"],
body.hide-reserved-allocations a.allocation[data-status="reserved"],
body.hide-reserved-allocations a.allocation-block[data-status="reserved"],
body.hide-reserved-allocations .allocation.allocation-block[data-status="reserved"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Update Hour Display */
body.hide-reserved-allocations .allocation-hours-display .total-hours-normal {
  display: none !important;
}

body.hide-reserved-allocations .allocation-hours-display .total-hours-filtered {
  display: inline !important;
}

/* Remove Styling from Reserved Days in Yearly View */
body.hide-reserved-allocations .calendar-day[data-purely-reserved="true"].allocation-high,
body.hide-reserved-allocations .calendar-day[data-purely-reserved="true"].allocation-medium,
body.hide-reserved-allocations .calendar-day[data-purely-reserved="true"].allocation-low,
body.hide-reserved-allocations .calendar-day[data-purely-reserved="true"].allocation-critical {
  background-color: transparent !important;
  border: none !important;
  color: inherit !important;
}

/* Note: Overbooked warnings are handled in allocation_overbooked.css */