/* Design tokens based on requirements:
   - Primary: Royal Blue (#4169E1)
   - Secondary / Backgrounds: white / light grays (#f9f9f9, #ffffff)
   - Frame-less (thin borders or shadows, no hard boxy borders)
   - No gradients, no glows, no emoji, official, icons-heavy
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --primary-color: #4169E1; /* Royal Blue */
  --primary-hover: #2e54c5;
  --bg-color: #ffffff;
  --panel-bg: #fafafa;
  --text-main: #111111;
  --text-muted: #666666;
  --border-color: #eaeaea;
  --chat-bubble-user: #f0f3ff;
  --chat-bubble-assistant: #f5f5f5;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition-smooth: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* App Layout: Centered chat */
.app-container {
  width: 100%;
  max-width: 600px;
  height: 100%;
  max-height: 900px;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

@media(min-width: 601px) {
  .app-container {
    height: 90vh;
    border-radius: 16px;
    border: 1px solid var(--border-color);
  }
}

.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

/* Header */
.chat-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  color: var(--primary-color);
  width: 28px;
  height: 28px;
}

.logo-container h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.logo-container p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-selector {
  display: flex;
  background-color: #f1f1f1;
  padding: 3px;
  border-radius: 8px;
}

.lang-btn {
  background: none;
  border: none;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.lang-btn.active {
  background-color: var(--primary-color);
  color: #ffffff;
}

.admin-link {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  transition: var(--transition-smooth);
}

.admin-link:hover {
  background-color: #f1f1f1;
  color: var(--primary-color);
}

.settings-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.settings-btn:hover, .settings-btn.active {
  background-color: #f1f1f1;
  color: var(--primary-color);
}

/* Sound Settings Panel styling */
.settings-panel {
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.settings-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 1rem 0;
}

.settings-header .panel-icon {
  width: 18px;
  height: 18px;
  color: var(--primary-color);
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setting-item .label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
}

.setting-item .badge {
  background-color: var(--primary-color);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 12px;
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: 600;
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.slider-container input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  background: #e2e8f0;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.slider-container .hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.setting-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 0.25rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
}

.switch-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.switch-container input[type="checkbox"] {
  display: none;
}

.switch-slider {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  background-color: #cbd5e1;
  border-radius: 10px;
  transition: 0.2s;
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
}

.switch-container input[type="checkbox"]:checked + .switch-slider {
  background-color: var(--primary-color);
}

.switch-container input[type="checkbox"]:checked + .switch-slider::before {
  transform: translateX(16px);
}

.switch-label {
  font-size: 0.82rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.message {
  max-width: 80%;
  padding: 1rem 1.2rem;
  font-size: 0.92rem;
  line-height: 1.45;
  border-radius: 12px;
}

.message.user {
  align-self: flex-end;
  background-color: var(--chat-bubble-user);
  color: var(--text-main);
  border-bottom-right-radius: 2px;
}

.message.assistant {
  align-self: flex-start;
  background-color: var(--chat-bubble-assistant);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
}

.message.system {
  align-self: center;
  max-width: 95%;
  background-color: transparent;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border: 1px dashed var(--border-color);
}

/* Quick Options (Support Buttons) */
.quick-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  padding: 0.5rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--panel-bg);
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

.quick-btn:hover {
  border-color: var(--primary-color);
  background-color: #f7f9ff;
}

.quick-btn i {
  width: 16px;
  height: 16px;
  color: var(--primary-color);
  flex-shrink: 0;
}

.quick-btn-text {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
}

/* Footer / Input Bar */
.chat-input-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.voice-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mic-btn {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
}

.mic-btn:hover {
  background-color: #357abd;
  transform: scale(1.05);
}

.mic-btn.connected {
  background-color: #e74c3c;
  color: #ffffff;
  animation: pulse-red 1.5s infinite alternate;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0px rgba(231, 76, 60, 0.4); }
  100% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
}

.attach-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.attach-btn:hover {
  color: var(--primary-color);
  transform: scale(1.1);
}

.image-preview-container {
  position: relative;
  display: inline-block;
  margin: 8px 16px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: #ffffff;
  max-width: 100px;
}

.image-preview-container img {
  max-width: 80px;
  max-height: 80px;
  border-radius: 4px;
  display: block;
}

.cancel-image-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: #e74c3c;
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background-color: #f1f3f5;
  border-radius: var(--border-radius);
  align-self: flex-start;
  max-width: 80%;
  margin-bottom: 1rem;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #adb5bd;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}


.mic-status-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.voice-status-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.speaking-indicator-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-color);
  font-size: 0.8rem;
  font-weight: 500;
}

.speaking-indicator-inline .speaking-indicator {
  display: flex;
  gap: 3px;
}

.speaking-indicator-inline .speaking-dot {
  width: 6px;
  height: 6px;
  background-color: var(--primary-color);
  border-radius: 50%;
  animation: speaking-dot-anim 1.2s infinite alternate;
}

.speaking-indicator-inline .speaking-dot:nth-child(2) { animation-delay: 0.2s; }
.speaking-indicator-inline .speaking-dot:nth-child(3) { animation-delay: 0.4s; }


.text-input-row {
  display: flex;
  gap: 0.5rem;
}

.text-input-row input {
  flex: 1;
  background-color: #f5f5f5;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  color: var(--text-main);
  transition: var(--transition-smooth);
}

.text-input-row input:focus {
  background-color: #f0f3ff;
}

.send-btn {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.send-btn:hover {
  background-color: var(--primary-hover);
}

/* Voice Waveform Visualizer */
.waveform {
  display: none;
  align-items: center;
  gap: 4px;
  height: 32px;
  justify-content: center;
  padding: 4px 0;
}

.waveform.active {
  display: flex;
}

.wave-bar {
  width: 3px;
  height: 8px;
  background-color: var(--primary-color);
  border-radius: 2px;
  animation: wave 1.2s ease-in-out infinite alternate;
}

.wave-bar:nth-child(2) { animation-delay: 0.15s; }
.wave-bar:nth-child(3) { animation-delay: 0.3s; }
.wave-bar:nth-child(4) { animation-delay: 0.45s; }
.wave-bar:nth-child(5) { animation-delay: 0.6s; }
.wave-bar:nth-child(6) { animation-delay: 0.45s; }
.wave-bar:nth-child(7) { animation-delay: 0.3s; }
.wave-bar:nth-child(8) { animation-delay: 0.15s; }

@keyframes wave {
  0% { height: 8px; }
  100% { height: 28px; }
}

/* Speech Overlay */
.speaking-overlay {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #111111;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.speaking-indicator {
  display: flex;
  gap: 3px;
}

.speaking-dot {
  width: 6px;
  height: 6px;
  background-color: #ffffff;
  border-radius: 50%;
  animation: speaking-dot-anim 1.2s infinite alternate;
}

.speaking-dot:nth-child(2) { animation-delay: 0.2s; }
.speaking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes speaking-dot-anim {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

#speaking-toast-text {
  font-size: 0.8rem;
  font-weight: 500;
}

/* Admin Dashboard layout styling */
.admin-container {
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  background-color: var(--bg-color);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.admin-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.tickets-sidebar {
  width: 35%;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 1rem;
}

.ticket-detail-view {
  width: 65%;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.ticket-card {
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.ticket-card:hover, .ticket-card.active {
  border-color: var(--primary-color);
  background-color: #f7f9ff;
}

.ticket-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.ticket-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sentiment-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.sentiment-angry { background-color: #ffeef0; color: #d9383a; }
.sentiment-neutral { background-color: #f5f5f5; color: #666666; }
.sentiment-calm { background-color: #eefaf0; color: #1c8c36; }

.login-modal {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.login-box {
  width: 100%;
  max-width: 380px;
  padding: 2rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  text-align: center;
}

.login-box h2 {
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  font-size: 0.9rem;
}

.login-box button {
  width: 100%;
  padding: 12px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.login-box button:hover {
  background-color: var(--primary-hover);
}

.detail-section {
  background-color: #fafafa;
  padding: 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.detail-section h4 {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.log-item {
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  line-height: 1.4;
}

.log-item .sender {
  font-weight: 700;
}


/* --- Redesigned Footer & Voice call center mode --- */
.chat-input-footer {
  transition: all 0.3s ease;
}

.chat-input-footer.voice-active {
  padding: 2.5rem 1.5rem;
  background-color: #f7f9ff;
  border-top: 1px solid #dbe3f9;
}

.chat-input-footer.voice-active #text-input-row {
  display: none !important;
}

.chat-input-footer.voice-active .voice-controls {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  transition: all 0.3s ease;
}

.chat-input-footer.voice-active .mic-btn {
  width: 80px;
  height: 80px;
  box-shadow: 0 10px 25px rgba(65, 105, 225, 0.4);
}

.chat-input-footer.voice-active .mic-btn i {
  width: 32px;
  height: 32px;
}

.chat-input-footer.voice-active .voice-status-container {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.chat-input-footer.voice-active .mic-status-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary-color);
}

.photo-upload-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 4px;
}

.attach-btn {
  background-color: #f5f5f5;
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 20px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.attach-btn:hover {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
}

.attach-btn-label {
  font-size: 0.8rem;
  font-weight: 600;
}

/* --- Chat Completed Fullscreen Overlay --- */
.chat-completed-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.98);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
  z-index: 100;
  animation: fadeIn 0.4s ease-out forwards;
}

.completed-card {
  max-width: 400px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.completed-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.completed-icon.success {
  background-color: #e8f8f5;
  color: #2ecc71;
}

.completed-icon.warning {
  background-color: #fef9e7;
  color: #f1c40f;
}

.completed-card h3 {
  font-size: 1.4rem;
  color: var(--text-main);
}

.completed-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.restart-btn {
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  margin-top: 1rem;
}

.restart-btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
}

/* --- Floating Explanatory guides --- */
.guide-card-floating {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: #ffffff;
  border: 1px solid var(--primary-color);
  border-radius: 12px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(65, 105, 225, 0.15);
  z-index: 90;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.guide-card-floating.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.guide-card-icon {
  background-color: #eff3fe;
  color: var(--primary-color);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-guide 2s infinite;
}

@keyframes pulse-guide {
  0% { box-shadow: 0 0 0 0px rgba(65, 105, 225, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(65, 105, 225, 0); }
  100% { box-shadow: 0 0 0 0px rgba(65, 105, 225, 0); }
}

.guide-card-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* --- Markdown Styling in Chat --- */
.message-content strong {
  font-weight: 700;
  color: inherit;
}

.message-content em {
  font-style: italic;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  font-weight: 700;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  color: inherit;
}

.message-content h1 { font-size: 1.2rem; }
.message-content h2 { font-size: 1.1rem; }
.message-content h3 { font-size: 1rem; }

.message-content ul {
  margin-left: 1.25rem;
  margin-bottom: 0.5rem;
  list-style-type: disc;
}

.message-content li {
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.message-content code {
  background-color: rgba(65, 105, 225, 0.12);
  color: var(--primary-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: Consolas, Monaco, "Andale Mono", monospace;
  font-size: 0.85em;
  font-weight: 600;
}

/* For assistant messages, override code background for better contrast */
.message.assistant .message-content code {
  background-color: rgba(0, 0, 0, 0.06);
  color: #111111;
}


/* --- Mobile Responsiveness for Admin Panel --- */
@media (max-width: 768px) {
  .admin-container {
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  .admin-header {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .admin-header div[style*="display: flex"] {
    width: 100%;
    justify-content: space-between;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 1rem;
  }

  .filter-bar div[style*="display: flex"] {
    flex-direction: column;
    max-width: 100% !important;
  }

  .admin-main {
    flex-direction: column;
    overflow-y: auto;
  }

  .tickets-sidebar {
    width: 100% !important;
    max-height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .ticket-detail-view {
    width: 100% !important;
    padding: 1rem !important;
  }

  .ticket-detail-view .detail-section div[style*="display: flex"] {
    flex-direction: column !important;
    gap: 15px;
  }

  .status-control-box {
    width: 100% !important;
  }

  .analytics-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
}

/* --- Mobile Device Optimizations for App Panel (<= 600px) --- */
@media (max-width: 600px) {
  .app-container {
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .chat-panel {
    height: 100dvh;
  }

  /* Compact header on mobile */
  .chat-header {
    padding: 0.75rem 1rem;
  }

  .chat-header h1 {
    font-size: 1rem;
  }

  /* Adaptive settings panel on mobile */
  .settings-panel {
    padding: 0.85rem 1rem;
    max-height: 250px;
    overflow-y: auto;
  }

  .settings-body {
    gap: 0.75rem;
  }

  .setting-switches {
    gap: 1rem;
    flex-direction: column;
  }

  /* Compact messages space on mobile */
  .chat-messages {
    padding: 1rem 0.85rem;
    gap: 0.75rem;
  }

  .message {
    max-width: 90%;
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
  }

  /* Quick options button styling for small mobile screens */
  .quick-options {
    padding: 0.25rem 0.75rem;
    gap: 0.4rem;
  }

  .quick-btn {
    padding: 6px 10px;
  }

  .quick-btn-text {
    font-size: 0.75rem;
  }

  /* Dynamic viewport/safe area spacing for footer and buttons */
  .chat-input-footer {
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    gap: 0.5rem;
    background-color: #ffffff;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.02);
  }

  .chat-input-footer.voice-active {
    padding: 1.5rem 1rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }

  .voice-controls {
    gap: 0.5rem;
  }

  .chat-input-footer.voice-active .voice-controls {
    gap: 0.85rem;
  }

  .mic-btn {
    width: 44px;
    height: 44px;
  }

  .chat-input-footer.voice-active .mic-btn {
    width: 72px;
    height: 72px;
  }

  .mic-status-text {
    font-size: 0.8rem;
  }

  /* Ensure text row, buttons, and send button fit perfectly */
  .text-input-row {
    gap: 0.5rem;
  }

  #text-chat-input {
    padding: 8px 12px;
    font-size: 0.88rem;
  }

  .send-btn {
    width: 36px;
    height: 36px;
  }

  /* Photo upload row styling on mobile so it is always accessible */
  .photo-upload-row {
    margin-top: 2px;
  }

  .attach-btn {
    padding: 6px 12px;
    border-radius: 16px;
    width: 100%;
    justify-content: center;
  }

  .attach-btn-label {
    font-size: 0.75rem;
  }
}
