/* Shaanti CMS — Chat Interface */

:root {
  --sage: #a0a38e;
  --beige: #dad5cb;
  --dark: #212121;
  --gold: #c4a77d;
  --white: #fafaf7;
  --sage-light: rgba(160, 163, 142, 0.12);
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: var(--beige);
  color: var(--dark);
  height: 100dvh;
  overflow: hidden;
}

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ===== LOGIN ===== */

#login-screen {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sage) 0%, var(--beige) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 40px;
  box-shadow: var(--shadow);
  max-width: 380px;
  width: 90%;
  text-align: center;
}

.login-logo h1 {
  font-family: 'Imbue', serif;
  font-weight: 400;
  font-size: 32px;
  color: var(--dark);
  margin-bottom: 4px;
}

.login-logo h1 span {
  color: var(--gold);
  font-weight: 500;
}

.login-logo p {
  font-size: 13px;
  color: var(--sage);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 32px;
}

#login-form input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--beige);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
}

#login-form input:focus {
  border-color: var(--sage);
}

.btn {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: var(--sage);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:hover { background: #8a8d7a; }
.btn:active { transform: scale(0.98); }

.error {
  color: #c0392b;
  font-size: 13px;
  margin-top: 12px;
}

/* ===== CHAT ===== */

#chat-screen {
  background: var(--white);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--dark);
  color: white;
  flex-shrink: 0;
}

.chat-header h2 {
  font-family: 'Imbue', serif;
  font-weight: 400;
  font-size: 20px;
}

.chat-header h2 span { color: var(--gold); }

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
}

.status-dot.disconnected { background: #e74c3c; }

/* Messages */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn 0.2s ease;
}

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

.message--user {
  align-self: flex-end;
  background: var(--sage);
  color: white;
  border-bottom-right-radius: 4px;
}

.message--assistant {
  align-self: flex-start;
  background: var(--beige);
  color: var(--dark);
  border-bottom-left-radius: 4px;
}

.message--system {
  align-self: center;
  background: var(--sage-light);
  color: var(--dark);
  text-align: center;
  max-width: 90%;
  border-radius: 12px;
}

.message--system .hint {
  font-size: 12px;
  color: var(--sage);
  margin-top: 8px;
  font-style: italic;
}

.message--tool {
  align-self: flex-start;
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--sage);
  display: flex;
  align-items: center;
  gap: 6px;
}

.message--tool .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--beige);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.message--tool .spinner.done {
  animation: none;
  border-color: var(--sage);
  background: var(--sage);
  position: relative;
}

.message--tool .spinner.done::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 3px;
  width: 4px;
  height: 6px;
  border: solid white;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

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

.message--error {
  align-self: center;
  background: #fde8e8;
  color: #c0392b;
  text-align: center;
}

.message--result {
  align-self: center;
  background: rgba(76, 175, 80, 0.1);
  color: #2e7d32;
  text-align: center;
  font-weight: 500;
}

/* Typing indicator */

.typing-indicator {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--beige);
  border-radius: 12px;
  display: flex;
  gap: 4px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--sage);
  border-radius: 50%;
  animation: bounce 1.2s ease-in-out infinite;
}

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

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input */

.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--white);
  border-top: 1px solid var(--beige);
  flex-shrink: 0;
}

.chat-input textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--beige);
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.chat-input textarea:focus {
  border-color: var(--sage);
}

.btn--send {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
}

.btn--send:hover { background: #b09568; }
.btn--send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Scrollbar */

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--beige); border-radius: 2px; }

/* Mobile */

@media (max-width: 600px) {
  .login-card { padding: 32px 24px; }
  .message { max-width: 92%; }
  .chat-header { padding: 10px 14px; }
  .chat-messages { padding: 14px; }
  .chat-input { padding: 8px 10px; }
}
