/* ==========================================================================
   RYU Frontend -- Aiuken Solutions
   Commercial Intelligence Orchestrator -- Interface Styles
   ========================================================================== */

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

:root {
  --color-bg-primary: #1a0f0a;
  --color-bg-secondary: #1f1410;
  --color-bg-tertiary: #2a1a14;
  --color-bg-input: #251c16;
  --color-bg-hover: #3a2820;
  --color-accent: #ff6b35;
  --color-accent-dim: rgba(255, 107, 53, 0.15);
  --color-accent-glow: rgba(255, 107, 53, 0.3);
  --color-text-primary: #f0e6e0;
  --color-text-secondary: #b8a89e;
  --color-text-muted: #7a6a60;
  --color-border: #2a1a14;
  --color-border-accent: rgba(255, 107, 53, 0.2);
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-vip: #fbbf24;
  --color-user-bg: #3a2010;
  --color-agent-bg: #1f1410;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --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 24px rgba(0, 0, 0, 0.5);
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
}

/* --- Header --- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 40px;
  height: 40px;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--color-accent);
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.2;
  letter-spacing: 0.05em;
}

.header-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-online {
  background: var(--color-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-offline {
  background: var(--color-text-muted);
}

.status-error {
  background: var(--color-error);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.status-label {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* --- Chat Container --- */

.chat-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

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

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

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

/* --- Messages --- */

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: messageIn 200ms ease-out;
}

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

.message-user { align-self: flex-end; flex-direction: row-reverse; }
.message-agent { align-self: flex-start; }
.message-system { align-self: center; max-width: 90%; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-user .message-avatar {
  background: var(--color-user-bg);
  color: var(--color-accent);
  border: 1px solid var(--color-border-accent);
}

.message-agent .message-avatar {
  background: var(--color-accent-dim);
  color: var(--color-accent);
  border: 1px solid var(--color-border-accent);
}

.message-content {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.message-user .message-content {
  background: var(--color-user-bg);
  border: 1px solid rgba(255, 107, 53, 0.1);
  color: var(--color-text-primary);
}

.message-agent .message-content {
  background: var(--color-agent-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

.message-system .message-content {
  background: transparent;
  border: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 13px;
  padding: 12px 20px;
}

.message-content p { margin-bottom: 6px; }
.message-content p:last-child { margin-bottom: 0; }
.message-meta { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }

.message-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border-radius: 3px;
}

.message-content pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
}

/* --- VIP Badge --- */

.badge-vip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-vip);
  letter-spacing: 0.05em;
}

/* --- Typing Indicator --- */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--color-text-muted);
  border-radius: var(--radius-full);
  animation: typingPulse 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 typingPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

.typing-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* --- Quick Actions --- */

.quick-actions {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.btn-quick {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-accent);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-accent);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-quick:hover {
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
}

/* --- Input Bar --- */

.input-bar {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 8px 8px 14px;
  transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-dim);
}

.input-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  padding: 4px 0;
}

.input-field::placeholder {
  color: var(--color-text-muted);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover:not(:disabled) {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-send:not(:disabled) { color: var(--color-accent); }
.btn-send:hover:not(:disabled) { background: var(--color-accent-dim); }

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 0;
}

.char-count { font-size: 11px; color: var(--color-text-muted); }
.powered-by { font-size: 11px; color: var(--color-text-muted); letter-spacing: 0.02em; }

/* --- Responsive --- */

@media (max-width: 640px) {
  #app { max-width: 100%; }
  .header { padding: 10px 14px; }
  .transcript { padding: 14px; gap: 12px; }
  .message { max-width: 92%; }
  .input-bar { padding: 10px 14px 14px; }
  .header-subtitle { display: none; }
}

::selection {
  background: var(--color-accent-dim);
  color: var(--color-text-primary);
}
