/* PRD Builder - Split-pane layout with chat and PRD editor */

:root {
  --font-sans: "Inter", sans-serif;
  --text-color: rgb(25, 25, 24);
  --bg-color: #fafafa;
  --border-color: rgba(55, 53, 47, 0.12);
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
}

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

body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-color);
  background-color: var(--bg-color);
  line-height: 1.55;
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-32) var(--space-24);
}

.app-header {
  text-align: center;
  margin-bottom: var(--space-24);
  padding: var(--space-16) var(--space-24);
  margin: calc(-1 * var(--space-32)) calc(-1 * var(--space-24)) var(--space-24);
}

.app-header__title {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text-color);
  margin: 0;
  padding-bottom: var(--space-16);
}

.app-header__title::after {
  content: "";
  display: block;
  width: 40%;
  height: 1px;
  background: var(--border-color);
  margin: var(--space-16) auto 0;
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.75);
  border: 0.5px solid rgba(55, 53, 47, 0.12);
  border-radius: 12px;
  padding: 12px 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(25, 25, 24, 0.6);
}

.select-input {
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 0.5px solid rgba(55, 53, 47, 0.16);
  background: white;
  color: rgb(25, 25, 24);
  cursor: pointer;
  outline: none;
}

.select-input:focus {
  border-color: #2383e2;
}

.segmented {
  display: inline-flex;
  background: rgba(55, 53, 47, 0.06);
  border: 0.5px solid rgba(55, 53, 47, 0.12);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.segmented-btn {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(25, 25, 24, 0.75);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.segmented-btn:hover {
  background: rgba(55, 53, 47, 0.08);
  color: rgb(25, 25, 24);
}

.segmented-btn.active {
  background: white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  color: rgb(25, 25, 24);
}

.btn-secondary {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: 0.5px solid rgba(55, 53, 47, 0.16);
  background: white;
  color: rgb(25, 25, 24);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
}

.btn-secondary:hover {
  background: rgba(55, 53, 47, 0.04);
  border-color: rgba(55, 53, 47, 0.24);
}

.split-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  height: calc(100vh - 280px);
  min-height: 600px;
}

.chat-pane,
.prd-pane {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header,
.prd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 0.5px solid rgba(55, 53, 47, 0.12);
}

.chat-header h2,
.prd-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: rgb(25, 25, 24);
}

.completeness-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(55, 53, 47, 0.08);
  color: rgba(25, 25, 24, 0.7);
}

.completeness-badge.complete {
  background: rgba(34, 197, 94, 0.12);
  color: rgb(22, 163, 74);
}

.completeness-badge.in-progress {
  background: rgba(251, 191, 36, 0.12);
  color: rgb(217, 119, 6);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 85%;
  padding: 8px 14px;
  border-radius: 20px;
  line-height: 1.45;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(15, 20, 25, 0.04);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(15, 20, 25, 0.06);
}

.message.user .bubble {
  background: #0a84ff;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 24px rgba(10, 132, 255, 0.15);
}

.message.user .bubble:hover {
  box-shadow: 0 12px 32px rgba(10, 132, 255, 0.2);
}

.message.assistant .bubble {
  background: rgba(55, 53, 47, 0.06);
  border: 0.5px solid rgba(55, 53, 47, 0.12);
  color: var(--text-color);
}

.message.assistant .bubble strong {
  color: #2383e2;
  font-weight: 600;
}

/* Markdown styling within bubbles */
.bubble p {
  margin: 0 0 8px;
}

.bubble p:last-child {
  margin: 0;
}

.bubble ul,
.bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.bubble li {
  margin: 4px 0;
}

.bubble code {
  background: rgba(55, 53, 47, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono",
    Consolas, "Courier New", monospace;
}

.message.user .bubble code {
  background: rgba(255, 255, 255, 0.2);
}

.bubble pre {
  background: rgba(55, 53, 47, 0.06);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.message.user .bubble pre {
  background: rgba(255, 255, 255, 0.15);
}

.bubble pre code {
  background: none;
  padding: 0;
}

.bubble h1,
.bubble h2,
.bubble h3 {
  margin: 12px 0 8px;
  font-weight: 600;
}

.bubble h1 {
  font-size: 18px;
}

.bubble h2 {
  font-size: 16px;
}

.bubble h3 {
  font-size: 15px;
}

.bubble a {
  color: #0a84ff;
  text-decoration: underline;
}

.message.user .bubble a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: underline;
}

/* Typing animation */
.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa3ad;
  margin-right: 6px;
  animation: blink 1s infinite;
}

.message.user .bubble .typing-dot {
  background: rgba(255, 255, 255, 0.7);
}

@keyframes blink {
  0% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

.chat-composer {
  border-top: 0.5px solid rgba(55, 53, 47, 0.12);
  padding: 16px;
}

.chat-composer textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border-radius: 10px;
  border: 0.5px solid rgba(55, 53, 47, 0.16);
  background: rgba(55, 53, 47, 0.04);
  font-size: 15px;
  line-height: 1.55;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s ease, background 0.2s ease;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif;
}

.chat-composer textarea:focus {
  background: white;
  border-color: #2383e2;
}

.chat-composer textarea::placeholder {
  color: rgba(25, 25, 24, 0.4);
}

.chat-composer .btn-primary {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 50px;
  background: #000000;
  color: white;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.chat-composer .btn-primary:hover:not(:disabled) {
  background: #1a1a1a;
}

.chat-composer .btn-primary:active:not(:disabled) {
  background: #333333;
}

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

.chat-composer .btn-primary svg {
  width: 18px;
  height: 18px;
}

.prd-editor {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  color: rgba(25, 25, 24, 0.5);
  font-size: 15px;
  padding: 40px 20px;
}

.prd-section {
  margin-bottom: 24px;
  border: 0.5px solid rgba(55, 53, 47, 0.12);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.prd-section.section-updated {
  border-color: #2383e2;
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.1);
  animation: highlightUpdate 0.5s ease;
}

@keyframes highlightUpdate {
  0% {
    background-color: rgba(35, 131, 226, 0.05);
  }
  100% {
    background-color: transparent;
  }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(55, 53, 47, 0.04);
  border-bottom: 0.5px solid rgba(55, 53, 47, 0.12);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: rgb(25, 25, 24);
}

.section-status {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-draft {
  background: rgba(55, 53, 47, 0.08);
  color: rgba(25, 25, 24, 0.6);
}

.status-needs-info {
  background: rgba(251, 191, 36, 0.12);
  color: rgb(217, 119, 6);
}

.status-ready {
  background: rgba(34, 197, 94, 0.12);
  color: rgb(22, 163, 74);
}

.section-content {
  padding: 16px;
}

.section-editor {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border-radius: 8px;
  border: 0.5px solid rgba(55, 53, 47, 0.16);
  background: white;
  font-size: 15px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s ease;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Helvetica, Arial, sans-serif;
}

.section-editor:focus {
  border-color: #2383e2;
  box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.1);
}

.section-editor::placeholder {
  color: rgba(25, 25, 24, 0.4);
}

.prd-status {
  font-size: 13px;
}

.prd-status .status-ready {
  color: rgb(22, 163, 74);
  font-weight: 500;
}

.prd-status .status-draft {
  color: rgba(25, 25, 24, 0.6);
}

.error {
  margin-top: 10px;
  font-size: 14px;
  color: #991b1b;
  background: rgba(211, 47, 47, 0.08);
  border: 0.5px solid rgba(211, 47, 47, 0.18);
  border-radius: 10px;
  padding: 10px 12px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 0.5px solid rgba(55, 53, 47, 0.12);
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: rgb(25, 25, 24);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: rgba(25, 25, 24, 0.5);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: rgba(55, 53, 47, 0.08);
}

.modal-body {
  padding: 20px;
}

.export-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-option {
  padding: 16px;
  border: 0.5px solid rgba(55, 53, 47, 0.12);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-option:hover {
  border-color: #2383e2;
  background: rgba(35, 131, 226, 0.04);
}

.export-option strong {
  font-size: 16px;
  font-weight: 600;
  color: rgb(25, 25, 24);
}

.export-option span {
  font-size: 14px;
  color: rgba(25, 25, 24, 0.6);
}

@media (max-width: 1200px) {
  .split-pane {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }

  .chat-pane,
  .prd-pane {
    height: 500px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  .container {
    padding: var(--space-24) var(--space-16);
  }

  .app-header {
    padding: var(--space-12) var(--space-16);
    margin: calc(-1 * var(--space-24)) calc(-1 * var(--space-16)) var(--space-20);
  }

  .app-header__title {
    font-size: 28px;
  }

  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-secondary {
    margin-left: 0;
  }

  .chat-pane,
  .prd-pane {
    height: 400px;
  }
}
