/* ============================================================
   PFOR Platform — Main Stylesheet
   Design: Light & Clean B2B
   ============================================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #f5f5f3;
  --bg-secondary: rgba(255, 255, 255, 0.78);
  --bg-card: #ffffff;
  --bg-card-hover: #f1f2ef;
  --bg-soft: #efefec;

  --accent-primary: #1f2937;
  --accent-secondary: #4b5563;
  --accent-gradient: linear-gradient(135deg, #111827 0%, #374151 100%);

  --text-primary: #111827;
  --text-secondary: #475569;
  --text-muted: #6b7280;

  --border-subtle: rgba(17, 24, 39, 0.08);
  --border-strong: rgba(17, 24, 39, 0.14);

  --success: #16a34a;
  --warning: #f59e0b;
  --error: #ef4444;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, Arial, sans-serif;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.08);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  position: relative;
  z-index: 1;
}

.navbar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0.9rem var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 245, 243, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
}

.brand-logo {
  width: 28px;
  height: 28px;
  background: var(--accent-gradient);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}

.brand-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}
.user-badge.hidden { display: none; }

.user-badge-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  transition: all var(--transition-fast);
}

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

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-secondary);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(37, 99, 235, 0.05);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.btn-large {
  padding: 0.8rem 1.8rem;
  font-size: 1rem;
}

.hero {
  padding: 4rem 0 2.5rem;
  text-align: left;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1.3rem;
  box-shadow: var(--shadow-sm);
}
.hero-badge-dot {
  width: 7px;
  height: 7px;
  background: var(--accent-primary);
  border-radius: 50%;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -0.05em;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.7rem;
  max-width: 720px;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 660px;
  margin: 0 0 2rem;
  line-height: 1.6;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.7fr);
  gap: 1.5rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.chat-stream {
  display: grid;
  gap: 1rem;
}

.conversation-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 0.9rem;
  align-items: flex-start;
  padding: 0.9rem 0.2rem 0.9rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.conversation-item:last-child {
  border-bottom: none;
}

.conversation-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.04);
  font-size: 1.15rem;
}

.conversation-copy h3 {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.02em;
}

.conversation-copy p {
  color: var(--text-secondary);
  font-size: 0.97rem;
  line-height: 1.55;
}

.agent-status-panel {
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 0.9rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 90px;
}

.panel-header {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.agent-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.45rem;
  border-radius: 12px;
}

.agent-state + .agent-state {
  border-top: 1px solid var(--border-subtle);
}

.agent-state strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.agent-state small {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c5c9d0;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.04);
}

.agent-state.active .state-dot {
  background: var(--text-primary);
  box-shadow: 0 0 0 5px rgba(17, 24, 39, 0.05);
}

.agent-state.pending .state-dot {
  background: rgba(17, 24, 39, 0.3);
}

.input-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: left;
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-2xl);
}

.input-card-label {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.problem-textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 150px;
  transition: border-color var(--transition-fast);
}
.problem-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.problem-textarea::placeholder {
  color: var(--text-muted);
}

.input-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-md);
}
.char-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.agents-progress {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-2xl);
  display: none;
  box-shadow: var(--shadow-sm);
}
.agents-progress.visible {
  display: block;
}

.progress-title {
  font-weight: 600;
  text-align: center;
  margin-bottom: var(--space-lg);
  color: var(--accent-primary);
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
@media (max-width: 640px) {
  .agents-grid { grid-template-columns: repeat(2, 1fr); }
}

.agent-chip {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}
.agent-chip.active {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.05);
  transform: translateY(-2px);
}
.agent-chip.done {
  border-color: var(--success);
  background: rgba(22, 163, 74, 0.05);
}

.agent-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}
.agent-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}
.agent-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.agent-chip.active .agent-status {
  color: var(--accent-primary);
  font-weight: 500;
}
.agent-chip.done .agent-status {
  color: var(--success);
  font-weight: 500;
}

.progress-bar-wrap {
  height: 6px;
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  transition: width 0.3s ease;
}

.report-section {
  display: none;
  margin-bottom: var(--space-3xl);
  animation: slideUp 0.4s ease forwards;
}
.report-section.visible {
  display: block;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.report-header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.report-header-left h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.report-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
  border-radius: var(--radius-full);
}

.report-actions {
  display: flex;
  gap: var(--space-sm);
}

.report-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
}

@media print {
  body {
    background: #ffffff;
    color: #111827;
  }

  .navbar,
  .input-card,
  .agents-progress,
  .features-strip,
  .footer,
  .report-actions,
  .modal-overlay,
  .chat-stream,
  .agent-status-panel {
    display: none !important;
  }

  .report-section {
    display: block !important;
    margin: 0;
    padding: 0;
  }

  .report-card {
    background: #ffffff;
    border: 1px solid #dbe2ea;
    box-shadow: none;
    padding: 1.25rem;
  }

  .report-content {
    color: #111827;
    font-size: 12pt;
    line-height: 1.6;
  }

  .report-content h1,
  .report-content h2,
  .report-content h3,
  .report-content strong,
  .report-content li,
  .report-content p,
  .report-content th,
  .report-content td,
  .report-content blockquote {
    color: #111827;
  }
}

.report-content {
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.7;
}

.report-content h1,
.report-content h2,
.report-content h3 {
  color: var(--text-primary);
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  font-weight: 600;
}
.report-content h1 { font-size: 1.75rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.5rem; }
.report-content h2 { font-size: 1.5rem; }
.report-content h3 { font-size: 1.25rem; }

.report-content p {
  margin-bottom: 1.25em;
}

.report-content ul,
.report-content ol {
  margin-bottom: 1.25em;
  padding-left: 1.5em;
}
.report-content li {
  margin-bottom: 0.5em;
}

.report-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.report-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95rem;
}
.report-content th,
.report-content td {
  border: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem;
  text-align: left;
}
.report-content th {
  background: var(--bg-primary);
  font-weight: 600;
  color: var(--text-primary);
}
.report-content tr:nth-child(even) {
  background: var(--bg-card-hover);
}

.report-content blockquote {
  border-left: 4px solid var(--accent-primary);
  background: var(--bg-primary);
  padding: 1rem 1.5rem;
  margin: 1.5em 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.features-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 2rem 0 0;
  border-top: 1px solid var(--border-subtle);
}
@media (max-width: 768px) {
  .features-strip { grid-template-columns: 1fr; }
}

.feature-item {
  text-align: left;
  padding: 1rem 0.25rem 0;
}
.feature-icon {
  font-size: 1.5rem;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 0.7rem;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.04);
}
.feature-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.feature-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.footer {
  text-align: center;
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}
.footer a:hover {
  color: var(--accent-primary);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity var(--transition-base);
}
.modal-overlay.hidden {
  display: none;
}


.modal {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: var(--space-xl);
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: scale(1);
  transition: transform var(--transition-base);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
  border-radius: var(--radius-sm);
}
.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.modal-header {
  text-align: center;
  margin-bottom: var(--space-lg);
}
.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.modal-tabs {
  display: flex;
  background: var(--bg-card-hover);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: var(--space-lg);
}
.modal-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.6rem 0;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.modal-tab:hover {
  color: var(--text-primary);
}
.modal-tab.active {
  background: var(--bg-secondary);
  color: var(--accent-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-group {
  margin-bottom: var(--space-md);
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}
.form-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.8rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
}
.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-input::placeholder {
  color: var(--text-muted);
}

.form-submit {
  width: 100%;
  margin-top: var(--space-sm);
}

.form-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-bottom: var(--space-sm);
  min-height: 1.2rem;
  display: none;
}
.form-error.visible {
  display: block;
}

form.hidden {
  display: none;
}

.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 500;
  animation: toastEnter 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  max-width: 300px;
}
.toast.info { border-left: 4px solid var(--accent-primary); }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }

.hidden {
  display: none !important;
}

@keyframes toastEnter {
  from { opacity: 0; transform: translateX(50px); }
  to   { opacity: 1; transform: translateX(0); }
}
