/* ==================== DESIGN TOKENS & ROOT variables ==================== */
:root {
  --bg-primary: #0B0B0C;
  --bg-secondary: #121214;
  --card-bg: #1A1A1E;
  --card-border: rgba(255, 255, 255, 0.05);
  
  --accent-primary: #3B82F6; /* Electric Blue */
  --accent-glow: rgba(59, 130, 246, 0.4);
  --accent-secondary: #06B6D4; /* Cyan / Mic Record */
  --accent-secondary-glow: rgba(6, 182, 212, 0.4);
  
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-inverse: #000000;
  
  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;
  
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 24px;
  
  --font-display: 'Outfit', sans-serif;
  --font-text: 'Inter', sans-serif;
  --font-marathi: 'Noto Sans Marathi', sans-serif;
  
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-top: env(safe-area-inset-top, 0px);
}

/* ==================== RESET & CORE STYLES ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-text);
  overflow: hidden;
  font-size: 16px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
}

/* Scrollbar Style */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==================== UTILITY STYLES ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  border: none;
  font-family: var(--font-display);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #1D4ED8);
  color: #FFF;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger-icon {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}
.btn-danger-icon:active {
  background: var(--danger);
  color: #FFF;
}

.btn-block {
  width: 100%;
}

.input-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.input-group label {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--text-muted);
}
.input-group input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  padding: 14px;
  border-radius: var(--border-radius-md);
  color: var(--text-main);
  font-family: var(--font-text);
  font-size: 1rem;
  transition: border-color 0.2s;
}
.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* ==================== SCREEN OVERLAYS (LOGIN) ==================== */
.screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.login-card {
  background: rgba(26, 26, 30, 0.6);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  width: 100%;
  max-width: 400px;
  padding: 40px 30px;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.4s ease-out;
}

.login-logo {
  text-align: center;
  margin-bottom: 35px;
}

.logo-glow-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,0.2) 0%, rgba(0,0,0,0) 70%);
  border: 1px solid var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 15px;
}
.logo-icon {
  font-size: 1.8rem;
  color: var(--accent-primary);
  filter: drop-shadow(0 0 4px var(--accent-glow));
}

.login-logo h1 {
  font-size: 1.6rem;
  letter-spacing: 1.5px;
  margin-bottom: 5px;
  color: var(--text-main);
}
.login-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 15px;
  text-align: center;
}

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

/* ==================== MAIN CONTAINER LAYOUT ==================== */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  padding-top: var(--safe-area-top);
  padding-bottom: var(--safe-area-bottom);
}

/* Sidebar Styling (Desktop Only) */
.sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 24px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}
.sidebar-content {
  flex-grow: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}
.status-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 15px;
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.online {
  background-color: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}
.info-box {
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.1);
  padding: 15px;
  border-radius: var(--border-radius-md);
}
.info-box h3 {
  font-size: 0.9rem;
  color: var(--accent-primary);
  margin-bottom: 8px;
}
.info-box p {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
}
.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.02);
}

/* Chat Workspace */
.chat-workspace {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  position: relative;
  height: 100%;
}

/* Glassmorphic Header */
.app-header {
  height: 70px;
  background: rgba(11, 11, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-size: 1.1rem;
}
.header-titles h2 {
  font-size: 1rem;
  font-weight: 600;
}
.header-titles .sub-title {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
}
.header-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}
.header-btn.logout:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* ==================== MESSAGES CONTAINER ==================== */
.messages-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.welcome-banner {
  text-align: center;
  max-width: 500px;
  margin: auto;
  padding: 20px;
  animation: fadeIn 0.5s;
}
.welcome-icon {
  font-size: 2.5rem;
  color: var(--accent-primary);
  margin-bottom: 15px;
  opacity: 0.8;
}
.welcome-banner h2 {
  font-size: 1.4rem;
  margin-bottom: 10px;
}
.welcome-banner p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 25px;
}
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  padding: 8px 16px;
  border-radius: 20px;
  color: var(--text-main);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-text);
}
.chip:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #FFF;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Message Bubbles */
.message-row {
  display: flex;
  width: 100%;
}
.message-row.user {
  justify-content: flex-end;
}
.message-row.jarvis {
  justify-content: flex-start;
}

.msg-bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: var(--border-radius-md);
  font-size: 0.95rem;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  animation: popIn 0.3s cubic-bezier(0.1, 0.8, 0.25, 1);
}

.message-row.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent-primary), #1D4ED8);
  color: #FFF;
  border-top-right-radius: 2px;
}
.message-row.jarvis .msg-bubble {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  border-top-left-radius: 2px;
}

.msg-meta {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
  opacity: 0.7;
}
.message-row.user .msg-meta {
  color: rgba(255, 255, 255, 0.7);
}

@keyframes popIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Markdown Rendering Inside Bubbles */
.msg-bubble p {
  margin-bottom: 8px;
}
.msg-bubble p:last-child {
  margin-bottom: 0;
}
.msg-bubble ul, .msg-bubble ol {
  margin-left: 20px;
  margin-bottom: 8px;
}
.msg-bubble li {
  margin-bottom: 4px;
}
.msg-bubble code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}
.msg-bubble pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  overflow-x: auto;
  margin-bottom: 8px;
}
.msg-bubble pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.msg-bubble strong {
  font-weight: 600;
}

/* Premium styled preview link card */
.preview-link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  margin-top: 10px;
  text-decoration: none;
  color: var(--text-main);
  transition: background 0.2s;
}
.preview-link-card:hover {
  background: rgba(255, 255, 255, 0.05);
}
.link-card-icon {
  font-size: 1.5rem;
  color: var(--accent-primary);
}
.link-card-info {
  display: flex;
  flex-direction: column;
}
.link-card-info .link-title {
  font-weight: 500;
  font-size: 0.85rem;
}
.link-card-info .link-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.preview-image-card {
  max-width: 100%;
  border-radius: var(--border-radius-sm);
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: block;
}

/* ==================== ATTACHMENTS BAR ==================== */
.attachments-bar {
  background: rgba(22, 22, 24, 0.9);
  border-top: 1px solid var(--card-border);
  padding: 12px 20px;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  flex-shrink: 0;
  z-index: 5;
}
.attach-preview-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--card-border);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background-color: var(--bg-primary);
}
.attach-preview-item .remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: #FFF;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  border: none;
  cursor: pointer;
}

/* ==================== INPUT PANEL (BOTTOM DOCK) ==================== */
.input-panel {
  padding: 15px 20px 25px;
  background: rgba(11, 11, 12, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
  z-index: 10;
}

.chat-form-element {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
}

.input-action-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.input-action-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.textarea-wrapper {
  flex-grow: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 10px 18px;
  max-height: 150px;
  display: flex;
  align-items: center;
  transition: all 0.25s ease;
  cursor: text;
}
.textarea-wrapper:focus-within {
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 10px var(--accent-glow);
}
.textarea-wrapper textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-text);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  line-height: 1.4;
  height: 22px;
}
.textarea-wrapper textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.65;
  font-weight: 400;
}

.input-submit-btn {
  border: none;
  color: #FFF;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Mic Mode Icon Accent (Cyan Glow) */
.input-submit-btn.mic-mode {
  background: linear-gradient(135deg, var(--accent-secondary), #0891B2);
  box-shadow: 0 4px 10px var(--accent-secondary-glow);
}
.input-submit-btn.send-mode {
  background: linear-gradient(135deg, var(--accent-primary), #1D4ED8);
  box-shadow: 0 4px 10px var(--accent-glow);
}
.input-submit-btn:active {
  transform: scale(0.92);
}

/* ==================== TYPING INDICATOR ==================== */
.typing-indicator-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
}
.typing-bubble {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 12px 16px;
  border-radius: var(--border-radius-md);
  border-top-left-radius: 2px;
  display: inline-flex;
  gap: 4px;
}
.typing-bubble .dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1.4s infinite;
}
.typing-bubble .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble .dot:nth-child(3) { animation-delay: 0.4s; }

.typing-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

@keyframes typing {
  50% { opacity: 1; transform: translateY(-3px); }
}

/* ==================== VOICE OVERLAY VISUALIZATION ==================== */
.voice-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(11, 11, 12, 0.95);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  animation: fadeIn 0.2s ease-out;
}
.waveform-container {
  width: 90%;
  max-width: 500px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#waveform-canvas {
  width: 100%;
  height: 100%;
}
.voice-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.4rem;
}
.recording-dot {
  width: 12px;
  height: 12px;
  background-color: var(--danger);
  border-radius: 50%;
  animation: pulse 1s infinite alternate;
}
@keyframes pulse {
  from { opacity: 0.3; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.25); box-shadow: 0 0 10px rgba(239, 68, 68, 0.8); }
}

.voice-controls {
  text-align: center;
}
.voice-controls p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 15px;
}

/* ==================== MODALS (SETTINGS) ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s;
}
.modal-box {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  width: 100%;
  max-width: 450px;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  animation: popIn 0.3s cubic-bezier(0.1, 0.8, 0.25, 1);
}
.modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}
.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-muted);
}
.modal-close-btn:hover {
  color: var(--text-main);
}
.modal-body {
  padding: 25px;
}
.modal-body small {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 4px;
}
.modal-footer {
  padding: 15px 25px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: flex-end;
}

/* Copy Box & Credentials update styles */
.copy-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  margin-top: 8px;
  gap: 10px;
}
.copy-box span {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--accent-secondary);
  word-break: break-all;
  user-select: all;
}
.copy-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.copy-btn:hover {
  background: var(--accent-primary);
  color: #FFF;
  border-color: var(--accent-primary);
}
.copy-btn:active {
  transform: scale(0.95);
}

/* ==================== MOBILE MEDIA QUERIES (RESPONSIVENESS) ==================== */
@media (max-width: 992px) {
  .sidebar {
    display: none; /* Hide log sidebar on mobile */
  }
}

@media (max-width: 576px) {
  body {
    font-size: 15px;
  }
  .app-header {
    height: 60px;
    padding: 0 15px;
  }
  .messages-container {
    padding: 15px;
    gap: 15px;
  }
  .msg-bubble {
    max-width: 88%;
    padding: 12px 14px;
  }
  .input-panel {
    padding: 10px 12px calc(15px + var(--safe-area-bottom));
  }
  .textarea-wrapper {
    padding: 8px 14px;
  }
  .input-action-btn, .input-submit-btn {
    width: 42px;
    height: 42px;
  }
  .login-card {
    padding: 30px 20px;
  }
}

/* Native-like PWA Standalone Display tweaks */
@media all and (display-mode: standalone) {
  .app-container {
    /* More spacing to accommodate OS navigation bars and notifications status bars */
    padding-top: max(var(--safe-area-top), 10px);
  }
  .app-header {
    margin-top: 5px;
  }
}
