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

:root {
  /* Sinnia-inspired color palette */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary: #ec4899;
  --accent: #14b8a6;

  /* Backgrounds */
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.1);

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Borders & Shadows */
  --border: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(99, 102, 241, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow: 0 0 20px rgba(99, 102, 241, 0.3);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.3) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.header-content {
  position: relative;
  z-index: 1;
}

.logo {
  width: 120px;
  height: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.3));
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header p {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.property-info {
  margin-top: 1rem;
}

.property-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  color: var(--text-primary);
}

.property-icon {
  font-size: 1rem;
}

.property-badge #property-name {
  font-weight: 600;
  color: var(--primary-light);
}

.property-id {
  color: var(--text-secondary);
  font-size: 0.8rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

.message {
  max-width: 85%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  position: relative;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-md), var(--glow);
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(5px);
}

.message-content {
  font-size: 0.95rem;
  line-height: 1.7;
}

.message-content p {
  margin-bottom: 0.75rem;
}

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

.message-content ul,
.message-content ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.message.user .message-content li {
  color: rgba(255, 255, 255, 0.9);
}

/* Headers in messages */
.message-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1rem 0 0.75rem 0;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.message-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem 0;
  color: var(--primary-light);
}

.message-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.75rem 0 0.5rem 0;
  color: var(--text-primary);
}

.message-content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem 0;
  color: var(--text-secondary);
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
  margin-top: 0;
}

/* Code blocks */
.message-content pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  position: relative;
}

.message-content pre.code-block {
  padding-top: 0.75rem;
}

.message-content code {
  font-family: 'JetBrains Mono', 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.9em;
}

.message-content code.inline-code {
  background: rgba(99, 102, 241, 0.2);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--primary-light);
}

.message.user .message-content code.inline-code {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Tables */
.message-content .table-wrapper {
  overflow-x: auto;
  margin: 0.75rem 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0;
}

.message-content th,
.message-content td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.message-content th {
  background: rgba(99, 102, 241, 0.2);
  font-weight: 600;
  color: var(--primary-light);
  white-space: nowrap;
}

.message-content tr:last-child td {
  border-bottom: none;
}

.message-content tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.message-content td {
  color: var(--text-secondary);
}

/* Blockquotes */
.message-content blockquote {
  border-left: 3px solid var(--primary);
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Horizontal rule */
.message-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 1rem 0;
}

/* Links */
.message-content a {
  color: var(--primary-light);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.message-content a:hover {
  border-bottom-color: var(--primary-light);
}

/* Bold and italic */
.message-content strong {
  color: var(--primary-light);
  font-weight: 600;
}

.message.user .message-content strong {
  color: white;
}

.message-content em {
  font-style: italic;
  color: var(--text-secondary);
}

.message.user .message-content em {
  color: rgba(255, 255, 255, 0.9);
}

/* Lists improvements */
.message-content ul,
.message-content ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.message-content ol {
  list-style-type: decimal;
}

.message-content li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.message-content li:last-child {
  margin-bottom: 0;
}

.message-content li strong {
  color: var(--text-primary);
}

.message.user .message-content li {
  color: rgba(255, 255, 255, 0.9);
}

/* Input Container */
.input-container {
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

#chat-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#message-input {
  flex: 1;
  padding: 1rem 1.25rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 1rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
}

#message-input::placeholder {
  color: var(--text-muted);
}

#message-input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px var(--border-focus);
}

#send-button {
  padding: 1rem 1.75rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-md);
}

#send-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--glow);
}

#send-button:active {
  transform: translateY(0);
}

#send-button:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Footer */
.footer {
  padding: 1rem;
  text-align: center;
}

.clear-button {
  padding: 0.625rem 1.25rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-button:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--primary);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 6px;
  padding: 1rem 1.25rem;
  align-self: flex-start;
  background: var(--bg-card-hover);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

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

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Error State */
.error {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: #fca5a5 !important;
}

/* Responsive */
@media (max-width: 768px) {
  .app {
    padding: 0;
  }

  .header {
    padding: 1.5rem 1rem;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .chat-container {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .message {
    max-width: 92%;
  }

  .messages {
    padding: 1rem;
  }

  #message-input {
    padding: 0.875rem 1rem;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  #send-button {
    padding: 0.875rem 1.25rem;
    min-width: auto;
  }

  .button-text {
    display: none;
  }

  #send-button::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 8px solid white;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    margin-left: 2px;
  }

  .input-container {
    border-radius: 0;
  }
}

/* Animations for data display */
.message-content table {
  animation: fadeIn 0.4s ease-out;
}

/* Custom scrollbar for WebKit */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Selection color */
::selection {
  background: var(--primary);
  color: white;
}

/* Login Page Styles */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 100px;
  height: auto;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.3));
}

.login-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.login-features {
  margin-bottom: 2rem;
  text-align: left;
}

.feature {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.feature:last-child {
  margin-bottom: 0;
}

.feature-icon {
  font-size: 1.25rem;
}

.login-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem 1.5rem;
  background: white;
  color: #333;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-md);
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.login-button:active {
  transform: translateY(0);
}

.google-icon {
  flex-shrink: 0;
}

.login-note {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.error-message {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Header with user info */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
}

.brand .logo {
  width: 60px;
  margin-bottom: 0;
}

.brand-text h1 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.brand-text p {
  font-size: 0.85rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

#user-name {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  padding: 0.375rem 0.75rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-button:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

/* Property selector */
.property-selector-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.property-selector-container label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.property-select {
  padding: 0.5rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  min-width: 200px;
  cursor: pointer;
  outline: none;
}

.property-select:focus {
  border-color: var(--primary);
}

.property-select option {
  background: #1e1b4b;
  color: var(--text-primary);
}

/* Responsive adjustments for login and header */
@media (max-width: 768px) {
  .login-card {
    padding: 2rem 1.5rem;
  }

  .header-top {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .brand {
    flex-direction: column;
    text-align: center;
  }

  .brand-text h1,
  .brand-text p {
    text-align: center;
  }

  .user-info {
    width: 100%;
    justify-content: center;
  }

  .property-selector-container {
    flex-direction: column;
    gap: 0.5rem;
    border-radius: var(--radius-sm);
  }

  .property-select {
    width: 100%;
  }
}
