/* ============================================================
   Allmode.ai for Excel — Theme-aligned styles
   Colors matched to /frontend/styles/brands/allmode/theme.css
   ============================================================ */

:root {
  /* Light mode palette (default) — matches allmode web light theme */
  --bg-000: #ffffff;
  --bg-100: #faf8f3;
  --bg-200: #f3f0e8;
  --bg-300: #faf8f3;
  --bg-400: #e8e3d8;
  --text-000: #1f1d1a;
  --text-100: #1f1d1a;
  --text-200: #3b3a36;
  --text-300: #3b3a36;
  --text-400: #6e6d68;
  --border-100: #ddd7c9;
  --border-200: #cdc6b8;
  --border-300: #bfb8aa;
  --accent-main: #171513;
  --accent-bg: #171513;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text-000);
  background: var(--bg-200);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Loading ---- */
.app-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 12px;
  background: var(--bg-200);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-200);
  border-top-color: var(--text-000);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.app-loading p {
  color: var(--text-400);
  font-size: 13px;
}

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

/* ---- App Layout ---- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-100);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-100);
  background: var(--bg-100);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-000);
  letter-spacing: -0.01em;
}

.panel-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-100);
}

/* ---- Login Panel ---- */
.login-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 24px;
  background: var(--bg-200);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 12px 0 6px;
  color: var(--text-000);
  letter-spacing: -0.02em;
}

.login-header p {
  color: var(--text-400);
  font-size: 14px;
}

.login-card {
  width: 100%;
  max-width: 320px;
  background: var(--bg-000);
  border: 0.5px solid var(--border-100);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.06),
    0 2px 64px rgba(0,0,0,0.03);
}

.login-form {
  width: 100%;
}

.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-200);
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  background: var(--bg-000);
  border: 1px solid var(--border-100);
  border-radius: 10px;
  color: var(--text-000);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:hover {
  border-color: var(--border-200);
}

.form-input:focus {
  border-color: var(--border-300);
}

.form-input::placeholder {
  color: var(--text-400);
  font-size: 13px;
}

.password-field {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  padding: 0 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-400);
  display: flex;
  align-items: center;
}

.password-toggle:hover {
  color: var(--text-000);
}

.login-error {
  color: #ef4444;
  font-size: 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
}

.login-button {
  width: 100%;
  height: 44px;
  margin-top: 4px;
  background: var(--accent-bg);
  color: var(--bg-000);
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.165,0.85,0.45,1), opacity 0.15s;
  position: relative;
  overflow: hidden;
}

.login-button:hover {
  transform: scaleY(1.015) scaleX(1.005);
}

.login-button:active {
  transform: scale(0.985);
}

.login-button:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.login-button-spinner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-400);
}

.login-footer a {
  color: var(--text-200);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.login-footer a:hover {
  color: var(--text-000);
}

/* ---- Chat Panel ---- */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-100);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 24px;
}

.chat-empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-000);
  letter-spacing: -0.01em;
}

.chat-empty-desc {
  font-size: 13px;
  color: var(--text-400);
  line-height: 1.6;
}

/* ---- Message Bubbles ---- */
.message-row {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

/* User message — right-aligned like web /chat */
.message-row.message-user {
  align-items: flex-end;
}

.message-user-bubble {
  display: inline-flex;
  gap: 8px;
  background: var(--bg-200);
  border-radius: 12px;
  padding: 10px 16px 10px 10px;
  max-width: 95%;
}

.message-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-main);
  color: var(--bg-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  user-select: none;
}

.message-user-text {
  font-size: 0.9375rem;
  line-height: 1.5rem;
  letter-spacing: -0.01em;
  color: var(--text-000);
  padding: 2px 0;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Assistant message — matches ai-conversation.tsx */
.message-row.message-assistant {
  align-items: flex-start;
}

.message-assistant-content {
  position: relative;
  letter-spacing: -0.015em;
  padding-bottom: 4px;
  padding-left: 2px;
  padding-right: 2px;
  overflow: hidden;
  min-width: 0;
}

.message-assistant-content .message-content {
  font-size: 0.9375rem;
  line-height: 1.65rem;
  color: var(--text-000);
}

/* ---- Markdown content ---- */
.message-content {
  overflow-x: auto;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.message-content p {
  margin: 0 0 8px;
}

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

.message-content pre {
  background: var(--bg-200);
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  margin: 8px 0;
  border: 1px solid var(--border-100);
  max-width: 100%;
}

.message-content code {
  background: var(--bg-200);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  color: var(--text-200);
}

.message-content pre code {
  background: none;
  padding: 0;
  color: var(--text-100);
}

.message-content table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
  width: 100%;
  display: block;
  overflow-x: auto;
}

.message-content th,
.message-content td {
  border: 1px solid var(--border-200);
  padding: 6px 10px;
  text-align: left;
}

.message-content th {
  background: var(--bg-300);
  font-weight: 600;
  color: var(--text-200);
}

.message-content ul,
.message-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

.message-content li {
  margin-bottom: 4px;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  color: var(--text-000);
  margin: 12px 0 6px;
  font-weight: 600;
}

.message-content h1 { font-size: 1.25rem; }
.message-content h2 { font-size: 1.125rem; }
.message-content h3 { font-size: 1rem; }

.message-content blockquote {
  border-left: 3px solid var(--border-200);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-300);
}

.message-content strong {
  color: var(--text-000);
  font-weight: 600;
}

.message-content a {
  color: var(--text-200);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-content a:hover {
  color: var(--text-000);
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--border-100);
  margin: 12px 0;
}

/* Attachment in user message */
.message-attachment {
  margin-bottom: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  border: 1px solid var(--border-100);
}

.attachment-label {
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--text-400);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.attachment-preview {
  font-family: "SF Mono", "Consolas", monospace;
  font-size: 11px;
  white-space: pre-wrap;
  max-height: 60px;
  overflow: hidden;
  color: var(--text-300);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-400);
  animation: typing 1.2s infinite;
}

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

@keyframes typing {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ---- Attachment Bar ---- */
.attachment-bar {
  display: flex;
  align-items: center;
  padding: 0 14px 6px;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-100);
  border: 1px solid var(--border-100);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-200);
  position: relative;
  max-width: 100%;
}

.attachment-pill:hover .attachment-remove {
  opacity: 1;
  pointer-events: auto;
}

.attachment-pill svg {
  flex-shrink: 0;
  color: var(--text-400);
}

.attachment-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-400);
  padding: 2px;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.attachment-remove:hover {
  color: #ef4444;
}

/* ---- Chat Input Area — matches web ai-chat.tsx sidebar mode ---- */
.chat-input-area {
  padding: 12px;
}

/* Outer wrapper: shows border normally, gradient border on focus */
.chat-input-box {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border-200);
  transition: all 0.2s;
}

.chat-input-box:focus-within {
  border-color: transparent;
  padding: 2px;
  background: linear-gradient(to right, rgb(59, 130, 246) 0%, rgb(147, 197, 253) 50%, rgb(59, 130, 246) 100%);
  background-size: 200% auto;
}

/* Inner container: covers the gradient, leaving it visible as a border */
.chat-input-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--bg-100);
  border-radius: 10px;
}

.chat-input-box:not(:focus-within) .chat-input-inner {
  border-radius: 11px;
}

.chat-textarea {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-000);
  font-size: 14px;
  line-height: 1.5rem;
  letter-spacing: -0.025em;
  font-family: inherit;
  padding: 8px;
}

.chat-textarea::placeholder {
  color: var(--text-400);
  font-size: 13px;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-400);
  cursor: pointer;
  transition: all 0.15s;
}

.chat-action-btn:hover {
  background: var(--bg-200);
  color: var(--text-000);
}

.chat-action-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Send button — square icon button matching web light mode (bg-black text-white) */
.chat-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: none;
  background: var(--accent-main);
  color: var(--bg-000);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.chat-send-btn:hover {
  opacity: 0.9;
}

.chat-send-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Stop/loading button — same square size, with breathing animation */
.chat-stop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border-300);
  background: transparent;
  color: var(--text-200);
  cursor: pointer;
  transition: all 0.15s;
}

.chat-stop-btn:hover {
  background: var(--bg-200);
}

/* ---- Model Selector ---- */
.model-selector-wrapper {
  position: relative;
}

.model-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-400);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.model-selector-btn:hover {
  color: var(--text-000);
  background: var(--bg-200);
}

.model-selector-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.model-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 4px;
  min-width: 200px;
  background: var(--bg-000);
  border: 1px solid var(--border-100);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  z-index: 100;
}

.model-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-200);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
  text-align: left;
}

.model-menu-item:hover {
  background: var(--bg-200);
  color: var(--text-000);
}

.model-menu-item.active {
  color: var(--text-000);
}

.model-menu-item.active svg {
  color: var(--accent-main);
}

/* Breathing animation — matches web ai-breathing */
@keyframes ai-breathing {
  0%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.ai-breathing {
  animation: ai-breathing 2s ease-in-out infinite;
}

/* ---- Quick Actions (empty state) ---- */
.chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  justify-content: center;
}

.chat-quick-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-200);
  background: transparent;
  color: var(--text-200);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.chat-quick-btn:hover {
  background: var(--bg-200);
  border-color: var(--border-300);
  color: var(--text-000);
}

/* ---- Tool Call Display ---- */
.tool-calls-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.tool-call-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: var(--bg-200);
  border: 1px solid var(--border-100);
  min-width: 0;
  overflow: hidden;
}

.tool-call-item.tool-success .tool-call-icon {
  color: #22c55e;
}

.tool-call-item.tool-error .tool-call-icon {
  color: #ef4444;
}

.tool-call-item.tool-pending .tool-call-icon {
  color: var(--text-400);
}

.tool-call-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.tool-call-label {
  font-weight: 600;
  color: var(--text-200);
  white-space: nowrap;
}

.tool-call-summary {
  color: var(--text-400);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Message Actions (hover) ---- */
.message-actions-bar {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  justify-content: flex-end;
}

.message-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0.5px solid var(--border-100);
  background: var(--bg-000);
  color: var(--text-300);
  cursor: pointer;
  transition: all 0.15s;
}

.message-action-btn:hover {
  background: var(--bg-200);
  color: var(--text-000);
}

/* ---- Messages inner container ---- */
.chat-messages-inner {
  width: 100%;
  padding: 0 4px;
  min-width: 0;
}

/* ---- Scrollbar — light theme ---- */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ---- Fluent UI overrides for light theme ---- */
.fui-FluentProvider {
  background: transparent !important;
}

.fui-Input {
  background: var(--bg-000) !important;
  border-color: var(--border-100) !important;
  color: var(--text-000) !important;
}

.fui-Textarea {
  background: transparent !important;
  border: none !important;
  color: var(--text-000) !important;
}

.fui-Textarea::after {
  display: none !important;
}

.fui-Tab {
  color: var(--text-400) !important;
}

.fui-Tab:hover {
  color: var(--text-200) !important;
}

.fui-Tab[aria-selected="true"] {
  color: var(--text-000) !important;
}

.fui-Button--primary {
  background: var(--accent-main) !important;
  color: var(--bg-300) !important;
  border: none !important;
}

.fui-Button--subtle {
  color: var(--text-300) !important;
}

.fui-Button--subtle:hover {
  background: var(--bg-200) !important;
  color: var(--text-200) !important;
}

.fui-Card {
  background: var(--bg-200) !important;
  border-color: var(--border-100) !important;
}

.fui-Label {
  color: var(--text-200) !important;
}

.fui-Badge {
  color: var(--text-200) !important;
}

