/* ============================================
   DR. FUMANCHU — Web App Styles
   Colors: Dragon Gold #c9a84c | Jade #2a6a40 | Void Black #0d0d0d
   ============================================ */

:root {
  --bg:        #0d0d0d;
  --bg2:       #111209;
  --bg3:       #161510;
  --gold:      #c9a84c;
  --gold-dim:  #7a6030;
  --jade:      #2a6a40;
  --jade-light:#5aaa70;
  --text:      #f2f2f2;
  --text2:     #c0bdb8;
  --text3:     #706a60;
  --border:    #1e1e14;
  --border2:   #2a2a1a;
  --red:       #8a3030;
  --header-h:  56px;
  --nav-h:     64px;
  --radius:    4px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  overflow: hidden;
}

.hidden { display: none !important; }
.active { display: flex !important; }

/* ============================================
   AUTH SCREEN
   ============================================ */
#auth-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(42,106,64,0.12) 0%, var(--bg) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
}

.auth-logo { margin-bottom: 12px; }

.auth-title {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  color: var(--gold);
  letter-spacing: 4px;
  text-transform: uppercase;
}

.auth-subtitle {
  font-size: 11px;
  color: var(--jade-light);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 240px;
}

#auth-pin {
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 14px 16px;
  font-size: 18px;
  letter-spacing: 8px;
  text-align: center;
  border-radius: var(--radius);
  outline: none;
  font-family: 'Inter', sans-serif;
}

#auth-pin:focus { border-color: var(--gold); }

#auth-submit {
  background: var(--gold);
  color: var(--bg);
  border: none;
  padding: 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  transition: opacity 0.2s;
}

#auth-submit:hover { opacity: 0.85; }

.auth-error {
  color: #c07070;
  font-size: 12px;
  margin-top: 4px;
}

/* ============================================
   APP SHELL
   ============================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* HEADER */
.app-header {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}

.header-logo { font-size: 22px; }

.header-title {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 2px;
  flex: 1;
}

.header-datetime {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.5px;
  text-align: right;
}

/* MAIN */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.app-screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  flex-direction: column;
}

.app-screen.active { display: flex; }

/* BOTTOM NAV */
.bottom-nav {
  height: var(--nav-h);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  transition: color 0.2s;
  font-family: 'Inter', sans-serif;
}

.nav-btn.active { color: var(--gold); }
.nav-btn:hover { color: var(--text2); }

.nav-icon { font-size: 20px; }
.nav-label { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }

/* ============================================
   DASHBOARD
   ============================================ */
#screen-dashboard {
  padding: 12px;
  gap: 10px;
  background: var(--bg);
}

.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.widget-icon { font-size: 14px; }

.widget-title {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  flex: 1;
}

.widget-badge {
  background: var(--jade);
  color: var(--text);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.widget-add {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text2);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-add:hover { border-color: var(--gold); color: var(--gold); }

.widget-body { padding: 10px 14px; }

.widget-loading { color: var(--text3); font-size: 11px; padding: 6px 0; }

/* Weather widget */
.widget-weather .weather-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.weather-icon { font-size: 32px; }
.weather-temp { font-size: 28px; color: var(--gold); font-weight: 300; }
.weather-desc { font-size: 11px; color: var(--text2); }
.weather-loc { font-size: 10px; color: var(--text3); letter-spacing: 1px; text-transform: uppercase; }

/* Calendar events */
.cal-event {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.cal-event:last-child { border-bottom: none; }
.cal-time { font-size: 11px; color: var(--gold); min-width: 44px; font-weight: 500; }
.cal-title { font-size: 12px; color: var(--text); flex: 1; }

/* Email items */
.email-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.email-item:last-child { border-bottom: none; }
.email-item:hover .email-subject { color: var(--gold); }
.email-from { font-size: 10px; color: var(--text3); margin-bottom: 2px; }
.email-subject { font-size: 12px; color: var(--text); }

/* Todos */
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.todo-item:last-child { border-bottom: none; }

.todo-check {
  width: 16px; height: 16px;
  border: 1px solid var(--border2);
  border-radius: 2px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.todo-check.done { background: var(--jade); border-color: var(--jade); color: white; }
.todo-text { font-size: 12px; color: var(--text2); flex: 1; }
.todo-text.done { text-decoration: line-through; color: var(--text3); }

.todo-input-row {
  display: flex;
  gap: 8px;
  padding: 8px 0 2px;
}

.todo-input-row input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 10px;
  font-size: 12px;
  border-radius: var(--radius);
  outline: none;
  font-family: 'Inter', sans-serif;
}

.todo-input-row input:focus { border-color: var(--gold); }

.todo-input-row button {
  background: var(--jade);
  border: none;
  color: white;
  padding: 8px 14px;
  font-size: 11px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

/* News items */
.news-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text);
  line-height: 1.5;
}

.news-item:last-child { border-bottom: none; }
.news-item::before { content: '· '; color: var(--gold); }

/* Dashboard avatar banner */
.dashboard-avatar-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 8px;
  background: linear-gradient(135deg, rgba(42,106,64,0.12) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.avatar-orb {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-dim);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-orb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.avatar-name {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  color: var(--text);
  letter-spacing: 0.5px;
}

.avatar-status {
  font-size: 11px;
  color: var(--jade-light);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Agent chips (chat + voice) */
.agent-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0;
}

.agent-chips::-webkit-scrollbar { display: none; }

.agent-chip {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.3px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.agent-chip.active {
  background: rgba(42,106,64,0.25);
  border-color: var(--jade-light);
  color: var(--text);
}

.agent-chip:hover { border-color: var(--gold-dim); color: var(--text); }

/* ============================================
   CHAT
   ============================================ */
#screen-chat {
  display: none;
  flex-direction: column;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-agent-bar {
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.agent-selector {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--gold);
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius);
  outline: none;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  width: 100%;
  max-width: 260px;
}

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

.chat-date-divider {
  text-align: center;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 0;
}

/* Message bubbles */
.msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-agent { align-self: flex-start; }
.msg-user { align-self: flex-end; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
}

.msg-agent .msg-bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
}

.msg-user .msg-bubble {
  background: #1a1408;
  border: 1px solid var(--gold-dim);
  color: var(--text);
}

.msg-meta {
  font-size: 9px;
  color: var(--text3);
  padding: 0 2px;
}

.msg-agent .msg-meta { text-align: left; }
.msg-user .msg-meta { text-align: right; }

/* Typing indicator */
.msg-typing .msg-bubble { padding: 12px 16px; }
.typing-dots { display: flex; gap: 4px; align-items: center; }
.typing-dot {
  width: 6px; height: 6px;
  background: var(--text3);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Quick replies */
.chat-quick-replies {
  display: flex;
  gap: 6px;
  padding: 6px 12px 0;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.quick-reply-chip {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
}

.quick-reply-chip:hover { border-color: var(--gold); color: var(--gold); }

/* Input bar */
.chat-input-area {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  flex-shrink: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 24px;
  padding: 4px 4px 4px 8px;
  margin-top: 6px;
}

.chat-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.chat-btn:hover { opacity: 1; }

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: 'Inter', sans-serif;
  padding: 6px 4px;
}

#chat-input::placeholder { color: var(--text3); }

.chat-send {
  background: var(--gold);
  border: none;
  color: var(--bg);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.chat-send:hover { opacity: 0.85; }

/* File attachment preview */
.attachment-card {
  background: var(--bg3);
  border: 1px solid var(--border2);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.attachment-icon { font-size: 18px; }

/* Markdown in chat */
.msg-bubble strong { color: var(--gold); font-weight: 600; }
.msg-bubble em { color: var(--jade-light); font-style: italic; }
.msg-bubble code {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--jade-light);
}

.msg-bubble ul, .msg-bubble ol {
  padding-left: 16px;
  margin: 6px 0;
}

.msg-bubble li { margin: 3px 0; }

/* ============================================
   VOICE
   ============================================ */
#screen-voice {
  display: none;
  flex-direction: column;
  align-items: stretch;
  background: radial-gradient(ellipse at 50% 50%, rgba(42,106,64,0.08) 0%, var(--bg) 70%);
}

.voice-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 20px 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.voice-agent-name {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  color: var(--text2);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.voice-orb-wrapper {
  position: relative;
  cursor: pointer;
}

#voice-canvas {
  display: block;
}

.voice-state {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.voice-state.listening { color: var(--gold); }
.voice-state.thinking { color: var(--jade-light); }
.voice-state.speaking { color: var(--jade-light); }

.voice-transcript {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text2);
  min-height: 44px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  font-style: italic;
}

.voice-response {
  font-size: 12px;
  color: var(--text3);
  max-width: 320px;
  width: 100%;
  text-align: center;
  line-height: 1.6;
  min-height: 20px;
}

.voice-quick-agents {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 16px;
  flex-wrap: nowrap;
}

.voice-quick-agents::-webkit-scrollbar { display: none; }



.voice-end {
  background: transparent;
  border: 1px solid #3a2a2a;
  color: #907070;
  padding: 8px 20px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  letter-spacing: 1px;
  transition: background 0.2s, border-color 0.2s;
}

.voice-end:hover { background: rgba(90,40,40,0.12); border-color: #5a3a3a; }

/* ============================================
   SCROLLBARS
   ============================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ============================================
   RESPONSIVE — Desktop sidebar
   ============================================ */
@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }

  #app {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .app-header {
    width: 100%;
    order: -1;
  }

  /* TODO: Add left sidebar for desktop in Phase 2 */
}
