/* Lux App — hell, warm, lesbar */

:root {
  --bg: #F5F0EB;
  --bg-chat: #FFFFFF;
  --bg-user: #E8E0D8;
  --bg-lux: #FFFFFF;
  --text: #2C2C2C;
  --text-light: #6B6560;
  --accent: #8B7355;
  --accent-hover: #6B5740;
  --border: #E0D8D0;
  --shadow: rgba(0, 0, 0, 0.06);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
}

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

header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
}

#model-toggle {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  background: var(--bg-user);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 8px 4px 10px;
  cursor: pointer;
  transition: all 0.2s;
}

#model-toggle:focus {
  outline: none;
  border-color: var(--text-light);
}

#model-toggle.switching {
  opacity: 0.5;
  pointer-events: none;
}

#push-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
  position: relative;
}

#push-btn:hover {
  background: var(--border);
}

#push-btn.active {
  color: var(--accent);
  background: rgba(139, 115, 85, 0.15);
}

#push-dot {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  background: #4CAF50;
  border-radius: 50%;
  border: 2px solid var(--bg);
}
#push-btn.active #push-dot {
  display: block;
}

/* --- Messages --- */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.message {
  max-width: 85%;
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  animation: fadeIn 0.2s ease-out;
}

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

.message.user {
  background: var(--bg-user);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  background: var(--bg-lux);
  margin-right: auto;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px var(--shadow);
}

.message .time {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

/* Markdown in messages */
.message p { margin-bottom: 8px; }
.message p:last-child { margin-bottom: 0; }
.message em { font-style: italic; }
.message strong { font-weight: 600; }
.message code {
  background: rgba(0,0,0,0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 15px;
  font-family: "SF Mono", "Fira Code", monospace;
}
.message pre {
  background: rgba(0,0,0,0.06);
  padding: 12px;
  border-radius: 8px;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.message pre code {
  background: none;
  padding: 0;
  white-space: inherit;
  word-break: inherit;
  overflow-wrap: inherit;
}
.message img {
  max-width: 100%;
  border-radius: 8px;
  margin: 4px 0;
  cursor: pointer;
}
.message .chat-image {
  max-width: 100%;
  border-radius: 8px;
  margin: 4px 0;
}
.message .file-link {
  display: inline-block;
  padding: 8px 12px;
  background: rgba(0,0,0,0.06);
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 15px;
}
.message .file-link:hover {
  background: rgba(0,0,0,0.1);
}
/* --- Voice Messages --- */
.voice-message {
  padding: 4px 8px !important;
  max-width: 160px !important;
  min-width: 0 !important;
}

.voice-message .time {
  display: none;
}

.voice-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-play-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.voice-play-btn:active {
  transform: scale(0.9);
}

.voice-wave-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  height: 16px;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 1.5px;
  height: 100%;
}

.wave-bar {
  width: 2px;
  border-radius: 1px;
  background: var(--border);
  transition: background 0.12s;
  flex-shrink: 0;
}

.wave-bar.played {
  background: var(--accent);
}

.message.user .wave-bar {
  background: rgba(0,0,0,0.15);
}

.message.user .wave-bar.played {
  background: var(--accent-hover);
}

.voice-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
}

.voice-duration {
  font-size: 10px;
  color: var(--text-light);
  flex-shrink: 0;
  min-width: 24px;
  text-align: right;
}

.voice-transcript {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-light);
  font-style: italic;
  line-height: 1.3;
}

.voice-transcript p {
  margin-bottom: 2px;
}

.voice-transcript p:last-child {
  margin-bottom: 0;
}

/* Voice recording state */
#mic-btn.voice-recording {
  color: #D32F2F;
  background: rgba(211, 47, 47, 0.15);
  animation: voicePulse 0.8s infinite;
  box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4);
}

@keyframes voicePulse {
  0% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(211, 47, 47, 0); }
  100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0); }
}

/* Emoji picker */
.emoji-picker {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  margin-top: 6px;
  animation: fadeIn 0.15s ease-out;
}
.emoji-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: transform 0.15s;
}
.emoji-btn:hover, .emoji-btn:active {
  transform: scale(1.3);
}

/* Reaction display */
.reaction-display {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.reaction-badge {
  font-size: 18px;
  padding: 2px 4px;
  border-radius: 12px;
  background: rgba(0,0,0,0.04);
  cursor: default;
}

/* --- Typing indicator --- */
.typing {
  display: none;
  max-width: 85%;
  margin-bottom: 12px;
  padding: 12px 16px;
  background: var(--bg-lux);
  border-radius: var(--radius);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px var(--shadow);
  color: var(--text-light);
  font-style: italic;
}

.typing.visible {
  display: block;
}

/* --- Input area --- */
#input-area {
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.image-preview-item {
  position: relative;
  padding: 4px;
  background: var(--bg-chat);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 120px;
}
.image-preview-item img {
  display: block;
  max-width: 100%;
  max-height: 100px;
  border-radius: 8px;
  object-fit: cover;
}
.image-preview-item span {
  display: block;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  word-break: break-all;
}
.image-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-chat);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
}

#input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  color: var(--text);
  resize: none;
  max-height: 120px;
  padding: 8px 0;
}

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

#mic-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s, background 0.2s;
}
#mic-btn:hover {
  color: var(--accent);
}
#mic-btn.recording {
  color: #D32F2F;
  background: rgba(211, 47, 47, 0.1);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

#image-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s;
}

#image-btn:hover {
  color: var(--accent);
}

#send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

#send-btn:hover {
  background: var(--accent-hover);
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Connection status --- */
#status {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  padding: 4px;
  z-index: 100;
  transition: transform 0.3s;
  transform: translateY(-100%);
}

#status.disconnected {
  background: #D4A574;
  color: white;
  transform: translateY(0);
}

/* Permission-Dialog-Styles entfernt 24.04.2026 (toter Code, siehe server.ts). */

/* Scrollbar */
#messages::-webkit-scrollbar {
  width: 4px;
}
#messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
