/* ==============================================================================
   Oliview ChatA - Modernized Desktop Design System (Spec 038 Pixel-Identical)
   Palette: Olive Young Green (#2E9E44), Background (#F9FAF8), Text (#1A2E1D)
   ============================================================================== */

:root {
  --primary: #2E9E44;
  --primary-hover: #238035;
  --primary-light: #EBF5EE;
  --primary-border: #C7E6CF;
  --bg-main: #FFFFFF;
  --bg-sub: #F7FAF8;
  --bg-card: #FFFFFF;
  --border-color: #E0EBE3;
  --border-light: #DCE8E0;
  --text-primary: #1A2E1D;
  --text-secondary: #496350;
  --text-muted: #5A7060;
  --text-light: #8E9F93;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(46, 158, 68, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --max-width: 1200px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 6.5rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.modal-sheet {
  max-height: 85svh;
  overflow-y: auto;
}

button, input, select, textarea, .btn, .touch-target {
  min-height: 48px;
  min-width: 48px;
}

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ==============================================================================
   1. Header Section
   ============================================================================== */
.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.app-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==============================================================================
   2. Top Panel (2-Column Grid [1.6 : 1.4])
   ============================================================================== */
.top-panel {
  display: grid;
  grid-template-columns: 1.6fr 1.4fr;
  gap: 20px;
  background: var(--bg-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: #213527;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 10px;
  margin-bottom: 6px;
}

/* Brand Box & Chips */
.brand-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.brand-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: #2b6e3f;
  background-color: var(--primary-light);
  border: 1px solid var(--primary-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.brand-chip:hover {
  background-color: #d8edd7;
  transform: translateY(-1px);
}

/* Category Pills */
.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.cat-pill {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cat-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Attribute Card */
.attribute-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 10px;
}

.attribute-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #213527;
  margin-bottom: 8px;
}

.attribute-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attribute-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-sub);
  color: #2c4233;
  border: 1px solid var(--border-light);
}

/* 1-Click Example Queries */
.example-queries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-example {
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 10px 14px;
  line-height: 1.4;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background-color: #ffffff;
  color: #2a3d30;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  word-break: keep-all;
}

.btn-example:hover {
  border-color: var(--primary);
  background-color: #f6fbf7;
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ==============================================================================
   3. Chat Container & Messages
   ============================================================================== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.message-wrapper.user-wrapper {
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.assistant-avatar {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
}

.user-avatar {
  background: #EEF2F6;
  border: 1px solid #D0D7DE;
}

.message-bubble {
  max-width: 82%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14.5px;
  line-height: 1.65;
}

.user-bubble {
  background: var(--primary);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.assistant-bubble {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.welcome-tip {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg-sub);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Real-time 4-Stage Status Box */
.status-box {
  background: #F4F9F5;
  border: 1px solid #D6EAD9;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.status-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-secondary);
}

.status-step.running {
  color: var(--primary);
  font-weight: 700;
}

.status-step.complete {
  color: #2b6e3f;
}

.status-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #C7E6CF;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Inline Citation Badge */
.citation-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 4px;
  background: #EBF5EE;
  color: #238035;
  border: 1px solid #C7E6CF;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.citation-badge:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: scale(1.05);
}

/* Accordion Review Component */
.accordion-wrapper {
  margin-top: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
}

.accordion-header {
  padding: 12px 16px;
  background: var(--bg-sub);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  user-select: none;
}

.accordion-body {
  display: none;
  padding: 14px 16px;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
}

.accordion-body.open {
  display: block;
}

.review-item {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-light);
}

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

.review-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 4px;
}

.review-product-name {
  color: var(--primary-hover);
}

.review-rating {
  color: #F59E0B;
}

.review-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.btn-oy-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.btn-oy-link:hover {
  text-decoration: underline;
}

/* ==============================================================================
   4. Bottom Fixed Input Bar (Backdrop Blur, 1200px max-width)
   ============================================================================== */
.bottom-bar-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(220, 232, 224, 0.6);
  z-index: 100;
  padding: 10px 0;
}

.bottom-bar-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

.chat-input-form {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 6px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease;
}

.chat-input-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 158, 68, 0.12);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  padding: 6px 0;
  line-height: 1.4;
  color: var(--text-primary);
}

.action-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-send {
  background: var(--primary);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-send:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-stop {
  background: #EF4444;
  color: #ffffff;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-stop:hover {
  background: #DC2626;
}

.hidden {
  display: none !important;
}

/* ==============================================================================
   5. Markdown Content & GFM Table Styling (Spec 038 & Feature 047)
   ============================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 16px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  background: #ffffff;
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: left;
}

.markdown-table th {
  background-color: var(--primary-light);
  color: var(--text-primary);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 2px solid var(--primary-border);
  white-space: nowrap;
}

.markdown-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: top;
}

.markdown-table tbody tr:last-child td {
  border-bottom: none;
}

.markdown-table tbody tr:hover {
  background-color: #F8FBF9;
}

.markdown-table tbody tr:nth-child(even) {
  background-color: #FAFCFA;
}

.markdown-hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

.markdown-h1 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 16px 0 8px 0;
}

.markdown-h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 14px 0 6px 0;
}

.markdown-h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 12px 0 6px 0;
}

.markdown-li {
  margin-left: 18px;
  margin-bottom: 5px;
  line-height: 1.55;
  color: var(--text-primary);
}

.markdown-oli {
  list-style-type: none;
  margin-left: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.oli-num {
  font-weight: 700;
  color: var(--primary);
  min-width: 18px;
}

.markdown-code {
  background: var(--primary-light);
  color: var(--primary-hover);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.markdown-pre {
  background: var(--bg-sub);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 12px 0;
  overflow-x: auto;
}

.citation-badge {
  display: inline-flex;
  align-items: center;
  background-color: var(--primary-light);
  color: var(--primary-hover);
  border: 1px solid var(--primary-border);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin: 0 3px;
  vertical-align: middle;
  transition: all 0.15s ease;
  user-select: none;
}

.citation-badge:hover {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(46, 158, 68, 0.25);
}

