/* Staff Scheduling & Labor Optimization CSS */

.ss-container {
  padding: 20px;
  background: var(--bg-workspace, #fdf6e2);
  min-height: 100%;
  font-family: 'Noto Sans Thai', sans-serif;
  color: #333;
}

.ss-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--brand-primary, #F26522);
  padding-bottom: 10px;
}

.ss-header h2 {
  font-size: 24px;
  color: var(--brand-primary, #F26522);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ss-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid rgba(0,0,0,0.05);
}

.ss-widget-title {
  font-size: 16px;
  font-weight: 700;
  color: #555;
  margin-top: 0;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dashboard Grid */
.ss-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* KPI Numbers */
.ss-kpi-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--brand-primary, #F26522);
  line-height: 1;
}

.ss-kpi-label {
  font-size: 12px;
  color: #888;
  margin-top: 5px;
}

/* Alert styles */
.ss-alert {
  padding: 10px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ss-alert.warning {
  background: #fff3cd;
  color: #856404;
  border-left: 4px solid #ffeeba;
}

.ss-alert.danger {
  background: #f8d7da;
  color: #721c24;
  border-left: 4px solid #f5c6cb;
}

.ss-alert.success {
  background: #d4edda;
  color: #155724;
  border-left: 4px solid #c3e6cb;
}

/* Scheduler Form */
.ss-schedule-table {
  width: 100%;
  border-collapse: collapse;
}

.ss-schedule-table th, .ss-schedule-table td {
  padding: 10px;
  border-bottom: 1px solid #eee;
  text-align: left;
  font-size: 14px;
}

.ss-schedule-table th {
  background: #fafafa;
  font-weight: 600;
  color: #555;
}

.ss-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}

.ss-input:focus {
  outline: none;
  border-color: var(--brand-primary, #F26522);
}

.ss-btn {
  background: var(--brand-primary, #F26522);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.ss-btn:hover {
  background: #d9531e;
}

.ss-btn.secondary {
  background: #f0f0f0;
  color: #333;
}

.ss-btn.secondary:hover {
  background: #e0e0e0;
}

.ss-flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Efficiency Score indicator */
.ss-eff-bar {
  height: 8px;
  background: #eee;
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.ss-eff-fill {
  height: 100%;
  background: var(--brand-primary, #F26522);
  transition: width 0.3s;
}

/* Drill-down Table */
.ss-drilldown-table {
  width: 100%;
  border-collapse: collapse;
}

.ss-drilldown-table th, .ss-drilldown-table td {
  padding: 8px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
  text-align: left;
}

.ss-drilldown-table tr:hover {
  background: #fafafa;
  cursor: pointer;
}

.ss-badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.ss-badge.red { background: #f8d7da; color: #721c24; }
.ss-badge.green { background: #d4edda; color: #155724; }
.ss-badge.yellow { background: #fff3cd; color: #856404; }

.ss-filter-row {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .ss-filter-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ==========================================================================
   FULLY RESPONSIVE MOBILE & TABLET DESIGN (iOS & Android Optimized)
   ========================================================================== */

/* 1. Touch Optimization & Base Fluidity */
#panel-staff-scheduling {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.ss-container {
  padding: 16px;
  box-sizing: border-box;
}

/* 2. Top Navigation Tabs in ss-dashboard-view */
#ss-dashboard-view > div:first-child {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
  padding-bottom: 10px;
}

#ss-dashboard-view > div:first-child::-webkit-scrollbar {
  display: none;
}

#ss-dashboard-view > div:first-child button {
  white-space: nowrap;
  flex-shrink: 0;
  touch-action: manipulation;
}

/* 3. Hourly Staffing Chart & Peak Alignment */
.ss-hourly-card {
  width: 100%;
  box-sizing: border-box;
}

.ss-hourly-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 8px;
}

.ss-hourly-scroll-wrapper::-webkit-scrollbar {
  height: 6px;
}

.ss-hourly-scroll-wrapper::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.ss-hourly-scroll-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.ss-mobile-scroll-hint {
  display: none;
}

/* 4. Store Manager View Header & Controls */
#ss-manager-view {
  width: 100%;
  box-sizing: border-box;
}

#ss-manager-view > div:first-child {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* 5. Schedule Table Scrolling & Sticky Columns */
#ss-mgr-table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  box-sizing: border-box;
  border-radius: 10px;
}

#ss-mgr-table::-webkit-scrollbar {
  height: 6px;
}

#ss-mgr-table::-webkit-scrollbar-track {
  background: #f1f5f9;
}

#ss-mgr-table::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* 6. Station Plan & Dialog Modals */
#ss-dialog-modal {
  padding: 12px;
  box-sizing: border-box;
}

#ss-dialog-modal > div {
  max-height: calc(100vh - 36px);
  max-width: 95vw;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  box-sizing: border-box;
}

/* ==========================================================================
   BREAKPOINTS: TABLET (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  .ss-container {
    padding: 12px;
  }
  
  .ss-station-row2 {
    flex-direction: column !important;
  }

  .ss-station-chart-col,
  .ss-station-matrix-col {
    flex: 1 1 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }
}

/* ==========================================================================
   BREAKPOINTS: MOBILE PHONES (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .ss-container {
    padding: 8px 6px calc(24px + env(safe-area-inset-bottom)) 6px;
  }

  /* Dashboard View on Mobile */
  #ss-dashboard-view {
    padding: 14px 12px !important;
    border-radius: 10px !important;
  }

  #ss-dashboard-view > div:first-child {
    gap: 12px !important;
    margin-bottom: 14px !important;
  }

  #ss-dashboard-view > div:first-child button {
    font-size: 13.5px !important;
    padding-bottom: 4px !important;
  }

  #dash-chart-container {
    min-width: 520px;
  }

  /* Manager View Toolbar on Mobile */
  #ss-manager-view > div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
  }

  #ss-mgr-title {
    font-size: 15px !important;
    line-height: 1.4 !important;
    text-align: left;
  }

  #ss-manager-view > div:first-child > div:last-child {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #ss-mgr-back-dash-btn {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    justify-content: center !important;
    min-height: 42px !important;
    font-size: 13.5px !important;
  }

  #ss-mgr-date {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-height: 42px !important;
    font-size: 15px !important;
    text-align: center !important;
    box-sizing: border-box !important;
  }

  #ss-mgr-emp-btn, 
  #ss-mgr-edit-btn, 
  #ss-mgr-pdf-btn {
    min-height: 42px !important;
    font-size: 12.5px !important;
    padding: 6px 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
  }

  #ss-mgr-pdf-btn {
    grid-column: 1 / -1 !important;
  }

  /* Station Workforce Analytics */
  .ss-station-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Hourly Staffing & Peak Alignment on Mobile */
  .ss-mobile-scroll-hint {
    display: flex !important;
  }

  .ss-hourly-grid {
    min-width: 1280px !important;
    padding-bottom: 10px !important;
  }

  .ss-hourly-card {
    padding: 14px 12px !important;
  }

  /* Schedule Table Sticky Column on Mobile */
  #ss-mgr-table table {
    font-size: 12px !important;
    min-width: 820px !important;
  }

  #ss-mgr-table th, 
  #ss-mgr-table td {
    padding: 8px 6px !important;
  }

  /* Sticky first 2 columns for easy horizontal scrolling */
  #ss-mgr-table th:nth-child(1),
  #ss-mgr-table td:nth-child(1) {
    position: sticky !important;
    left: 0 !important;
    background: #ffffff !important;
    z-index: 5 !important;
    min-width: 36px !important;
    width: 36px !important;
    text-align: center !important;
  }

  #ss-mgr-table th:nth-child(2),
  #ss-mgr-table td:nth-child(2) {
    position: sticky !important;
    left: 36px !important;
    background: #ffffff !important;
    z-index: 5 !important;
    box-shadow: 3px 0 6px rgba(0, 0, 0, 0.06) !important;
  }

  #ss-mgr-table thead tr th:nth-child(1),
  #ss-mgr-table thead tr th:nth-child(2) {
    background: #f8fafc !important;
    z-index: 6 !important;
  }

  /* Touch-friendly inputs in schedule table */
  #ss-mgr-table input[type="time"],
  #ss-mgr-table select {
    min-height: 38px !important;
    font-size: 14px !important;
    padding: 4px 6px !important;
    touch-action: manipulation;
  }

  /* Station Filters Bar */
  #ss-mgr-station-filters {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 6px;
  }

  #ss-mgr-station-filters > div {
    display: inline-flex !important;
    flex-wrap: nowrap !important;
  }

  #ss-mgr-station-filters button {
    flex-shrink: 0 !important;
    min-height: 36px !important;
    touch-action: manipulation;
  }
}
