/* employee_monthly_status.css - Employee Monthly Status View Styling */
/* Updated to match multi_view_main.css styling consistency */

/* Font family inherits from body's shared CJK-safe stack — no per-view override.
   Kerning/legibility hints kept for the CJK-heavy data grid. */
#monthly-view {
  font-feature-settings: "kern" 1;
  text-rendering: optimizeLegibility;
}

/* Monthly View Container */
#monthly-view {
  display: none;
  flex-direction: column;
  height: 100%;
}

/* #monthly-attendance-info visual styling now comes from .view-info-band
   (applied via class on the element itself). Duplicate ID rule removed. */

/* Monthly Summary Profile (consistent with request_review_profile) */
#monthly_summary_profile,
#monthly-summary-profile {
  margin-left: 10px;
  margin-bottom: 10px;
  padding: 0;
  display: inline-block;
}

#monthly_summary_profile table,
#monthly-summary-profile table {
  width: auto;
  border-collapse: separate;
  border-spacing: 20px 4px;
  border: 1px solid #ced4da;
  table-layout: fixed;
}

#monthly_summary_profile td,
#monthly-summary-profile td {
  padding: 5px;
  text-align: left;
}

#monthly_summary_profile label,
#monthly-summary-profile label {
  font-size: 13px;
  white-space: nowrap;
  display: inline-block;
}

#monthly_summary_profile select,
#monthly-summary-profile select {
  font-size: 13px;
  padding: 3px 6px;
  width: auto;
  box-sizing: border-box;
}

#monthly_summary_profile button,
#monthly-summary-profile button {
  padding: 6px 12px;
  font-size: 14px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

#monthly_summary_profile button:disabled,
#monthly-summary-profile button:disabled {
  background-color: #cccccc;
  color: #666666;
  cursor: not-allowed;
  opacity: 0.6;
}

#monthly_summary_profile button:hover:not(:disabled),
#monthly-summary-profile button:hover:not(:disabled) {
  background-color: #0069d9;
}

/* Monthly Controls (consistent with daily/monthly controls in main) */
.monthly-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.monthly-controls label {
  font-weight: 500;
  color: #495057;
  font-size: 14px;
}

.monthly-controls select,
.monthly-controls input {
  padding: 5px 8px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 14px;
  background-color: white;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.monthly-controls select:focus,
.monthly-controls input:focus {
  outline: none;
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.monthly-controls input[type="number"] {
  width: 80px;
}

.monthly-controls button {
  padding: 5px 10px;
  background-color: #28a745;
  color: white;
  border: 1px solid #ced4da;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.15s ease-in-out;
}

.monthly-controls button:hover {
  background-color: #218838;
}

.monthly-controls button:active {
  transform: translateY(1px);
}

/* Monthly Stats Table Container (consistent with main table styling) */
.monthly-stats {
  flex-grow: 1;
  overflow-y: auto;
  border: 1px solid #ced4da;
  background-color: #fff;
  min-height: 0;
}

.monthly-stats table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.monthly-stats th,
.monthly-stats td {
  border: 1px solid #ced4da;
  padding: 6px;
  text-align: center;
  vertical-align: middle;
  /* font-size inherits 13px from .monthly-stats table */
}

.monthly-stats th {
  background-color: #dee2e6;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 10;
  color: #000;
  white-space: nowrap;
}

.monthly-stats tbody tr:nth-child(even) {
  background-color: #f8f9fa;
}

.monthly-stats tbody tr:hover {
  background-color: #e2e6ea;
  transition: background-color 0.15s ease;
}

/* Status Indicators (consistent with main status classes) */
.monthly-stats .status-present {
  color: #28a745;
  font-weight: bold;
}

.monthly-stats .status-absent {
  color: #dc3545;
  font-weight: bold;
}

.monthly-stats .status-leave {
  color: #ffc107;
  font-weight: bold;
}

.monthly-stats .status-overtime {
  color: #17a2b8;
  font-weight: bold;
}

.monthly-stats .status-warning {
  background-color: #fdeaa7 !important;
  color: #8b6914;
}

.monthly-stats .weekend {
  background-color: #f1f3f5 !important;
  color: #6c757d;
  font-style: italic;
}

/* Enhanced styling for specific columns while maintaining consistency */
/* Time cells styling */
.monthly-stats td:nth-child(2),  /* Work Hours */
.monthly-stats td:nth-child(3),  /* On (Clock In) */
.monthly-stats td:nth-child(4),  /* Off (Clock Out) */
.monthly-stats td:nth-child(5),  /* Overtime */
.monthly-stats td:nth-child(8),  /* Late-On */
.monthly-stats td:nth-child(9) { /* Early-Off */
  font-family: 'Courier New', monospace;
  /* font-size inherits 13px to match other monospace cells (Daily view) */
}

/* Clickable time cells (on-time / off-time tracking details) */
.monthly-stats td.clickable-time {
  cursor: pointer;
  font-weight: 500;
}

.monthly-stats td.clickable-time:hover {
  background-color: rgba(0, 123, 255, 0.08) !important;
  color: #0056b3;
}

.monthly-stats tr.weekend td.clickable-time {
  cursor: pointer;
  pointer-events: auto;
  font-weight: 500;
  text-decoration: none;
}

/* Work hours highlighting */
.monthly-stats td:nth-child(2) {
  font-weight: 500;
  color: #28a745;
}

/* Overtime hours highlighting */
.monthly-stats td:nth-child(5) {
  font-weight: 500;
  color: #17a2b8;
}

/* Late/Early warning colors */
.monthly-stats td:nth-child(8),  /* Late-On */
.monthly-stats td:nth-child(9) { /* Early-Off */
  font-weight: 500;
}

.monthly-stats td:nth-child(8):not(:empty):not([data-empty="true"]),
.monthly-stats td:nth-child(9):not(:empty):not([data-empty="true"]) {
  color: #dc3545;
}

.monthly-stats td.not-applicable-cell {
  color: #6c757d;
  font-family: inherit;
  font-style: italic;
  font-weight: 400;
}

/* Date column styling */
.monthly-stats td:first-child {
  font-weight: 500;
  background-color: #f1f3f5;
  color: #495057;
  min-width: 80px;
}

/* Absence column styling */
.monthly-stats td:nth-child(10) {
  font-weight: 600;
}

/* Leave category/time columns */
.monthly-stats td.monthly-leave-category-cell,
.monthly-stats td.monthly-leave-time-cell {
  font-size: 12px;
  font-weight: 500;
  white-space: pre-line;
  line-height: 1.35;
}

.monthly-stats .monthly-pending-leave-slot {
  color: #7c6f00;
  font-style: italic;
}

/* Leave cells that navigate to the request view for that day */
.monthly-stats td.monthly-leave-navigable {
  cursor: pointer;
}

/* Loading state */
.monthly-stats.loading {
  position: relative;
}

.monthly-stats.loading::after {
  content: 'Loading monthly data...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.95);
  padding: 20px;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  font-size: 14px;
  color: #6c757d;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Empty state */
.monthly-stats-empty {
  text-align: center;
  padding: 40px;
  color: #6c757d;
  font-style: italic;
  font-size: 16px;
}

/* Monthly Header (consistent with other view headers) */
.monthly-header {
  background-color: #e8f4fd;
  padding: 10px;
  border: 1px solid #bee5eb;
  margin-bottom: 10px;
  border-radius: 4px;
}

/* Responsive design (consistent with main responsive patterns) */
@media (max-width: 1200px) {
  .monthly-controls {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .monthly-stats th,
  .monthly-stats td {
    padding: 6px;
    font-size: 13px;
  }
  
  .monthly-stats td:first-child {
    min-width: 70px;
  }
}

@media (max-width: 992px) {
  .monthly-stats {
    font-size: 12px;
  }
  
  .monthly-stats th,
  .monthly-stats td {
    padding: 6px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .monthly-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .monthly-controls > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .monthly-stats {
    font-size: 13px;
  }

  .monthly-stats th,
  .monthly-stats td {
    padding: 4px;
    font-size: 13px;
  }
  
  /* All columns visible on mobile — table scrolls horizontally */
}

/* Monthly view: keep only the table body area scrollable */
#monthly-view.view-container {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Header/profile stay in normal flow and do not overlap the table */
#monthly-attendance-info,
#monthly-summary-profile,
#monthly_summary_profile {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}

/* The table container owns scrolling */
#monthly-view .monthly-stats {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  position: relative;
  z-index: 0;
}

/* Do NOT disable valid tracking cells on weekends */
.monthly-stats tr.weekend td.clickable-time {
  cursor: pointer;
  text-decoration: underline dotted currentColor;
  text-underline-offset: 3px;
  pointer-events: auto;
}

#monthly-summary-profile button,
#monthly-summary-profile select,
#monthly-summary-profile input,
#monthly-summary-profile a,
#monthly-summary-profile label,
#monthly_summary_profile button,
#monthly_summary_profile select,
#monthly_summary_profile input,
#monthly_summary_profile a,
#monthly_summary_profile label {
  pointer-events: auto;
}

/* (no columns hidden at ≤576px — horizontal scroll handles narrow viewports) */

/* Print styles (consistent with main print handling) */
@media print {
  .monthly-controls {
    display: none;
  }
  
  .monthly-stats {
    border: none;
    box-shadow: none;
    font-size: 12px;
  }
  
  .monthly-stats th {
    background: #f8f9fa !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  .monthly-stats .status-absent,
  .monthly-stats .status-leave,
  .monthly-stats .status-warning,
  .monthly-stats .weekend {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
