:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.25);
  
  --secondary: #0ea5e9;
  --secondary-glow: rgba(14, 165, 233, 0.2);
  
  --accent: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --bg-main: #0b1120;
  --bg-card: rgba(23, 33, 53, 0.82);
  --bg-card-hover: rgba(30, 45, 74, 0.88);
  --border-card: rgba(255, 255, 255, 0.1);
  --border-card-hover: rgba(255, 255, 255, 0.2);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 8px 30px rgba(79, 70, 229, 0.35);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.6;
}

/* Background glowing blur orbs */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #4f46e5, #3b82f6);
  top: -120px;
  left: -120px;
}

.orb-2 {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, #8b5cf6, #ec4899);
  bottom: -120px;
  right: -120px;
}

/* Application Layout Container */
.app-layout {
  position: relative;
  z-index: 1;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  gap: 20px;
}

/* Main Header */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  width: 100%;
  transition: var(--transition-fast);
}

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

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.brand-text h1 span {
  background: linear-gradient(135deg, #818cf8, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
}

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

.btn-lang-toggle,
.status-badge,
.btn-metrics {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-lang-toggle {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8;
  cursor: pointer;
}

.btn-lang-toggle:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: rgba(56, 189, 248, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.status-badge {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 10px #34d399;
  animation: pulse-dot 2s infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-metrics {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  cursor: pointer;
}

.btn-metrics:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* Main Container */
.main-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  flex: 1;
}

/* Glass Cards */
.portal-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-subtle);
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: var(--transition-fast);
}

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

.header-icon {
  width: 42px;
  height: 42px;
  background: rgba(79, 70, 229, 0.15);
  border: 1px solid rgba(79, 70, 229, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: #818cf8;
  flex-shrink: 0;
}

.header-icon.icon-ai {
  background: rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.3);
  color: #38bdf8;
}

.avatar-sofia-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.card-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.card-header p {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Quick Prompts Chips */
.quick-prompts-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.3;
}

.chip:hover {
  background: rgba(79, 70, 229, 0.25);
  border-color: rgba(99, 102, 241, 0.5);
  color: #c7d2fe;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.chip:active {
  transform: translateY(0);
}

/* Form Elements */
.inquiry-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  gap: 14px;
}

.flex-1 {
  flex: 1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group label .required {
  color: var(--danger);
}

input[type="text"],
select,
textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
  transition: var(--transition-fast);
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
  background: rgba(15, 23, 42, 0.9);
}

select {
  cursor: pointer;
}

select option {
  background-color: #1e293b;
  color: #fff;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-glow);
  transition: var(--transition-fast);
  touch-action: manipulation;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* ==============================================================================
   CHAT INTERFACE & MODERN CONVERSATIONAL VIEW
   ============================================================================== */

.response-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-new-chat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #c7d2fe;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  touch-action: manipulation;
}

.btn-new-chat:hover {
  background: rgba(99, 102, 241, 0.35);
  color: #fff;
  transform: translateY(-1px);
}

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 520px;
  min-height: 260px;
  overflow-y: auto;
  padding-right: 6px;
  scroll-behavior: smooth;
}

.chat-stream::-webkit-scrollbar {
  width: 6px;
}

.chat-stream::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.chat-msg {
  display: flex;
  gap: 12px;
  animation: fadeInMsg 0.3s ease-out;
}

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

.msg-user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
}

.msg-avatar.avatar-ai {
  background: transparent;
  padding: 0;
  overflow: hidden;
  border: 2px solid #38bdf8;
}

.msg-bubble {
  max-width: 86%;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  word-break: break-word;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.msg-user .msg-bubble {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.32), rgba(99, 102, 241, 0.22));
  border-color: rgba(99, 102, 241, 0.45);
  border-bottom-right-radius: 4px;
}

.msg-assistant .msg-bubble {
  border-bottom-left-radius: 4px;
}

.msg-author-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.msg-author-name {
  font-weight: 700;
  color: #e2e8f0;
}

.markdown-content {
  font-size: 0.9rem;
  line-height: 1.65;
  color: #e2e8f0;
}

.markdown-content p {
  margin-bottom: 8px;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

.markdown-content ul, 
.markdown-content ol {
  margin: 6px 0 10px 20px;
}

.markdown-content li {
  margin-bottom: 4px;
}

.markdown-content strong {
  color: #fff;
  font-weight: 600;
}

/* In-Chat Follow-up Bar (Redesigned Capsule) */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 16px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-full);
  margin-top: 10px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  transition: all 0.2s ease;
}

.chat-input-bar:focus-within {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.25), 0 8px 30px rgba(0, 0, 0, 0.45);
  background: rgba(15, 23, 42, 0.98);
}

.chat-input-bar input {
  flex: 1;
  height: 42px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 4px 0 0;
  color: #fff;
  font-family: inherit;
  font-size: 16px; /* Prevents auto-zoom in iOS */
  outline: none !important;
}

.chat-input-bar input::placeholder {
  color: var(--text-dim);
  font-size: 0.88rem;
}

.btn-send {
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: all 0.2s ease;
  flex-shrink: 0;
  touch-action: manipulation;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.03);
  filter: brightness(1.15);
}

.btn-send:active:not(:disabled) {
  transform: scale(0.97);
}

/* Escalation & Sources */
.alert-box {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.alert-escalation {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fef3c7;
}

.alert-icon {
  font-size: 20px;
  color: #f59e0b;
}

.alert-content h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fcd34d;
  margin-bottom: 2px;
}

.alert-content p {
  font-size: 0.82rem;
  color: #fde68a;
}

.btn-escalate-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 7px 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-escalate-opt:hover {
  background: rgba(245, 158, 11, 0.25);
  color: #fff;
  transform: translateY(-1px);
}

/* Response Meta Bar & Distinct Color-coded Tags */
.response-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.tag-topic {
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.45);
  color: #c7d2fe;
}

.tag-cache {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
}

.tag-rag {
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.tag-escalated {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: #fde68a;
}

/* Consulted Sources Accordion & Cards */
.sources-details {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-top: 12px;
  transition: all 0.25s ease;
}

.sources-details[open] {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.details-summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  outline: none;
  user-select: none;
}

.sources-summary-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sources-summary-title i {
  color: #38bdf8;
}

.sources-meta-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tokens-badge {
  color: #c084fc;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(192, 132, 252, 0.14);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(192, 132, 252, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.latency-badge {
  color: #38bdf8;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.14);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.source-item {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid #38bdf8;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
}

.source-item:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(56, 189, 248, 0.4);
}

.source-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.source-doc-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.source-doc-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.source-doc-text {
  display: flex;
  flex-direction: column;
}

.source-doc-name {
  font-size: 0.84rem;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.2;
}

.source-doc-file {
  font-size: 0.7rem;
  color: #64748b;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 4px;
}

.source-score-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: var(--radius-full);
  padding: 3px 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.source-snippet {
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.5;
  background: rgba(15, 23, 42, 0.65);
  border-radius: 6px;
  padding: 8px 10px;
  font-style: italic;
  display: flex;
  gap: 8px;
  word-break: break-word;
}

.source-snippet .quote-icon {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
  flex-shrink: 0;
}

.no-sources-msg {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.session-end-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: #ef4444;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-new-chat-in-chat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: var(--transition-fast);
}

.btn-new-chat-in-chat:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

/* Metrics Drawer */
.metrics-drawer {
  position: fixed;
  top: 0;
  right: -450px;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: #141f36;
  border-left: 1px solid var(--border-card);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: right var(--transition-smooth);
}

.metrics-drawer.open {
  right: 0;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-card);
}

.drawer-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}

.drawer-header p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.close-drawer-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: var(--transition-fast);
}

.close-drawer-btn:hover {
  color: #fff;
}

.drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.metrics-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.metric-icon {
  font-size: 17px;
  color: #818cf8;
  margin-bottom: 2px;
}

.metric-icon.icon-warning { color: #fbbf24; }
.metric-icon.icon-success { color: #34d399; }
.metric-icon.icon-purple { color: #c084fc; }

.metric-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.drawer-footer-actions {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-card);
}

.btn-reset-metrics {
  width: 100%;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-reset-metrics:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
  color: #fff;
  border-color: rgba(239, 68, 68, 0.6);
  transform: translateY(-1px);
}

.btn-reset-metrics:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Utility */
.hidden {
  display: none !important;
}

/* ==============================================================================
   RESPONSIVE DESIGN & MOBILE OPTIMIZATIONS FOR SMARTPHONES
   ============================================================================== */

@media (max-width: 680px) {
  .app-layout {
    padding: 12px 10px;
    gap: 12px;
  }

  .main-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 16px;
  }

  .header-brand {
    justify-content: flex-start;
    gap: 10px;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .brand-text h1 {
    font-size: 1.15rem;
  }

  .brand-subtitle {
    font-size: 0.72rem;
  }

  .header-actions {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
  }

  .btn-lang-toggle,
  .status-badge,
  .btn-metrics {
    flex: 1;
    height: 34px;
    padding: 0 8px;
    font-size: 0.75rem;
    justify-content: center;
  }

  .portal-card {
    padding: 16px 12px;
    border-radius: 16px;
    gap: 12px;
  }

  .card-header {
    gap: 10px;
    padding-bottom: 10px;
  }

  .card-header h2 {
    font-size: 1.05rem;
  }

  .card-header p {
    font-size: 0.76rem;
  }

  .header-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .chips-grid {
    gap: 6px;
  }

  .chip {
    padding: 6px 11px;
    font-size: 0.76rem;
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  .form-actions {
    flex-direction: column-reverse;
    gap: 8px;
    width: 100%;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
    height: 44px;
  }

  /* Chat Stream on Mobile */
  .chat-stream {
    max-height: 58vh;
    min-height: 240px;
    padding-right: 2px;
    gap: 12px;
  }

  .msg-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .msg-bubble {
    max-width: 90%;
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 0.86rem;
  }

  .details-summary-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .sources-meta-badges {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }

  .sources-details {
    padding: 8px 10px;
    border-radius: 10px;
  }

  .source-item {
    padding: 8px 10px;
  }

  .source-item-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .source-doc-name {
    font-size: 0.78rem;
  }

  .source-doc-file {
    font-size: 0.66rem;
  }

  .source-score-pill {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  .source-snippet {
    font-size: 0.76rem;
    padding: 6px 8px;
  }

  .tag {
    font-size: 0.68rem;
    padding: 3px 8px;
  }

  /* Mobile Chat Input Bar */
  .chat-input-bar {
    padding: 4px 4px 4px 14px;
    gap: 6px;
    margin-top: 8px;
    border-radius: 28px;
    background: rgba(15, 23, 42, 0.95);
  }

  .chat-input-bar input {
    height: 40px;
    font-size: 16px;
  }

  .chat-input-bar input::placeholder {
    font-size: 0.8rem;
  }

  .send-text-label {
    display: none;
  }

  .btn-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
    font-size: 15px;
    gap: 0;
  }

  .btn-new-chat {
    padding: 5px 10px;
    font-size: 0.72rem;
  }

  .metrics-drawer {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
  }

  .metrics-drawer.open {
    right: 0;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    padding: 10px 8px;
  }

  .metric-value {
    font-size: 1.15rem;
  }
}

@media (max-width: 380px) {
  .brand-text h1 {
    font-size: 1.02rem;
  }

  .btn-lang-toggle,
  .status-badge,
  .btn-metrics {
    font-size: 0.68rem;
    padding: 0 4px;
    gap: 3px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
