/**
 * Pierre Chat - Shared Styles
 * Used by all iframe chat interfaces
 */

/* Avenir Font */
@font-face {
  font-family: 'Avenir';
  src: url('assets/font/Avenir_LT_45_Book.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Avenir';
  src: url('assets/font/Avenir-Heavy.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --olive: #6E7357;
  --olive-dark: #4a5133;
  --olive-tint: #eef0e8;
  --paper: #ececec;
  --tile: #ffffff;
  --ink: #2c3236;
  --muted: #2c3236;
  --line: #d9d9d2;
  --font-primary: 'Avenir', Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-primary);
  background: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Chat Container */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.chat-header h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}

.chat-header h2 span {
  font-family: var(--font-primary);
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
}

.clear-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
  opacity: 0.7;
}

.clear-btn:hover {
  background: var(--olive-tint);
  color: var(--olive-dark);
  opacity: 1;
}

/* Category Chips */
.chips {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  flex-wrap: wrap;
}

.chip {
  font-family: var(--font-primary);
  font-size: 15px;
  padding: 7px 15px;
  border-radius: 30px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.chip.active {
  background: #000;
  color: #fff;
}

.chip:hover:not(.active) {
  background: var(--olive-tint);
}

/* Chat Body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  font-family: var(--font-primary);
}

/* Empty State */
.empty {
  max-width: 500px;
  margin: 10px auto 0;
}

.empty .hi {
  font-family: var(--font-primary);
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 6px;
  font-weight: bold;
}

.empty .sub {
  font-size: 13px;
  color: #2c323690;
  margin-bottom: 16px;
  line-height: 1.5;
}

.prompts {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.prompt {
  border: 1px solid #2c323615;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  background: #2c323610;
  transition: background .15s;
}

.prompt:hover {
  background: var(--olive-tint);
}

/* Messages */
.msg {
  max-width: 80%;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 12px;
  word-wrap: break-word;
  margin-top: 12px;
}

.me {
  background: var(--olive);
  color: #fff;
  margin-left: auto;
  width: fit-content !important;
  max-width: 80%;
  text-align: right !important;
}

.ai {
  background: #f1f1ec;
  color: var(--ink);
  border-bottom-left-radius: 4px;
  width: fit-content !important;
  max-width: 80%;
  margin-right: auto;
  width: fit-content !important;
}

/* Markdown formatting in AI messages */
.ai h1 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
  margin-top: 4px;
  color: var(--ink);
  line-height: 1.3;
}

.ai h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  margin-top: 4px;
  color: var(--ink);
  line-height: 1.3;
}

.ai h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ink);
}

.ai h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--ink);
}

.ai p {
  margin-bottom: 10px;
}

.ai p:last-child {
  margin-bottom: 0;
}

.ai ul,
.ai ol {
  margin: 10px 0;
  padding-left: 24px;
}

.ai li {
  margin-bottom: 6px;
  line-height: 1.5;
}

.ai strong {
  font-weight: 600;
  color: var(--ink);
}

.ai em {
  font-style: italic;
}

.ai code {
  font-family: 'Monaco', 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 12.5px;
}

.ai pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 10px 0;
}

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

.ai hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.ai blockquote {
  border-left: 3px solid var(--olive);
  padding-left: 12px;
  margin: 10px 0;
  color: var(--muted);
}

/* Tables */
.ai table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
  border: 1px solid var(--line);
}

.ai table thead {
  background: var(--olive-tint);
}

.ai table th {
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  color: var(--ink);
}

.ai table td {
  padding: 9px 12px;
  border: 1px solid var(--line);
  color: var(--ink);
}

.ai table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.ai table tbody tr:hover {
  background: var(--olive-tint);
}

/* Typing Indicator */
.typing {
  display: flex;
  gap: 5px;
  padding: 13px 16px;
  background: #f1f1ec;
  border-radius: 14px;
  width: fit-content;
  margin-bottom: 12px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b5b5ad;
  animation: blink 1.2s infinite;
}

.dot:nth-child(2) {
  animation-delay: .2s;
}

.dot:nth-child(3) {
  animation-delay: .4s;
}

@keyframes blink {
  0%, 60%, 100% {
    opacity: .3;
  }
  30% {
    opacity: 1;
  }
}

/* Input */
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
}

.chat-input textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 11px 16px;
  font-family: var(--font-primary);
  font-size: 14px;
  outline: none;
  color: var(--ink);
  resize: none;
  overflow-y: hidden;
  min-height: 40px;
  max-height: 200px;
  line-height: 1.5;
}

.chat-input textarea:focus {
  border-color: var(--olive);
}

.send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--olive);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}

.send svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.8;
}

.send:disabled {
  background: #c9c9c2;
  cursor: not-allowed;
}

/* Loading/Pause state */
.send.loading {
  background: #dc3545;
  border-radius: 8px;
}

.send.loading svg {
  display: none;
}

.send.loading::after {
  content: '';
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
}

/* Error Message */
.error {
  background: #fee;
  color: var(--ink);
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  margin-bottom: 12px;
  max-width: 84%;
  border-left: 3px solid #c33;
  line-height: 1.5;
  word-wrap: break-word;
}

/* Test iframe specific styles */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}

.sheet-head span {
  font-family: var(--font-primary);
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
}

.body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-family: var(--font-primary);
}

.input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.input textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 11px 16px;
  font-family: var(--font-primary);
  font-size: 14px;
  outline: none;
  resize: none;
  overflow-y: hidden;
  min-height: 40px;
  max-height: 200px;
  line-height: 1.5;
}

.input textarea:focus {
  border-color: var(--olive);
}

.src {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 9px;
  font-size: 11px;
  color: var(--olive);
  background: #fff;
  border: 1px solid var(--olive);
  padding: 4px 9px;
  border-radius: 20px;
  cursor: pointer;
}

.fb {
  display: flex;
  gap: 14px;
  margin-top: 8px;
}

.fb svg {
  width: 15px;
  height: 15px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 1.6;
  cursor: pointer;
}

/* Disclaimer */
.disclaimer {
  text-align: center;
  font-family: var(--font-primary);
  font-size: 11px;
  color: #2c323670;
  padding: 14px 18px 20px;
  background: #fff;
}
