/* BuildBuddy Assembly Assistant — Mobile-first styles */

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: #1a1a1a;
  background: #f5f5f5;
  -webkit-text-size-adjust: 100%;
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== App Layout ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height for mobile */
  max-width: 600px;
  margin: 0 auto;
  background: #ffffff;
}

/* ===== Camera Section ===== */
#camera-section {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  height: 30vh;
  background: #000;
  overflow: hidden;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#capture-canvas {
  display: none;
}

#camera-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  justify-content: center;
}

#step-progress {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ===== Status Bar ===== */
#status-bar {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 6px 12px;
  background: #fafafa;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: #666;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  transition: background-color 0.3s ease;
}

/* Status states */
.status-indicator.active .status-dot {
  background: #34c759;
}

.status-indicator.inactive .status-dot {
  background: #ccc;
}

.status-indicator.error .status-dot {
  background: #ff3b30;
}

.status-label {
  user-select: none;
}

/* ===== Conversation Section ===== */
#conversation-section {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#conversation {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ===== Message Bubbles ===== */
.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message p {
  margin: 0;
}

.user-message {
  align-self: flex-end;
  background: #007aff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.assistant-message {
  align-self: flex-start;
  background: #e9e9eb;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

/* Warning message styling for error detection */
.warning-message {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
  border-bottom-left-radius: 4px;
}

.warning-message::before {
  content: "\26A0\FE0F ";
  font-size: 1rem;
}

/* Loading indicator */
.message.loading {
  opacity: 0.7;
  font-style: italic;
}

/* ===== Controls Section ===== */
#controls-section {
  flex-shrink: 0;
  padding: 10px 12px;
  background: #fafafa;
  border-top: 1px solid #e0e0e0;
}

#button-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

#btn-analyze {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #007aff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#btn-analyze:hover {
  background: #0062cc;
}

#btn-analyze:active {
  background: #004fa3;
}

#btn-analyze:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#btn-voice {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #34c759;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#btn-voice:hover {
  background: #2da44e;
}

#btn-voice:active,
#btn-voice.listening {
  background: #ff3b30;
}

#btn-voice:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#btn-voice.hidden {
  display: none;
}

/* Text input row */
#text-input-row {
  display: flex;
  gap: 8px;
}

#text-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid #d1d1d6;
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
}

#text-input:focus {
  border-color: #007aff;
}

#btn-send {
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #007aff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

#btn-send:hover {
  background: #0062cc;
}

#btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Responsive — larger screens ===== */
@media (min-width: 481px) {
  #camera-section {
    height: 35vh;
  }

  .message {
    max-width: 70%;
  }
}
