/* ==========================================================================
   Free CSH Schedule Maker - Tool Specific Layouts & Grids
   Interactive Schedule Editor, Weekly Matrix, Employee Grid, Timeline
   Full Day & Night (Dark Mode) Theme Compatibility
   ========================================================================== */

/* Main Tool Container */
.schedule-app-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-top: var(--space-4);
  margin-bottom: var(--space-8);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

/* Tool Top Action Header */
.tool-header-bar {
  background: var(--color-surface);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.tool-title-input-wrap {
  flex: 1 1 300px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.schedule-title-input {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-main);
  border: 1px solid transparent;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: transparent;
  width: 100%;
  max-width: 450px;
  transition: all var(--transition-fast);
}
.schedule-title-input:hover {
  border-color: var(--color-border);
  background: var(--color-surface-subtle);
}
.schedule-title-input:focus {
  background: var(--color-surface);
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.tool-actions-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Tool Settings & Controls Toolbar */
.tool-toolbar {
  background: var(--color-surface-subtle);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.toolbar-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.control-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-main);
}
.control-item select,
.control-item input {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-main);
}

/* Days of Week Filter Pills */
.days-toggle-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.day-pill-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.day-pill-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.day-pill-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

/* Schedule Main Workspace (Split / Live Preview) */
.schedule-workspace {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 520px;
}
@media (min-width: 1024px) {
  .schedule-workspace.with-sidebar {
    grid-template-columns: 360px 1fr;
  }
}

/* Items Sidebar / List */
.schedule-sidebar {
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.sidebar-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.schedule-items-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
  max-height: 580px;
  padding-right: var(--space-1);
}

/* Schedule Item Card in List */
.schedule-item-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: all var(--transition-fast);
  position: relative;
}
.schedule-item-card:hover {
  border-color: var(--color-border-dark);
  box-shadow: var(--shadow-sm);
}
.schedule-item-card.has-conflict {
  border-color: var(--color-danger);
  background-color: var(--color-danger-bg);
}
.item-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.item-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text-main);
  margin-bottom: 2px;
}
.item-card-time {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.item-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.item-card-actions button {
  background: none;
  border: none;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.item-card-actions button:hover {
  background: var(--color-surface-subtle);
  color: var(--color-text-main);
}
.item-card-actions button.btn-delete-item:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}
.item-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: 0.75rem;
}
.item-card-days {
  color: var(--color-text-muted);
}

/* Category Badge Indicators */
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}
.cat-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.cat-work { background: var(--cat-work-bg); color: var(--cat-work); }
.cat-personal { background: var(--cat-personal-bg); color: var(--cat-personal); }
.cat-meeting { background: var(--cat-meeting-bg); color: var(--cat-meeting); }
.cat-study { background: var(--cat-study-bg); color: var(--cat-study); }
.cat-break { background: var(--cat-break-bg); color: var(--cat-break); }
.cat-exercise { background: var(--cat-exercise-bg); color: var(--cat-exercise); }
.cat-urgent { background: var(--cat-urgent-bg); color: var(--cat-urgent); }
.cat-other { background: var(--cat-other-bg); color: var(--cat-other); }

/* Schedule Live Canvas / Preview Area */
.schedule-preview-canvas {
  background: var(--color-surface);
  padding: var(--space-6);
  overflow-x: auto;
  position: relative;
  transition: background-color var(--transition-normal);
}
.preview-watermark-header {
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: var(--space-3);
}
.preview-title-display {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text-main);
}
.preview-subtitle-display {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Conflict Alert Banner */
.conflict-alert {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning);
  color: var(--color-warning);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Empty Schedule State */
.schedule-empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
  max-width: 460px;
  margin-inline: auto;
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-inline: auto;
  margin-bottom: var(--space-4);
}

/* ==========================================================================
   Weekly Grid View
   ========================================================================== */
.weekly-grid-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  table-layout: fixed;
}
.weekly-grid-table th {
  background: var(--color-surface-subtle);
  color: var(--color-text-main);
  padding: var(--space-3) var(--space-2);
  text-align: center;
  font-size: 0.875rem;
  font-weight: 700;
  border: 1px solid var(--color-border);
}
.weekly-grid-table th.time-col-header {
  width: 85px;
  text-align: center;
}
.weekly-grid-table td {
  border: 1px solid var(--color-border);
  padding: 4px;
  vertical-align: top;
  min-height: 48px;
  background: var(--color-surface);
  transition: background-color var(--transition-fast);
}
.weekly-grid-table td.time-cell {
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding: var(--space-2) 4px;
  vertical-align: middle;
}
.weekly-cell-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 44px;
}

/* Weekly & Daily Activity Block */
.schedule-block {
  padding: 6px 8px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.3;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid currentColor;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.schedule-block:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  filter: brightness(0.96);
}
.schedule-block .block-title {
  font-weight: 700;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.schedule-block .block-time {
  font-size: 0.7rem;
  opacity: 0.85;
  display: block;
}
.schedule-block .block-person {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.9;
  display: block;
}

/* ==========================================================================
   Daily Timeline View
   ========================================================================== */
.daily-timeline-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 840px;
  margin-inline: auto;
}
.timeline-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--space-4);
  align-items: flex-start;
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed var(--color-border);
}
.timeline-time-label {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  text-align: center;
}
.timeline-events-cell {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.daily-card-event {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ==========================================================================
   Employee & Shift Schedule Matrix
   ========================================================================== */
.employee-schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}
.employee-schedule-table th {
  background: var(--color-surface-subtle);
  color: var(--color-text-main);
  padding: var(--space-3) var(--space-3);
  text-align: center;
  font-size: 0.875rem;
  font-weight: 700;
  border: 1px solid var(--color-border);
}
.employee-schedule-table th.emp-name-col {
  text-align: left;
  width: 180px;
}
.employee-schedule-table th.emp-hours-col {
  width: 100px;
}
.employee-schedule-table td {
  border: 1px solid var(--color-border);
  padding: 6px;
  vertical-align: top;
  min-height: 60px;
  background: var(--color-surface);
}
.emp-name-cell {
  background: var(--color-surface-subtle) !important;
}
.emp-name-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.emp-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text-main);
}
.emp-role {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.emp-actions-inline {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.shift-slot-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 52px;
}
.shift-badge-pill {
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  border-radius: var(--radius-md);
  padding: 4px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.shift-badge-pill.off-shift {
  background: var(--color-surface-subtle);
  border-color: var(--color-border);
  color: var(--color-text-muted);
}
.shift-badge-pill.conflict-shift {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
  color: var(--color-danger);
  animation: pulseConflict 2s infinite;
}
.emp-hours-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  background: var(--color-surface-subtle);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-text-main);
}

/* ==========================================================================
   Monthly Calendar Grid
   ========================================================================== */
.monthly-calendar-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.month-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-subtle);
  border-radius: var(--radius-lg);
}
.month-nav-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-main);
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.month-day-header {
  background: var(--color-surface-subtle);
  padding: var(--space-2);
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--color-text-main);
}
.month-day-cell {
  background: var(--color-surface);
  min-height: 95px;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.month-day-cell:hover {
  background-color: var(--color-surface-hover);
}
.month-day-cell.other-month {
  background-color: var(--color-surface-subtle);
  color: var(--color-text-muted);
  opacity: 0.6;
}
.month-day-cell.today {
  background-color: var(--color-primary-light);
}
.month-day-cell.today .day-number {
  background: var(--color-primary);
  color: #ffffff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.day-number {
  font-size: 0.8rem;
  font-weight: 700;
}
.month-event-chip {
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Class Timetable Grid
   ========================================================================== */
.class-timetable {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.class-timetable th {
  background: var(--color-surface-subtle);
  color: var(--color-text-main);
  padding: var(--space-3);
  text-align: center;
  font-weight: 700;
  border: 1px solid var(--color-border);
  font-size: 0.875rem;
}
.class-timetable td {
  border: 1px solid var(--color-border);
  padding: 6px;
  vertical-align: middle;
  text-align: center;
  min-height: 60px;
  background: var(--color-surface);
}
.class-period-card {
  background: var(--cat-study-bg);
  border-left: 3px solid var(--cat-study);
  padding: 6px;
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 0.8rem;
}
.class-subject-name {
  font-weight: 700;
  color: var(--cat-study);
  margin-bottom: 2px;
}
.class-teacher-room {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

@keyframes pulseConflict {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
