/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: system-ui, -apple-system, sans-serif; }

/* App shell — full viewport, no scroll */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  min-width: 320px;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
}

.sidebar-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.sidebar-header .user-info {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
}

.sidebar-item {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.sidebar-item:hover {
  background: #f5f5f5;
}

.sidebar-item.active {
  background: #e8f0fe;
  border-left: 3px solid #007bff;
  padding-left: calc(1rem - 3px);
}

.sidebar-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.sidebar-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item-time {
  font-size: 0.7rem;
  color: #999;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-item-org {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.15rem;
}

.sidebar-item-people {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

.sidebar-item-names {
  font-size: 0.75rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 0.1rem;
}

.sidebar-item-preview {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-legend {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid #e0e0e0;
  background: #f8f9fa;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: #888;
}

/* Chat panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}

.chat-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
}

.chat-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.chat-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.chat-header small {
  font-size: 0.8rem;
  color: #666;
}

.chat-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.participant-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #f0f0f0;
  color: #444;
}

.participant-chip--landlord { background: #e8f0fe; color: #1a56db; }
.participant-chip--tenant { background: #fef3c7; color: #92400e; }
.participant-chip--maintenance { background: #fce4ec; color: #ad1457; }
.participant-chip--ai { background: #e8f5e9; color: #2e7d32; }

.participant-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.participant-dot--landlord { background: #1a56db; }
.participant-dot--tenant { background: #d97706; }
.participant-dot--maintenance { background: #ad1457; }
.participant-dot--ai { background: #2e7d32; }

.participant-badge {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.7;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.chat-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid #e0e0e0;
  background: #f8f9fa;
}

.chat-hint {
  display: none;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.5rem;
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #4338ca;
}

.chat-form {
  display: flex;
  gap: 0.5rem;
}

.chat-form input[type="text"] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.chat-form input[type="text"]:focus {
  border-color: #007bff;
}

.chat-form button {
  padding: 0.5rem 1.25rem;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
}

.chat-form button:hover {
  background: #0056b3;
}

/* Empty state */
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 1.1rem;
}

/* Message bubbles */
.msg {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
}

.msg--own { align-items: flex-end; }
.msg--other { align-items: flex-start; }
.msg--system { align-items: center; }

.msg-sender {
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 0.15rem;
}

.msg-bubble {
  max-width: 80%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  line-height: 1.4;
  word-wrap: break-word;
}

.msg--own .msg-bubble {
  background: #007bff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg--other .msg-bubble {
  background: #f0f0f0;
  color: #333;
  border-bottom-left-radius: 4px;
}

.msg--ai .msg-bubble {
  background: #e8f5e9;
  color: #333;
  border-bottom-left-radius: 4px;
}

.msg--system .msg-bubble {
  max-width: 90%;
  background: #fff8e1;
  border: 1px solid #ffe082;
  color: #666;
  font-size: 0.85rem;
  text-align: center;
  border-radius: 8px;
}

.msg-time {
  font-size: 0.65rem;
  color: #bbb;
  margin-top: 0.15rem;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.6rem 0.85rem;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #999;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Markdown inside bubbles */
.msg-bubble { overflow: hidden; overflow-wrap: break-word; }
.msg-bubble p { margin: 0.25rem 0; }
.msg-bubble p:first-child { margin-top: 0; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble a { color: inherit; text-decoration: underline; }
.msg--own .msg-bubble a { color: #cce5ff; }
.msg-bubble ul, .msg-bubble ol { margin: 0.25rem 0; padding-left: 1.25rem; }
.msg-bubble li { margin: 0.15rem 0; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4 {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.msg-bubble h1:first-child, .msg-bubble h2:first-child,
.msg-bubble h3:first-child, .msg-bubble h4:first-child { margin-top: 0; }
.msg-bubble pre {
  margin: 0.25rem 0;
  padding: 0.5rem;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
}
.msg-bubble code { font-size: 0.85rem; }
.msg-bubble table { width: 100%; border-collapse: collapse; margin: 0.25rem 0; font-size: 0.85rem; }
.msg-bubble th, .msg-bubble td { padding: 0.25rem 0.5rem; border: 1px solid rgba(0,0,0,0.1); text-align: left; }
.msg-bubble blockquote {
  margin: 0.25rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid rgba(0,0,0,0.15);
  color: #666;
}
.msg-bubble hr { border: none; border-top: 1px solid rgba(0,0,0,0.1); margin: 0.5rem 0; }

/* Public page layout — override the app shell's overflow: hidden */
html:has(.public-page),
html:has(.public-page) body {
  height: auto;
  overflow: auto;
}

.public-page {
  min-height: 100vh;
  background: #f5f6f8;
}

.public-header {
  padding: 1rem 2rem;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.public-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
}

.public-content {
  max-width: 680px;
  margin: 2rem auto;
  padding: 0 1rem 4rem;
}

/* Flash messages */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin: 1rem auto;
  max-width: 680px;
  font-size: 0.9rem;
}

.flash--notice {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #2e7d32;
}

.flash--alert {
  background: #fce4ec;
  border: 1px solid #ef9a9a;
  color: #c62828;
}

.flash ul { margin: 0.5rem 0 0 1.5rem; }

/* Form sections */
.form-section {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-section--success {
  background: #e8f5e9;
  border-color: #a5d6a7;
}

.form-section--success h3 {
  color: #2e7d32;
}

.form-section--success p {
  color: #333;
  margin-top: 0.5rem;
  line-height: 1.5;
}

.section-divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 1rem 0;
}

.review-notes {
  color: #333;
  line-height: 1.6;
  white-space: pre-wrap;
}

.form-section legend,
.form-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1rem;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 0.3rem;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field textarea,
.form-field input[type="file"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.15);
}

.form-field--checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-field--checkbox label { margin-bottom: 0; }
.form-field--checkbox input[type="checkbox"] { width: auto; }

/* Two-column row */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 500px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Nested entries (rental history, employment) */
.nested-entry {
  padding: 1rem;
  margin-bottom: 1rem;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  position: relative;
}

.nested-entry .form-field:last-of-type { margin-bottom: 0.5rem; }

.btn-remove {
  background: none;
  border: none;
  color: #c62828;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  margin-top: 0.25rem;
}

.btn-remove:hover { text-decoration: underline; }

.btn--small {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Buttons */
.btn {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn--primary {
  background: #007bff;
  color: #fff;
}

.btn--primary:hover {
  background: #0056b3;
}

.btn--secondary {
  background: #f0f0f0;
  color: #333;
}

.btn--secondary:hover {
  background: #e0e0e0;
}

/* Lease summary card */
.lease-summary {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.lease-summary h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.lease-summary p {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.app-summary {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.9rem;
}

.app-summary dt {
  font-weight: 500;
  color: #555;
}

.app-summary dd {
  color: #333;
}

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

.status-badge--draft { background: #f0f0f0; color: #666; }
.status-badge--active { background: #e8f5e9; color: #2e7d32; }
.status-badge--expiring { background: #fff8e1; color: #f57f17; }
.status-badge--expired { background: #fce4ec; color: #c62828; }
.status-badge--terminated { background: #fce4ec; color: #c62828; }

/* Upload section */
.upload-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
}

.upload-section h4 {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.text-muted { color: #999; font-style: italic; }
