/* ProgramarIA — Custom styles on top of Pico CSS */

:root {
  --brand-primary: #1565C0;
  --brand-secondary: #00897B;
  --brand-light: #E3F2FD;
  --brand-accent: #FF8F00;
  --kpi-green: #2E7D32;
  --kpi-orange: #E65100;
  --kpi-red: #C62828;
  --cell-edited: #FF8F00;
  --drop-valid: #C8E6C9;
  --drop-invalid: #FFCDD2;
}

/* Layout */
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #FAFAFA;
}

.app-header {
  background: var(--brand-primary);
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.app-header .subtitle {
  opacity: 0.85;
  font-size: 0.85rem;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 20px 0 28px;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  border: 2px solid #CCC;
  color: #999;
  background: white;
  transition: all 0.3s;
}

.stepper-step.active .stepper-circle {
  border-color: var(--brand-primary);
  background: var(--brand-primary);
  color: white;
}

.stepper-step.completed .stepper-circle {
  border-color: var(--kpi-green);
  background: var(--kpi-green);
  color: white;
}

.stepper-label {
  font-size: 0.85rem;
  color: #999;
  font-weight: 500;
}

.stepper-step.active .stepper-label { color: var(--brand-primary); font-weight: 600; }
.stepper-step.completed .stepper-label { color: var(--kpi-green); }

.stepper-line {
  width: 80px;
  height: 2px;
  background: #DDD;
  margin: 0 8px;
}

.stepper-line.completed { background: var(--kpi-green); }

/* Cards */
.card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #333;
}

/* KPI Cards */
.kpi-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.kpi-card {
  background: white;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: center;
  min-width: 140px;
  flex: 1;
}

.kpi-card .kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 4px 0;
}

.kpi-card .kpi-label {
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-green .kpi-value { color: var(--kpi-green); }
.kpi-orange .kpi-value { color: var(--kpi-orange); }
.kpi-red .kpi-value { color: var(--kpi-red); }

/* Info cards row */
.info-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.info-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-card .info-icon {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-light);
}

.info-card .info-text h4 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.info-card .info-text p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #666;
}

/* Form */
.form-row {
  display: flex;
  gap: 16px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="date"] {
  padding: 8px 12px;
  border: 1px solid #CCC;
  border-radius: 6px;
  font-size: 0.95rem;
  min-width: 180px;
  background: white;
}

/* Buttons */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) { background: #0D47A1; }

.btn-success {
  background: var(--kpi-green);
  color: white;
}

.btn-success:hover:not(:disabled) { background: #1B5E20; }

.btn-outline {
  background: white;
  color: var(--brand-primary);
  border: 2px solid var(--brand-primary);
}

.btn-outline:hover:not(:disabled) { background: var(--brand-light); }

.btn-secondary {
  background: #78909C;
  color: white;
}

.btn-secondary:hover:not(:disabled) { background: #546E7A; }

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Heatmap / Grid table */
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  overflow-x: auto;
  display: block;
}

.grid-table th,
.grid-table td {
  padding: 3px 4px;
  text-align: center;
  border: 1px solid #E0E0E0;
  white-space: nowrap;
  font-size: 0.7rem;
}

.grid-table th {
  background: #F5F5F5;
  font-weight: 600;
  color: #555;
  position: sticky;
  top: 0;
  z-index: 1;
}

.grid-table th:first-child,
.grid-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: white;
  z-index: 2;
  min-width: 120px;
  font-weight: 500;
}

.grid-table th:first-child {
  background: #F5F5F5;
  z-index: 3;
}

/* Heatmap colors */
.heat-0 { background: #F5F5F5; color: #BBB; }
.heat-1 { background: #BBDEFB; }
.heat-2 { background: #90CAF9; }
.heat-3 { background: #64B5F6; }
.heat-4 { background: #42A5F5; color: white; }
.heat-5 { background: #1E88E5; color: white; }

/* Schedule grid cells */
.schedule-cell {
  min-width: 60px;
  min-height: 28px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: grab;
  padding: 2px 4px;
  transition: box-shadow 0.15s;
  user-select: none;
}

.schedule-cell:active { cursor: grabbing; }

.schedule-cell.dragging {
  opacity: 0.5;
}

.schedule-cell.drop-target {
  box-shadow: 0 0 0 2px var(--kpi-green);
  background: var(--drop-valid) !important;
}

.schedule-cell.drop-invalid {
  box-shadow: 0 0 0 2px var(--kpi-red);
  background: var(--drop-invalid) !important;
}

.schedule-cell.edited {
  border: 2px dashed var(--cell-edited) !important;
}

.schedule-cell.free {
  background: #FFF9C4 !important;
  color: #F57F17;
  cursor: default;
}

.schedule-cell.rest-day {
  background: #EEEEEE !important;
  color: #999;
  cursor: default;
  font-style: italic;
}

.schedule-cell.empty {
  background: #FAFAFA;
  color: #CCC;
  cursor: default;
}

/* Workstation color palette */
.ws-color-0 { background: #E3F2FD; color: #1565C0; }
.ws-color-1 { background: #E8F5E9; color: #2E7D32; }
.ws-color-2 { background: #FFF3E0; color: #E65100; }
.ws-color-3 { background: #F3E5F5; color: #6A1B9A; }
.ws-color-4 { background: #E0F2F1; color: #00695C; }
.ws-color-5 { background: #FCE4EC; color: #AD1457; }
.ws-color-6 { background: #FFF8E1; color: #F57F17; }
.ws-color-7 { background: #E8EAF6; color: #283593; }
.ws-color-8 { background: #EFEBE9; color: #4E342E; }
.ws-color-9 { background: #E0F7FA; color: #006064; }

/* Progress */
.progress-container {
  text-align: center;
  padding: 40px 20px;
}

.progress-bar-track {
  width: 100%;
  max-width: 500px;
  height: 12px;
  background: #E0E0E0;
  border-radius: 6px;
  margin: 20px auto;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 6px;
  transition: width 0.5s ease-out;
  width: 0%;
}

.progress-time {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand-primary);
  margin: 16px 0;
}

.progress-step {
  font-size: 1rem;
  color: #555;
  margin: 8px 0;
}

.progress-info {
  background: var(--brand-light);
  border-radius: 8px;
  padding: 16px;
  margin: 24px auto;
  max-width: 500px;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.5;
}

/* Tabs */
.tab-bar {
  display: flex;
  border-bottom: 2px solid #E0E0E0;
  margin-bottom: 16px;
  gap: 0;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  color: #777;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

.tab-btn:hover:not(.active) { color: #333; }

/* Day selector */
.day-selector {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.day-btn {
  padding: 6px 14px;
  border: 1px solid #CCC;
  background: white;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.day-btn.active {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

.day-btn.holiday {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
  font-weight: 600;
}

.day-btn.holiday.active {
  background: var(--brand-accent);
  color: white;
  border-color: var(--brand-accent);
}

/* Status banner */
.status-banner {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1.1rem;
  text-align: left;
  margin-bottom: 16px;
}

.status-optimal { background: #C8E6C9; color: #1B5E20; }
.status-feasible { background: #FFE0B2; color: #E65100; }
.status-partial { background: #FFCDD2; color: #B71C1C; }

.status-line { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.status-line + .status-line { margin-top: 4px; }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.status-dot-optimal { background: #2E7D32; }
.status-dot-feasible { background: #E65100; }
.status-dot-partial { background: #C62828; }

/* Help button */
.help-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  border: none;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  z-index: 1000;
  transition: transform 0.2s;
}

.help-btn:hover { transform: scale(1.1); }

/* Help dialog */
.help-dialog {
  border: none;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.help-dialog::backdrop {
  background: rgba(0,0,0,0.4);
}

.help-dialog h3 {
  margin: 0 0 16px;
  color: var(--brand-primary);
}

.help-dialog ul {
  padding-left: 20px;
  line-height: 1.6;
}

.help-dialog li {
  margin-bottom: 8px;
}

.help-dialog .close-btn {
  margin-top: 16px;
  padding: 8px 24px;
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Confirmation dialog */
.confirm-dialog {
  border: none;
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
}

.confirm-dialog::backdrop { background: rgba(0,0,0,0.4); }

.confirm-dialog p {
  font-size: 1rem;
  margin: 16px 0;
}

/* Toast notification */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 2000;
  transform: translateX(120%);
  transition: transform 0.3s ease-out;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show { transform: translateX(0); }
.toast-success { background: var(--kpi-green); }
.toast-error { background: var(--kpi-red); }

/* Summary table */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.summary-table th,
.summary-table td {
  padding: 8px 12px;
  border: 1px solid #E0E0E0;
  text-align: center;
}

.summary-table th {
  background: #F5F5F5;
  font-weight: 600;
}

.summary-table td:first-child {
  text-align: left;
  font-weight: 500;
}

/* Coverage bar */
.coverage-bar {
  height: 8px;
  background: #E0E0E0;
  border-radius: 4px;
  overflow: hidden;
  min-width: 60px;
}

.coverage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

/* Weekly table (Por Puesto / Por Empleado) */
.weekly-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.weekly-table th,
.weekly-table td {
  padding: 4px 5px;
  border: 1px solid #E0E0E0;
  vertical-align: top;
  overflow: hidden;
}

.weekly-table th {
  background: #F5F5F5;
  font-weight: 600;
  color: #555;
  text-align: center;
  white-space: nowrap;
}

.weekly-row-label {
  font-weight: 500;
  white-space: nowrap;
  width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: white;
}

.weekly-cell {
  overflow: hidden;
}

.weekly-chip {
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
  cursor: grab;
}

.weekly-chip:active { cursor: grabbing; }
.weekly-chip.dragging { opacity: 0.5; }

.weekly-cell.weekly-drop-valid {
  background: var(--drop-valid);
  box-shadow: inset 0 0 0 2px var(--kpi-green);
}

.weekly-cell.weekly-drop-invalid {
  background: var(--drop-invalid);
  box-shadow: inset 0 0 0 2px var(--kpi-red);
}

.weekly-rest {
  color: #999;
  font-style: italic;
  text-align: center;
}

.weekly-rest-text {
  color: #999;
  font-style: italic;
  font-size: 0.7rem;
}

.weekly-total {
  text-align: center;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
  width: 50px;
}

/* Semaphore indicators */
.semaphore {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.semaphore-green { background: var(--kpi-green); }
.semaphore-orange { background: var(--kpi-orange); }
.semaphore-red { background: var(--kpi-red); }
.semaphore-gray { background: #BDBDBD; }
.semaphore-blue { background: var(--brand-primary); }

.holiday-header {
  color: var(--brand-accent) !important;
}

/* Responsive */
@media (max-width: 768px) {
  .form-row { flex-direction: column; }
  .info-row { flex-direction: column; }
  .kpi-row { flex-direction: column; }
  .app-header h1 { font-size: 1rem; }
  .stepper-label { display: none; }
  .stepper-line { width: 40px; }
}
