/* ImoMag Agent — Chat UI Styles */
:root {
  --imomag-primary: #1a6fc4;
  --imomag-primary-dark: #1558a0;
  --imomag-bg: #f5f7fa;
  --imomag-white: #ffffff;
  --imomag-border: #e2e8f0;
  --imomag-text: #1e293b;
  --imomag-muted: #64748b;
  --imomag-user-bg: #1a6fc4;
  --imomag-ai-bg: #f1f5f9;
  --imomag-radius: 12px;
  --imomag-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

.imomag-login-notice {
  padding: 1.5rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: var(--imomag-radius);
  text-align: center;
  color: var(--imomag-text);
}

/* Chat container */
.imomag-chat {
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  background: var(--imomag-white);
  border-radius: var(--imomag-radius);
  box-shadow: var(--imomag-shadow);
  overflow: hidden;
  border: 1px solid var(--imomag-border);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--imomag-text);
}

/* Header */
.imomag-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--imomag-primary);
  color: #fff;
}
.imomag-logo {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.3px;
}
.imomag-reset-btn {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  border-radius: 6px;
  padding: 4px 10px;
  transition: background 0.2s;
}
.imomag-reset-btn:hover { background: rgba(255,255,255,0.30); }

/* Messages scroll area */
.imomag-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  background: var(--imomag-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
  max-height: 1200px;
}

/* Individual message */
.imomag-msg { display: flex; }
.imomag-msg-user { justify-content: flex-end; }
.imomag-msg-assistant { justify-content: flex-start; }

.imomag-bubble {
  max-width: 72%;
  padding: 10px 15px;
  border-radius: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.imomag-msg-user .imomag-bubble {
  background: var(--imomag-user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.imomag-msg-assistant .imomag-bubble {
  background: var(--imomag-ai-bg);
  color: var(--imomag-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Typing indicator */
.imomag-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}
.imomag-typing span {
  width: 8px; height: 8px;
  background: var(--imomag-muted);
  border-radius: 50%;
  animation: imomag-bounce 1.2s infinite;
}
.imomag-typing span:nth-child(2) { animation-delay: 0.2s; }
.imomag-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes imomag-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-7px); opacity: 1; }
}

/* Input row */
.imomag-input-row {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: var(--imomag-white);
  border-top: 1px solid var(--imomag-border);
}
#imomag-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--imomag-border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  color: var(--imomag-text);
}
#imomag-input:focus { border-color: var(--imomag-primary); }
#imomag-input:disabled { opacity: 0.6; }

#imomag-send-btn {
  padding: 10px 22px;
  background: var(--imomag-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
#imomag-send-btn:hover { background: var(--imomag-primary-dark); }
#imomag-send-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Listings grid */
.imomag-listings {
  display: grid;
  align-self: stretch;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  width: 100%;
  padding: 4px 0;
}

/* Listing card */
.imomag-card {
  background: var(--imomag-white);
  border: 1px solid var(--imomag-border);
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.18s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
}
.imomag-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.imomag-card-img {
  height: 150px;
  overflow: hidden;
  background: #e8eef6;
}
.imomag-card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.imomag-img-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #b0bec5;
}

.imomag-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.imomag-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.imomag-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.imomag-badge-source { background: #e0f2fe; color: #0369a1; }
.imomag-badge-agency { background: #ede9fe; color: #6d28d9; }
.imomag-badge-complex { background: #dcfce7; color: #166534; }

.imomag-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--imomag-primary);
  text-decoration: none;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.imomag-card-title:hover { text-decoration: underline; }

.imomag-card-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--imomag-text);
}

.imomag-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.imomag-pill {
  background: #f1f5f9;
  border: 1px solid var(--imomag-border);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11.5px;
  color: var(--imomag-muted);
}

.imomag-card-location {
  font-size: 12px;
  color: var(--imomag-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Stars */
.imomag-stars {
  color: #f59e0b;
  font-size: 13px;
  letter-spacing: 1px;
}

/* Score bar */
.imomag-score-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
}
.imomag-score-track {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.imomag-score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.imomag-score-label {
  font-size: 11px;
  color: var(--imomag-muted);
  white-space: nowrap;
  min-width: 28px;
  text-align: right;
}
.imomag-score-low  { background: #f87171; }
.imomag-score-mid  { background: #fbbf24; }
.imomag-score-high { background: #34d399; }

/* Responsive */
@media (max-width: 640px) {
  .imomag-listings { grid-template-columns: 1fr; }
  .imomag-bubble { max-width: 90%; }
  .imomag-chat-header { padding: 12px 14px; }
}
