/* ===========================================
   ENOCH PWA — Theme & Styles
   Ported from desktop/src/renderer/index.css
   =========================================== */

:root {
  /* Core background */
  --bg: #050510;
  --bg-elevated: #0a0a1a;

  /* Card system */
  --card: rgba(10, 10, 30, 0.6);
  --card-border: rgba(0, 255, 255, 0.08);
  --card-hover: rgba(0, 255, 255, 0.04);

  /* Neon accents */
  --accent: #00fff0;
  --accent-dim: rgba(0, 255, 240, 0.12);
  --purple: #bf5af2;
  --neon-red: #ff003c;
  --neon-green: #39ff14;

  /* Text */
  --text: rgba(224, 240, 255, 0.92);
  --text-dim: rgba(140, 160, 200, 0.5);
  --text-mid: rgba(180, 200, 240, 0.7);

  /* Glows */
  --glow-cyan: 0 0 10px rgba(0, 255, 240, 0.3), 0 0 40px rgba(0, 255, 240, 0.1);

  /* Fonts */
  --font-sans: 'Exo 2', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ===========================================
   RESET & BASE
   =========================================== */

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

html, body {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ===========================================
   APP LAYOUT
   =========================================== */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: -webkit-fill-available;
  position: relative;
  overflow: hidden;
}

/* ===========================================
   HEADER
   =========================================== */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.3s;
}

.status-dot.connected {
  background: var(--neon-green);
  box-shadow: 0 0 6px var(--neon-green);
}

.status-dot.connecting,
.status-dot.reconnecting {
  background: #ffaa00;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.disconnected {
  background: var(--neon-red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  font-family: var(--font-sans);
  color: var(--accent);
  text-shadow: 0 0 10px rgba(0, 255, 240, 0.5), 0 0 30px rgba(0, 255, 240, 0.2);
}

.status-text {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.2s;
}

.icon-btn:active {
  color: var(--accent);
}

/* ===========================================
   MESSAGE LIST
   =========================================== */

#messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ===========================================
   MESSAGE BUBBLES
   =========================================== */

.msg {
  display: flex;
  padding: 3px 0;
  animation: fadeIn 0.2s ease-out;
}

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

.msg.user { justify-content: flex-end; }
.msg.bot, .msg.notification { justify-content: flex-start; }
.msg.system { justify-content: center; }

.msg-bubble {
  max-width: 85%;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

/* User bubble */
.msg.user .msg-bubble {
  background: rgba(0, 255, 240, 0.08);
  border: 1px solid rgba(0, 255, 240, 0.15);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

/* Bot bubble */
.msg.bot .msg-bubble {
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Notification bubble */
.msg.notification .msg-bubble {
  background: rgba(191, 90, 242, 0.08);
  border: 1px solid rgba(191, 90, 242, 0.15);
  color: var(--text);
  font-style: italic;
  border-bottom-left-radius: 4px;
}

/* System message */
.msg.system .msg-bubble {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: rgba(255, 0, 60, 0.7);
  font-style: italic;
}

/* File attachment label */
.msg-file {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: rgba(0, 255, 240, 0.7);
  margin-bottom: 4px;
}

/* Message footer (time + copy) */
.msg-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  gap: 8px;
}

.msg.user .msg-footer {
  justify-content: flex-end;
}

.msg-time {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.copy-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  opacity: 0.4;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  transition: opacity 0.2s, color 0.2s;
}

.copy-btn:active {
  opacity: 1;
  color: var(--accent);
}

/* ===========================================
   MESSAGE CONTENT (from bot HTML)
   =========================================== */

.message-content { word-break: break-word; }
.message-content strong { font-weight: 600; }
.message-content em { font-style: italic; }
.message-content code {
  background: rgba(0, 255, 240, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.message-content pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.message-content li {
  margin-left: 8px;
  list-style: none;
}
.message-content li::before {
  content: '\2022 ';
  color: var(--accent);
}
.message-content p + p {
  margin-top: 8px;
}
.message-content a {
  color: var(--accent);
  text-decoration: underline;
}
.message-content h1, .message-content h2, .message-content h3 {
  font-weight: 600;
  margin: 8px 0 4px;
}

/* ===========================================
   TYPING INDICATOR
   =========================================== */

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

.typing-dots {
  display: flex;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.4;
  animation: bounce 1.4s ease-in-out infinite;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.typing-text {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-style: italic;
}

/* ===========================================
   FILE PREVIEW BAR
   =========================================== */

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
}

.file-preview-name {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-preview-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

/* ===========================================
   INPUT AREA
   =========================================== */

.input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
  background: var(--bg-elevated);
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
}

.attach-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

#message-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 255, 240, 0.1);
  border-radius: 20px;
  color: var(--text);
  padding: 10px 16px;
  font-size: 15px;
  font-family: var(--font-sans);
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

#message-input:focus {
  border-color: rgba(0, 255, 240, 0.4);
}

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

.send-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 255, 240, 0.15);
  border: 1px solid rgba(0, 255, 240, 0.3);
  border-radius: 50%;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.send-btn:not(:disabled):active {
  background: rgba(0, 255, 240, 0.3);
  box-shadow: 0 0 15px rgba(0, 255, 240, 0.2);
}

/* ===========================================
   SETUP / SETTINGS OVERLAY
   =========================================== */

.setup-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.setup-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.15em;
  font-family: var(--font-sans);
  color: var(--accent);
  text-shadow: 0 0 10px rgba(0, 255, 240, 0.5), 0 0 30px rgba(0, 255, 240, 0.2);
  text-align: center;
}

.setup-subtitle {
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-align: center;
}

.setup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-field label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.setup-actions {
  display: flex;
  gap: 8px;
}

.setup-actions .btn-neon-solid,
.setup-actions .btn-neon {
  flex: 1;
}

.setup-save-btn {
  width: 100%;
  padding: 12px;
}

/* ===========================================
   SHARED COMPONENT STYLES
   =========================================== */

.input-neon {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 255, 240, 0.1);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.input-neon:focus {
  border-color: rgba(0, 255, 240, 0.4);
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.1);
}

.input-neon::placeholder {
  color: var(--text-dim);
}

.btn-neon {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-neon:active {
  background: rgba(0, 255, 240, 0.1);
}

.btn-neon-solid {
  background: rgba(0, 255, 240, 0.15);
  border: 1px solid rgba(0, 255, 240, 0.4);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.1);
}

.btn-neon-solid:active {
  background: rgba(0, 255, 240, 0.25);
  box-shadow: 0 0 20px rgba(0, 255, 240, 0.2);
}

.btn-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 8px;
  text-align: center;
  transition: color 0.2s;
}

.btn-clear:active { color: var(--text); }
.btn-danger:active { color: var(--neon-red); }

/* ===========================================
   SCROLLBAR
   =========================================== */

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 255, 240, 0.15); border-radius: 2px; }

::selection {
  background: rgba(0, 255, 240, 0.2);
  color: var(--text);
}

/* ===========================================
   NEW MESSAGES BADGE
   =========================================== */

.new-messages-badge {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 255, 240, 0.15);
  border: 1px solid rgba(0, 255, 240, 0.4);
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 0 10px rgba(0, 255, 240, 0.1);
  animation: fadeIn 0.2s ease-out;
}

/* ===========================================
   LIGHT THEME
   =========================================== */

[data-theme="light"] {
  --bg: #f4f6f9;
  --bg-elevated: #ffffff;
  --card: rgba(255, 255, 255, 0.85);
  --card-border: rgba(0, 0, 0, 0.08);
  --card-hover: rgba(255, 255, 255, 0.95);
  --accent: #0891b2;
  --accent-dim: rgba(8, 145, 178, 0.1);
  --purple: #7c3aed;
  --neon-red: #dc2626;
  --neon-green: #059669;
  --text: rgba(15, 23, 42, 0.92);
  --text-dim: rgba(100, 116, 139, 0.7);
  --text-mid: rgba(51, 65, 85, 0.8);
  --glow-cyan: 0 1px 3px rgba(8, 145, 178, 0.15);
}

[data-theme="light"] .brand {
  text-shadow: none;
  color: #0891b2;
}

[data-theme="light"] .setup-brand {
  text-shadow: none;
  color: #0891b2;
}

[data-theme="light"] .msg.user .msg-bubble {
  background: rgba(8, 145, 178, 0.08);
  border-color: rgba(8, 145, 178, 0.15);
}

[data-theme="light"] .msg.bot .msg-bubble {
  background: var(--card);
  border-color: var(--card-border);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .msg.notification .msg-bubble {
  background: rgba(124, 58, 237, 0.06);
  border-color: rgba(124, 58, 237, 0.12);
}

[data-theme="light"] #message-input {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] #message-input:focus {
  border-color: rgba(8, 145, 178, 0.5);
}

[data-theme="light"] .send-btn {
  background: rgba(8, 145, 178, 0.1);
  border-color: rgba(8, 145, 178, 0.3);
  color: #0891b2;
}

[data-theme="light"] .input-neon {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .input-neon:focus {
  border-color: rgba(8, 145, 178, 0.5);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1);
}

[data-theme="light"] .btn-neon {
  border-color: #0891b2;
  color: #0891b2;
}

[data-theme="light"] .btn-neon-solid {
  background: rgba(8, 145, 178, 0.1);
  border-color: rgba(8, 145, 178, 0.3);
  color: #0891b2;
  box-shadow: 0 1px 3px rgba(8, 145, 178, 0.08);
}

[data-theme="light"] .message-content code {
  background: rgba(8, 145, 178, 0.08);
}

[data-theme="light"] .message-content pre {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .message-content li::before {
  color: #0891b2;
}

[data-theme="light"] .dot {
  background: #0891b2;
}

[data-theme="light"] .status-dot.connected {
  background: var(--neon-green);
  box-shadow: 0 0 4px var(--neon-green);
}

[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.12); }
[data-theme="light"] ::selection { background: rgba(8, 145, 178, 0.2); }

[data-theme="light"] .new-messages-badge {
  background: rgba(8, 145, 178, 0.1);
  border-color: rgba(8, 145, 178, 0.3);
  color: #0891b2;
}
