/* === AI Workflow Automation — MVP Styles === */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
}

/* --- Layout --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--gray-900);
  color: white;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 0 1.5rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--gray-700);
  margin-bottom: 1rem;
}
.sidebar-nav { list-style: none; flex: 1; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--gray-300);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: var(--primary);
  color: white;
}

.main-content { flex: 1; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 1.1rem; font-weight: 600; }

.page { padding: 1.5rem; flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; }

/* --- Cards --- */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}
.card-header h2 { font-size: 1rem; font-weight: 600; }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--gray-700);
}
.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-pending   { background: var(--gray-200); color: var(--gray-700); }
.badge-running   { background: #dbeafe; color: var(--primary); }
.badge-waiting   { background: #fef3c7; color: var(--warning); }
.badge-completed { background: #dcfce7; color: var(--success); }
.badge-failed    { background: #fee2e2; color: var(--danger); }

/* --- Table --- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  text-align: left;
  padding: 0.75rem;
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-700);
}
tbody td { padding: 0.75rem; border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--gray-50); }
tbody tr { cursor: pointer; }

/* --- Alerts --- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.alert-success { background: #dcfce7; color: var(--success); border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: var(--danger); border: 1px solid #fecaca; }

/* --- Loading spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Steps progress --- */
.steps { display: flex; flex-direction: column; gap: 0.5rem; }
.step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.step-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.step-pending  .step-icon { background: var(--gray-200); color: var(--gray-500); }
.step-running  .step-icon { background: #dbeafe; color: var(--primary); }
.step-completed .step-icon { background: #dcfce7; color: var(--success); }
.step-failed   .step-icon { background: #fee2e2; color: var(--danger); }
/* Phase 2 StepState strings (waiting/in_progress/met/failed) differ from the
   legacy status strings above (pending/running/completed/failed) — used by
   the Workflow Designer's step-card list (Day 40). */
.state-waiting     .step-icon { background: var(--gray-200); color: var(--gray-500); }
.state-in_progress .step-icon { background: #dbeafe; color: var(--primary); }
.state-met         .step-icon { background: #dcfce7; color: var(--success); }
.state-failed      .step-icon { background: #fee2e2; color: var(--danger); }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand, .sidebar-nav li a span { display: none; }
  .sidebar-nav li a { justify-content: center; padding: 0.75rem; }
}

/* --- Participant action pages (Approve/Reject, Upload, etc.) --- */
.action-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.action-page-inner { width: 100%; max-width: 560px; }

.approve-reject-toggle { display: flex; gap: 0.75rem; }
.toggle-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
  color: var(--gray-700);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.toggle-approve.active { border-color: var(--success); background: #dcfce7; color: var(--success); }
.toggle-reject.active { border-color: var(--danger); background: #fee2e2; color: var(--danger); }

/* --- Uploaded content panel (Approve/Reject GUI) --- */
.upload-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.upload-thumb-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  width: 96px;
  text-decoration: none;
}
.upload-thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}
.upload-thumb-name {
  font-size: 0.75rem;
  color: var(--gray-700);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.upload-doc-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--gray-900);
  font-size: 0.875rem;
}
.upload-doc-link:hover { background: var(--gray-50); }
.upload-doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-doc-action { color: var(--primary); font-weight: 600; font-size: 0.8rem; flex-shrink: 0; }

/* --- Drag-drop upload GUI --- */
.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1rem;
}
.dropzone.dragover { border-color: var(--primary); background: #eff6ff; }
.dropzone p { margin-bottom: 0.5rem; }

.upload-row {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.625rem 0.75rem;
  margin-bottom: 0.5rem;
}
.upload-row-main { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.upload-row-name { font-size: 0.875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row-status { display: flex; align-items: center; gap: 0.375rem; flex-shrink: 0; }
.upload-validation { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--gray-100); }

.upload-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
}
.upload-history-row:last-child { border-bottom: none; }
.upload-history-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Enter Free Times GUI --- */
.slot-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.slot-row .form-control { width: auto; flex: 1; min-width: 110px; }
.slot-sep { color: var(--gray-500); font-size: 0.875rem; }

/* --- Utility --- */
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.875rem; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* Language switcher (js/i18n.js) */
.lang-select {
  font-size: 0.8125rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
}
.lang-switch-floating { position: fixed; top: 0.75rem; right: 0.75rem; z-index: 10; }
