/* company_daily_stats.css - Company Daily Statistics View Styling */

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

/* Daily Header — visual styling now comes from .view-info-band.
   Only Daily-specific tweaks remain. */
.daily-header {
  /* margin-bottom inherited from .view-info-band (10px) */
  white-space: normal;  /* daily inner content can wrap if needed */
}

h3.daily-header-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
  font: inherit;   /* inherit 16px/bold from parent .view-info-band */
}

/* Inline cluster: month triangle, day step, date, day step, month triangle. */
.daily-date-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-left: 2px;
}

/* All children of the h3 inherit its bold/prominent font.
   The date display is just inline text — same size, same weight. */
.daily-date-display {
  font: inherit;
  line-height: 1;
}

/* yyyy-mm portion — clickable on all viewports, opens month picker. */
.daily-date-month-btn {
  font: inherit;
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

.daily-date-month-btn:hover {
  color: #1d4ed8;
}

/* dd portion — plain text on desktop (days list is in the left sidebar),
   styled as a link only on mobile (where it triggers the days sheet). */
.daily-date-day-btn {
  font: inherit;
}

#days-list-prev-month,
.daily-day-step-btn,
#days-list-next-month {
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}

#days-list-prev-month:hover,
.daily-day-step-btn:hover,
#days-list-next-month:hover {
  background: rgba(0,0,0,0.14);
}

#days-list-prev-month:active,
.daily-day-step-btn:active,
#days-list-next-month:active {
  background: #d1d5db;
}

/* ── Selected day's calendar event, at the right end of the band ──────────
   The day-list Event column is narrow and clips a merged multi-site label
   ('Typhoon LA; Compensatory Work Day SJ'), so the header carries the full
   text. Pushed right with margin-left:auto; wraps rather than widening the
   band (which scrolls horizontally). Empty on a day with no event. */
.daily-header-event {
  margin-left: auto;
  max-width: 55%;
  padding: 1px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 0.8125em;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
  text-align: right;
  color: #4b4324;              /* same ink as the band's own label chip */
}

.daily-header-event:empty {
  display: none;               /* no event → the band looks exactly as before */
}

/* Off-day: the app-wide off-day palette (same as both date pickers). */
.daily-header-event.is-off-day {
  background: #ffe5e5;
  border-color: #f5c6cb;
  color: #721c24;
}

/* A declared work day (make-up day) — reads as "this one IS worked". */
.daily-header-event.is-work-day {
  background: #e6f4ea;
  border-color: #b7e0c4;
  color: #14622c;
}

#days-list-prev-month,
#days-list-next-month {
  font-size: 0;
}

#days-list-prev-month::before {
  content: '\25C0';
  font-size: 14px;
  color: #2563eb;
  line-height: 1;
}

#days-list-next-month::before {
  content: '\25B6';
  font-size: 14px;
  color: #2563eb;
  line-height: 1;
}

.daily-day-step-btn {
  font-size: 0;
}

#daily-prev-day::before,
#daily-next-day::before {
  display: block;
  font-size: 17px;
  line-height: 1;
  transform: translateY(-1px);
}

#daily-prev-day::before {
  content: '<';
}

#daily-next-day::before {
  content: '>';
}

/* Daily Summary Statistics */
.daily-summary-stats {
  margin-top: 8px;
  margin-left: 0;
  margin-bottom: 10px;
  padding: 0;
  display: inline-block;
}

.daily-header .daily-summary-stats {
  margin-top: 8px;
  margin-left: 0;
}

.daily-summary-stats table {
  width: max-content; /* each card hugs its content; table = sum of cards */
  border-collapse: separate;
  border-spacing: 10px 4px;
  border: 1px solid #ced4da;
  table-layout: auto;
  text-align: left;
}

.daily-summary-stats td.stat-card {
  /* Table is width:max-content already, so each cell naturally sizes to
     its content. No width hack needed — and a width:1% here would compute
     as ~3px when the mobile media query turns the row into a flexbox,
     squeezing every card unreadable. */
  white-space: nowrap;  /* keep label + value on one line */
}

.daily-summary-stats td {
  padding: 5px;
  text-align: left;
}

.stat-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 6px;
}

.stat-label {
  display: inline-block;
  font-size: 13px;
  color: #6c757d;
  white-space: nowrap;
  font-weight: bold;
  margin-right: 5px;
}

.stat-value {
  display: inline-block;
  font-size: 13px;
  color: #495057;
}

/* Stat card color variations */
.stat-present .stat-value { color: #28a745; }
.stat-absent .stat-value { color: #dc3545; }
.stat-leave .stat-value { color: #fd7e14; }
.stat-overtime .stat-value { color: #17a2b8; }
.stat-late .stat-value { color: #ffc107; }
.stat-rate .stat-value { color: #6f42c1; }
.stat-hours .stat-value { color: #20c997; }
.stat-total .stat-value { color: #6c757d; }

/* Daily Controls */
.daily-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 0;
  flex-wrap: wrap;
}

.daily-controls label {
  font-size: 13px;
  white-space: nowrap;
  display: inline-block;
}

.daily-controls input,
.daily-controls select,
.daily-controls button {
  padding: 6px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}

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

.daily-controls input[type="date"] {
  background-color: white;
}

.daily-controls input[type="text"] {
  min-width: 200px;
}

.daily-controls button {
  background-color: #007bff;
  color: white;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.daily-controls button:hover {
  background-color: #0069d9;
}

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

.daily-controls button.btn-secondary {
  background-color: #cccccc;
}

.daily-controls button.btn-secondary:hover {
  background-color: #b3b3b3;
}

.daily-controls button.btn-info {
  background-color: #17a2b8;
}

.daily-controls button.btn-info:hover {
  background-color: #138496;
}

/* Advanced Controls Row */
.daily-controls-advanced {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #dee2e6;
}

/* Daily Stats Table Container */
.daily-stats {
  flex-grow: 1;
  overflow-y: auto;
  border: 1px solid #ced4da;
  background-color: #fff;
  min-height: 0;
}

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

.daily-stats th,
.daily-stats td {
  border: 1px solid #ced4da;
  padding: 6px;
  text-align: center;
  vertical-align: middle;
}

.daily-stats th {
  background-color: #dee2e6;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 10;
}

.daily-stats th:nth-child(2),
.daily-stats th:nth-child(3),
.daily-stats th:nth-child(4),
.daily-stats th:nth-child(5) {
    text-align: left;
    padding-left: 6px;
}

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

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

/* Column specific styling */
.daily-stats td:nth-child(1) {
  /* Row number (#) */
  width: 30px;
  text-align: center;
}

.daily-stats td:nth-child(2) {
  /* OUcare ID */
  min-width: 70px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  text-align: left;
}

.daily-stats td:nth-child(3) {
  /* Card No */
  min-width: 70px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  text-align: left;
}

.daily-stats td:nth-child(4) {
  /* Name */
  min-width: 100px;
  text-align: left;
}

.daily-stats td:nth-child(5) {
  /* Department */
  min-width: 80px;
  text-align: left;
}

.daily-stats td:nth-child(6),
.daily-stats td:nth-child(7) {
  /* On Time / Off Time */
  min-width: 70px;
  font-family: 'Courier New', monospace;
  text-align: center;
}

.daily-stats td:nth-child(8) {
  /* Temperature */
  min-width: 60px;
  text-align: center;
}

.daily-stats td:nth-child(9) {
  /* Indicator (🟢 / 🟡 / 🔴) */
  width: 20px;
  min-width: 20px;
  text-align: center;
  font-family: inherit;
}

.daily-stats td:nth-child(10),
.daily-stats td:nth-child(11),
.daily-stats td:nth-child(12) {
  /* Late-On / Early-Off / Overtime Hours */
  min-width: 50px;
  text-align: center;
}

.daily-stats td.not-applicable-cell {
  color: #6c757d;
  font-style: italic;
  font-weight: 400;
  cursor: default;
}

.daily-stats td:nth-child(13),
.daily-stats td:nth-child(14) {
  /* Leave Category / Leave Hours */
  min-width: 70px;
  text-align: center;
}

.daily-stats td.multi-slot-leave-cell {
  white-space: pre-line;
  line-height: 1.35;
}

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

.daily-stats tr.pending-leave td.leave-category-cell,
.daily-stats tr.pending-leave td.leave-time-cell {
  background-color: rgba(255, 193, 7, 0.08);
}

.daily-stats td:nth-child(15) {
  /* Absence */
  min-width: 50px;
  text-align: center;
}

.daily-stats td:nth-child(16),
.daily-stats td:nth-child(17) {
  /* Previous Workday On / Off */
  min-width: 60px;
  font-family: 'Courier New', monospace;
  text-align: center;
}

/* Status Indicators */
.status-present {
  color: #28a745;
  font-weight: 600;
  background-color: rgba(40, 167, 69, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.status-absent {
  color: #dc3545;
  font-weight: 600;
  background-color: rgba(220, 53, 69, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.status-leave {
  color: #fd7e14;
  font-weight: 600;
  background-color: rgba(253, 126, 20, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.status-overtime {
  color: #17a2b8;
  font-weight: 600;
  background-color: rgba(23, 162, 184, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.status-in-progress {
  color: #20c997;
  font-weight: 600;
  background-color: rgba(32, 201, 151, 0.1);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.text-warning {
  color: #856404 !important;
  font-weight: 500;
}

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

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

/* Empty state */
.daily-stats-empty {
  text-align: center;
  padding: 40px !important;
  color: #6c757d;
  font-style: italic;
  background-color: #f8f9fa !important;
}

/* Filter indicator */
.filter-active {
  background-color: #007bff !important;
  color: white !important;
}

/* Search highlight */
.search-highlight {
  background-color: #fff3cd;
  padding: 2px 4px;
  border-radius: 3px;
}

/* Clickable on/off tracking cells in daily view.
   Matches request/monthly view behavior while avoiding nth-child dependency. */
.daily-stats td.clickable-time {
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
}

.daily-stats td.daily-on-time-cell,
.daily-stats td.daily-off-time-cell,
.daily-stats td.daily-prev-on-time-cell,
.daily-stats td.daily-prev-off-time-cell {
  font-family: 'Courier New', monospace;
  text-align: center;
}

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

/* Responsive design */
@media (max-width: 1200px) {
  .daily-summary-stats table {
    border-spacing: 8px 4px;
  }
  
  .stat-card {
    padding: 4px;
  }
  
  .stat-value {
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  .daily-header {
    padding: 6px 10px;
  }
  
  .daily-header h3 {
    font-size: 16px;
  }
  
  .daily-summary-stats {
    margin-left: 0;
  }

  /* Mobile layout: exactly two rows of stat-cards.
     The grid lives directly on the wrapper. Every box between the wrapper
     and the <td>s (the table, the auto-inserted tbody, and the <tr>) gets
     display: contents so the <td>s become the wrapper's direct grid items.
     This matches the pattern already used by #request_review_profile /
     #monthly_summary_profile elsewhere in this stylesheet.
     With grid-auto-flow: column and grid-template-rows: repeat(2, auto),
     7 cards land in 4 implicit columns × 2 rows. */
  .daily-summary-stats {
    display: grid;
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: 2px 8px;
    margin: 0 0 4px 0;       /* override base CSS margins */
    padding: 0;
    width: max-content;       /* can exceed viewport; #daily-summary-stats
                                  wrapper provides horizontal scroll */
    max-width: 100%;
  }

  .daily-summary-stats > table,
  .daily-summary-stats table > tbody,
  .daily-summary-stats tbody > tr {
    display: contents;
  }

  .daily-summary-stats td.stat-card {
    display: block;
    white-space: nowrap;      /* label + value on one line */
  }

  /* Mobile-only: dd becomes a clickable link to open the days sheet
     (replaces the dropped calendar icon). */
  .daily-date-day-btn {
    color: #2563eb;
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
  }

  .daily-date-day-btn:hover {
    color: #1d4ed8;
  }
  
  .daily-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .daily-controls > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .daily-controls input[type="text"] {
    min-width: unset;
    flex-grow: 1;
  }
  
  .daily-stats {
    font-size: 10px;
  }
  
  .daily-stats th,
  .daily-stats td {
    padding: 4px 2px;
  }
  
  .daily-stats td:nth-child(3),
  .daily-stats td:nth-child(4) {
    min-width: 60px;
  }
  
  .status-present,
  .status-absent,
  .status-leave,
  .status-overtime,
  .status-in-progress {
    padding: 2px 4px;
    font-size: 10px;
  }
}

/* Print styles */
@media print {
  .daily-controls {
    display: none;
  }
  
  .daily-stats {
    border: none;
  }
  
  .daily-stats th {
    background-color: #dee2e6;
    print-color-adjust: exact;
  }
  
  .status-present,
  .status-absent,
  .status-leave,
  .status-overtime,
  .status-in-progress {
    background: transparent !important;
    border: 1px solid currentColor;
  }
}
