/* AI Business Partner - Complete Styles */

/* CSS Variables for consistent layout calculations */
:root {
  /* Navbar dimensions */
  --navbar-padding-vertical: 12px;
  --navbar-height: 48px; /* Approximate: will be calculated by browser */

  /* Footer dimensions */
  --footer-padding-vertical: 20px;
  --footer-height: 64px; /* Approximate: will be calculated by browser */

  /* Total UI chrome height (navbar + footer) */
  --ui-chrome-height: calc(var(--navbar-height) + var(--footer-height));
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #08a54f 0%, #5856d6 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: #333;
}

/* ============================================================================
   SCREEN MANAGEMENT
   ============================================================================ */

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.hidden {
  display: none !important;
}

/* ============================================================================
   AUTHENTICATION SCREEN
   ============================================================================ */

#auth-screen {
  gap: 0;
}

.auth-container {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(15px);
  border-radius: 25px;
  padding: 50px 45px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.25),
    0 0 100px rgba(8, 165, 79, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  max-width: 450px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  animation: containerFadeIn 0.6s ease-out;
}

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

/* Cyrus Logo Title - Bold and Dominant */
.logo-title {
  font-size: 4rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #06325e 0%, #08a54f 50%, #5856d6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.15);
  animation: titleGlow 3s ease-in-out infinite;
  position: relative;
}

@keyframes titleGlow {
  0%, 100% {
    filter: drop-shadow(0 0 8px rgba(8, 165, 79, 0.3));
  }
  50% {
    filter: drop-shadow(0 0 16px rgba(8, 165, 79, 0.5));
  }
}

/* Rotating Power Words */
.tagline {
  text-align: center;
  margin-bottom: 35px;
  font-size: 1.3rem;
  min-height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.power-word {
  font-weight: 700;
  background: linear-gradient(135deg, #08a54f, #5856d6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fadeInOut 3s ease-in-out infinite;
  display: inline-block;
  min-width: 150px;
  text-align: center;
}

@keyframes fadeInOut {
  0%, 100% {
    opacity: 0;
    transform: translateY(-10px);
  }
  10%, 90% {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Sleek Login Heading */
.login-heading {
  color: #06325e;
  font-size: 1.8rem;
  font-weight: 300;
  margin-bottom: 20px;
  text-align: center;
  letter-spacing: 4px;
  text-transform: uppercase;
  position: relative;
  padding-bottom: 15px;
}

.login-heading::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #08a54f, transparent);
}

.auth-form h2 {
  color: #06325e;
  font-size: 1.5rem;
  margin-bottom: 8px;
  text-align: center;
}

.auth-form input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 16px;
  transition: all 0.2s;
  background: white;
}

.auth-form input:focus {
  outline: none;
  border-color: #08a54f;
  box-shadow: 0 0 0 3px rgba(8, 165, 79, 0.1);
}

.form-switch {
  text-align: center;
  color: #666;
  font-size: 0.9rem;
  margin-top: 8px;
}

.form-switch a {
  color: #08a54f;
  text-decoration: none;
  font-weight: 600;
}

.form-switch a:hover {
  text-decoration: underline;
}

/* ============================================================================
   CHAT SCREEN
   ============================================================================ */

#chat-screen {
  padding: 0;
  gap: 0;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  min-height: unset;
  justify-content: flex-start;
  overflow: hidden;
}

.navbar {
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: #06325e;
  flex-shrink: 0;
}

/* Chat Container with Sidebar */
.chat-container {
  display: flex;
  width: 100%;
  height: calc(100vh - var(--ui-chrome-height)); /* Account for navbar and footer */
  overflow: hidden;
}

/* Sidebar Toggle Button (initially hidden on desktop) */
#sidebar-toggle-btn {
  display: none;
}

/* Desktop/Mobile visibility helpers */
.mobile-only {
  display: none;
}

.desktop-only {
  display: flex;
}

/* ============================================================================
   CONVERSATION SIDEBAR
   ============================================================================ */

.conversation-sidebar {
  width: 300px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 2px solid #f0f0f0;
  background: linear-gradient(135deg, #08a54f 0%, #5856d6 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h3 {
  margin: 0;
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
}

.refresh-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.refresh-btn:active:not(:disabled) {
  transform: scale(0.95);
}

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

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.conversation-list-empty {
  padding: 40px 20px;
  text-align: center;
  color: #999;
}

.conversation-list-empty p {
  margin: 8px 0;
  line-height: 1.5;
}

.conversation-list-empty .small-text {
  font-size: 0.85rem;
  color: #bbb;
}

/* Individual Conversation Item */
.conversation-item {
  padding: 16px;
  margin-bottom: 8px;
  background: white;
  border-radius: 12px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.conversation-item:hover {
  background: #f8f9fa;
  border-color: #08a54f;
  transform: translateX(4px);
  box-shadow: 0 2px 6px rgba(8, 165, 79, 0.2);
}

.conversation-item.active {
  background: linear-gradient(135deg, rgba(8, 165, 79, 0.1), rgba(88, 86, 214, 0.1));
  border-color: #08a54f;
  box-shadow: 0 2px 8px rgba(8, 165, 79, 0.3);
}

.conversation-item-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.conversation-item-title {
  font-weight: 600;
  color: #06325e;
  margin-bottom: 6px;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item-preview {
  font-size: 0.85rem;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 6px;
}

.conversation-item-date {
  font-size: 0.75rem;
  color: #999;
}

.conversation-delete-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.conversation-item:hover .conversation-delete-btn {
  opacity: 1;
}

.conversation-delete-btn:hover {
  background: #fee;
  color: #dc3545;
  transform: scale(1.1);
}

.conversation-delete-btn:active {
  transform: scale(0.95);
}

.nav-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

/* Unified Icon Button Style */
.nav-icon-btn {
  background: transparent;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  position: relative;
}

.nav-icon-btn:hover {
  background: rgba(8, 165, 79, 0.1);
  color: #08a54f;
  transform: translateY(-1px);
}

.nav-icon-btn:active {
  transform: translateY(0);
  background: rgba(8, 165, 79, 0.15);
}

.nav-icon-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.chat-window {
  flex: 1;
  width: 100%;
  max-width: 100%;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chat-footer {
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px 30px;
  display: flex;
  gap: 12px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

#user-input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 25px;
  font-size: 16px;
  transition: all 0.2s;
}

#user-input:focus {
  outline: none;
  border-color: #08a54f;
  box-shadow: 0 0 0 3px rgba(8, 165, 79, 0.1);
}

/* ============================================================================
   MESSAGES
   ============================================================================ */

   .user-message,
   .bot-message {
     padding: 12px 18px;
     border-radius: 18px;
     max-width: 75%;
     word-wrap: break-word;
     line-height: 1.5;
     animation: fadeIn 0.3s ease;
   }
   
   .user-message {
     background: linear-gradient(135deg, #08a54f, #06924a);
     color: white;
     align-self: flex-end;
     margin-left: auto;
     box-shadow: 0 2px 8px rgba(8, 165, 79, 0.4);
     border: 1px solid rgba(255, 255, 255, 0.2);
   }
   
   .bot-message {
     background: rgba(255, 255, 255, 0.98);
     color: #333;
     align-self: flex-start;
     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
     border: 1px solid rgba(255, 255, 255, 0.3);
   }

/* Markdown formatting inside bot messages */
.bot-message h1, .bot-message h2, .bot-message h3 {
  margin-top: 16px;
  margin-bottom: 8px;
  color: #06325e;
  font-weight: 700;
}

.bot-message h1 { font-size: 1.5rem; }
.bot-message h2 { font-size: 1.3rem; }
.bot-message h3 { font-size: 1.1rem; }

.bot-message p {
  margin-bottom: 12px;
  line-height: 1.6;
}

.bot-message ul, .bot-message ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.bot-message li {
  margin-bottom: 6px;
  line-height: 1.5;
}

.bot-message strong {
  font-weight: 700;
  color: #06325e;
}

.bot-message em {
  font-style: italic;
  color: #555;
}

.bot-message code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.bot-message pre {
  background: #f4f4f4;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.bot-message pre code {
  background: none;
  padding: 0;
}

.bot-message a {
  color: #08a54f;
  text-decoration: none;
  font-weight: 600;
}

.bot-message a:hover {
  text-decoration: underline;
}

.bot-message blockquote {
  border-left: 4px solid #08a54f;
  padding-left: 16px;
  margin: 12px 0;
  color: #666;
  font-style: italic;
}

/* Alert messages */
.error-message,
.warning-message,
.success-message {
  padding: 12px 18px;
  border-radius: 18px;
  align-self: center;
  animation: shake 0.4s ease;
  max-width: 80%;
  text-align: center;
}

.error-message {
  background: #ff4444;
  color: white;
}

.warning-message {
  background: #ffa500;
  color: white;
}

.success-message {
  background: #08a54f;
  color: white;
}

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

.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 18px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.pill-btn {
  background: #08a54f;
  color: white;
  border: none;
  border-radius: 25px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.pill-btn:hover {
  background: #07924a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(8, 165, 79, 0.3);
}

.pill-btn:active {
  transform: translateY(0);
}

.pill-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.pill-btn.small {
  padding: 8px 20px;
  font-size: 14px;
}

/* Logout button in navbar - smaller, minimal */
.navbar .pill-btn.small {
  padding: 10px 18px;
  font-size: 13px;
  min-height: 44px;
  border-radius: 22px;
  margin-left: 4px;
}

.pill-btn.secondary {
  background: white;
  color: #06325e;
  border: 2px solid #06325e;
}

.pill-btn.secondary:hover {
  background: #06325e;
  color: white;
}

/* Usage Toggle Button - Status Indicator */
.usage-toggle::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #08a54f;
  border-radius: 50%;
  border: 2px solid white;
  opacity: 0;
  transition: opacity 0.3s;
}

.usage-toggle.warning {
  color: #f59e0b;
}

.usage-toggle.warning::after {
  background: #f59e0b;
  opacity: 1;
  animation: pulse 2s infinite;
}

.usage-toggle.danger {
  color: #ef4444;
}

.usage-toggle.danger::after {
  background: #ef4444;
  opacity: 1;
  animation: pulse 1s infinite;
}

/* Usage Panel (Dropdown) */
.usage-panel {
  position: absolute;
  top: var(--navbar-height);
  right: 80px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  padding: 20px;
  min-width: 280px;
  z-index: 1000;
  animation: slideDown 0.3s ease;
}

.usage-panel::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid white;
}

.usage-content h3 {
  color: #06325e;
  font-size: 1.1rem;
  margin-bottom: 16px;
  font-weight: 700;
}

.usage-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.usage-label {
  color: #666;
  font-size: 0.9rem;
}

.usage-value {
  color: #06325e;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.usage-bar {
  width: 100%;
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  margin-top: 16px;
  overflow: hidden;
}

.usage-progress {
  height: 100%;
  background: linear-gradient(90deg, #08a54f, #06924a);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.usage-progress.warning {
  background: linear-gradient(90deg, #ffa500, #ff8c00);
}

.usage-progress.danger {
  background: linear-gradient(90deg, #ff4444, #cc0000);
}

/* ============================================================================
   MORE OPTIONS PANEL (Mobile)
   ============================================================================ */

.more-options-panel {
  position: fixed;
  top: var(--navbar-height);
  right: 0;
  width: 280px;
  max-height: calc(100vh - var(--navbar-height));
  background: white;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

.more-options-panel:not(.hidden) {
  transform: translateX(0);
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: white;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 15px;
  color: #333;
  text-align: left;
}

.menu-item svg {
  flex-shrink: 0;
  color: #555;
  transition: color 0.2s ease;
}

.menu-item span {
  flex: 1;
  font-weight: 500;
}

.menu-item:hover {
  background: #f8f9fa;
}

.menu-item:active {
  background: #e9ecef;
}

.menu-item:hover svg {
  color: #08a54f;
}

.menu-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 8px 0;
}

.logout-item {
  color: #dc3545;
  font-weight: 600;
}

.logout-item svg {
  color: #dc3545;
}

.logout-item:hover {
  background: #fff5f5;
}

.logout-item:hover svg {
  color: #c82333;
}

/* Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 165, 0, 0);
  }
}

/* ============================================================================
   MODAL
   ============================================================================ */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: white;
  border-radius: 20px;
  padding: 40px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

.modal-content h2 {
  color: #06325e;
  margin-bottom: 16px;
  font-size: 1.8rem;
}

.modal-content p {
  color: #666;
  margin-bottom: 24px;
  font-size: 1.1rem;
  line-height: 1.6;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

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

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

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

.chat-window::-webkit-scrollbar {
  width: 8px;
}

.chat-window::-webkit-scrollbar-track {
  background: transparent;
}

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

.chat-window::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

   @media (max-width: 768px) {
    /* Update CSS variables for mobile dimensions */
    :root {
      --navbar-padding-vertical: 10px;
      --navbar-height: 44px;
      --footer-padding-vertical: 15px;
      --footer-height: 58px;
      --ui-chrome-height: calc(var(--navbar-height) + var(--footer-height));
    }

    /* Show mobile menu, hide desktop buttons */
    .mobile-only {
      display: flex !important;
    }

    .desktop-only {
      display: none !important;
    }

    .auth-container {
      padding: 40px 25px;
      max-width: 90%;
    }

    .logo-title {
      font-size: 3rem;
      letter-spacing: 1px;
    }

    .tagline {
      font-size: 1.1rem;
      margin-bottom: 25px;
    }

    .power-word {
      min-width: 120px;
    }

    .login-heading {
      font-size: 1.4rem;
      letter-spacing: 3px;
    }

    /* Mobile Sidebar Toggle */
    #sidebar-toggle-btn {
      display: flex;
    }

    .conversation-sidebar {
      position: fixed;
      left: 0;
      top: var(--navbar-height); /* Below navbar */
      height: calc(100vh - var(--navbar-height));
      width: 80%;
      max-width: 300px;
      z-index: 200;
      transform: translateX(-100%);
      box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .conversation-sidebar.open {
      transform: translateX(0);
    }

    .chat-container {
      height: calc(100vh - var(--ui-chrome-height));
    }

    .chat-window {
      padding: 15px;
    }

    .user-message,
    .bot-message {
      max-width: 85%;
    }

    .navbar,
    .chat-footer {
      padding: 15px 20px;
    }

    .nav-right {
      gap: 8px;
    }

    .pill-btn.small {
      padding: 6px 14px;
      font-size: 12px;
    }

    .modal-content {
      padding: 30px 20px;
    }

    .modal-buttons {
      flex-direction: column;
    }

    .modal-buttons .pill-btn {
      width: 100%;
    }

    /* FIX ISSUE #1: Usage panel positioning on mobile */
    .usage-panel {
      right: 20px;
      left: 20px;
      width: auto;
      min-width: unset;
    }

    .usage-panel::before {
      right: 30px;
    }

    /* FIX ISSUE #2: Touch targets - Apple HIG 44x44px minimum */
    .nav-icon-btn {
      min-width: 48px;
      min-height: 48px;
      padding: 12px;
    }

    .logo {
      font-size: 1.1rem;
    }

    .navbar {
      padding: 10px 16px;
    }

    .navbar .pill-btn.small {
      padding: 10px 16px;
      font-size: 12px;
    }
  }

@media (max-width: 480px) {
  .logo {
    font-size: 1.1rem;
  }

  .usage-btn {
    font-size: 11px;
    padding: 6px 12px;
  }

  .modal-content {
    padding: 24px 16px;
    max-height: 85vh;
    max-height: 85dvh;
  }

  .settings-modal-content {
    padding: 16px 12px;
    max-height: 75vh;
    max-height: 75dvh;
  }

  .modal-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
  }

  .settings-section {
    margin-bottom: 16px;
  }
}

/* Removed - Now using unified .nav-icon-btn class */

/* Message Rating */
.message-content {
  margin-bottom: 8px;
}

.message-rating {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.message-rating:hover {
  opacity: 1;
}

.rating-label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

.stars-container {
  display: flex;
  gap: 4px;
}

.rating-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  font-size: 24px;
  transition: all 0.2s;
  color: rgba(255, 255, 255, 0.3);
  line-height: 1;
}

.star-btn {
  color: rgba(255, 255, 255, 0.4);
}

.star-btn:hover {
  color: #ffd700;
  transform: scale(1.2);
}

.star-btn:active {
  transform: scale(0.9);
}

.rating-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rating-thanks {
  color: #2ecc71;
  font-size: 14px;
  font-style: italic;
}

/* ============================================================================
   SETTINGS MODAL
   ============================================================================ */

/* Removed - Now using unified .nav-icon-btn class */

/* Settings Modal Content */
.settings-modal-content {
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
}

/* Modal Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
}

.modal-header h2 {
  margin: 0;
  color: #06325e;
  font-size: 1.8rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 32px;
  color: #999;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
}

.close-btn:hover {
  background: #f0f0f0;
  color: #333;
}

.close-btn:active {
  transform: scale(0.9);
}

/* Settings Sections */
.settings-section {
  margin-bottom: 30px;
}

.settings-section h3 {
  color: #06325e;
  font-size: 1.3rem;
  margin-bottom: 8px;
  font-weight: 700;
}

.settings-description {
  color: #666;
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Settings Divider */
.settings-divider {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 30px 0;
}

/* Token Limit Controls */
.token-limit-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

#token-limit-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

#token-limit-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #08a54f;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#token-limit-slider::-webkit-slider-thumb:hover {
  background: #07924a;
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(8, 165, 79, 0.4);
}

#token-limit-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #08a54f;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#token-limit-slider::-moz-range-thumb:hover {
  background: #07924a;
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(8, 165, 79, 0.4);
}

.token-limit-display {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  background: #f8f8f8;
  padding: 12px 20px;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
}

.token-limit-display span {
  font-size: 1.4rem;
  color: #06325e;
  font-weight: 700;
}

#token-limit-input {
  width: 80px;
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1.3rem;
  font-weight: 700;
  color: #06325e;
  text-align: center;
  transition: all 0.2s;
  background: white;
}

#token-limit-input:focus {
  outline: none;
  border-color: #08a54f;
  box-shadow: 0 0 0 3px rgba(8, 165, 79, 0.1);
}

/* Remove spinner arrows from number input */
#token-limit-input::-webkit-inner-spin-button,
#token-limit-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#token-limit-input[type=number] {
  -moz-appearance: textfield;
}

/* Danger Section */
.danger-section {
  background: #fff5f5;
  padding: 20px;
  border-radius: 12px;
  border: 2px solid #ffcccc;
}

.danger-section h3 {
  color: #cc0000;
}

.danger-section .settings-description {
  color: #cc0000;
}

/* Danger Button */
.pill-btn.danger {
  background: #ff4444;
  color: white;
}

.pill-btn.danger:hover {
  background: #cc0000;
  box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
}

/* Responsive Settings Modal */
@media (max-width: 768px) {
  .settings-modal-content {
    padding: 20px 16px;
    max-height: 80vh;
    max-height: 80dvh; /* Dynamic viewport height for mobile browsers */
    overflow-y: auto;
  }

  .modal-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
  }

  .modal-header h2 {
    font-size: 1.5rem;
  }

  .settings-section {
    margin-bottom: 20px;
  }

  .settings-section h3 {
    font-size: 1.2rem;
  }

  .token-limit-display {
    padding: 10px 16px;
  }

  #token-limit-input {
    width: 70px;
    font-size: 1.2rem;
  }
}

/* ============================================ */
/* ENHANCED MARKDOWN RENDERING STYLES           */
/* ============================================ */

/* Code Blocks with Syntax Highlighting */
.message-content pre {
  background: #1e1e1e;
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid #333;
}

.message-content pre code {
  background: transparent;
  padding: 0;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.9em;
  line-height: 1.5;
  color: #d4d4d4;
}

/* Inline Code */
.message-content code {
  background: #f4f4f4;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.9em;
  color: #e83e8c;
  border: 1px solid #e0e0e0;
}

/* Tables */
.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-content th {
  background: #3498db;
  color: white;
  padding: 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #2980b9;
}

.message-content td {
  padding: 10px 12px;
  border-bottom: 1px solid #e0e0e0;
}

.message-content tr:last-child td {
  border-bottom: none;
}

.message-content tr:hover {
  background: #f8f9fa;
}

/* Lists */
.message-content ul,
.message-content ol {
  margin: 12px 0;
  padding-left: 24px;
}

.message-content li {
  margin: 6px 0;
  line-height: 1.6;
}

.message-content ul li {
  list-style-type: disc;
}

.message-content ol li {
  list-style-type: decimal;
}

/* Nested Lists */
.message-content ul ul,
.message-content ol ul {
  margin: 4px 0;
}

.message-content ul ul li {
  list-style-type: circle;
}

/* Blockquotes */
.message-content blockquote {
  border-left: 4px solid #3498db;
  margin: 16px 0;
  padding: 12px 20px;
  background: #f8f9fa;
  border-radius: 0 8px 8px 0;
  color: #555;
  font-style: italic;
}

/* Links */
.message-content a {
  color: #3498db;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.message-content a:hover {
  border-bottom-color: #3498db;
}

/* Horizontal Rules */
.message-content hr {
  border: none;
  border-top: 2px solid #e0e0e0;
  margin: 20px 0;
}

/* Headers in Messages */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 16px 0 10px 0;
  font-weight: 600;
  color: #2c3e50;
}

.message-content h1 { font-size: 1.8em; }
.message-content h2 { font-size: 1.5em; }
.message-content h3 { font-size: 1.3em; }
.message-content h4 { font-size: 1.1em; }

/* Paragraphs */
.message-content p {
  margin: 10px 0;
  line-height: 1.6;
}

/* Strong and Emphasis */
.message-content strong {
  font-weight: 600;
  color: #2c3e50;
}

.message-content em {
  font-style: italic;
  color: #555;
}

/* ============================================ */
/* METRICS MODAL STYLES (Part C)                */
/* ============================================ */

/* Removed - Now using unified .nav-icon-btn class */

.metrics-modal-content {
  max-width: 800px;
  padding: 40px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.metric-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 24px;
  border-radius: 12px;
  text-align: center;
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  transition: transform 0.2s;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.metric-card.success {
  background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
  box-shadow: 0 4px 12px rgba(86, 171, 47, 0.3);
}

.metric-card.success:hover {
  box-shadow: 0 8px 20px rgba(86, 171, 47, 0.4);
}

.metric-card.warning {
  background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
  box-shadow: 0 4px 12px rgba(242, 153, 74, 0.3);
}

.metric-card.warning:hover {
  box-shadow: 0 8px 20px rgba(242, 153, 74, 0.4);
}

.metric-label {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 8px;
  font-weight: 500;
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 8px 0;
}

.metric-subtext {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-top: 4px;
}

.recent-ratings-section {
  margin: 30px 0;
}

.recent-ratings-section h3 {
  color: #2c3e50;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

.recent-ratings-list {
  max-height: 300px;
  overflow-y: auto;
  background: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
}

.rating-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: white;
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 4px solid #3498db;
  transition: transform 0.2s;
}

.rating-item:hover {
  transform: translateX(4px);
}

.rating-item.helpful {
  border-left-color: #2ecc71;
}

.rating-item.not-helpful {
  border-left-color: #e74c3c;
}

.rating-emoji {
  font-size: 1.5rem;
}

.rating-score {
  font-weight: 600;
  color: #2c3e50;
  flex: 1;
}

.rating-date {
  color: #7f8c8d;
  font-size: 0.85rem;
}

.no-data {
  text-align: center;
  color: #7f8c8d;
  padding: 40px 20px;
  font-style: italic;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid #e0e0e0;
}

/* Responsive Metrics */
@media (max-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }

  .metric-card {
    padding: 16px;
  }

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

  .metrics-modal-content {
    padding: 30px 20px;
  }

  /* Make delete button visible on mobile (no hover on touchscreens) */
  .conversation-delete-btn {
    opacity: 0.5;
  }

  .conversation-item:hover .conversation-delete-btn,
  .conversation-delete-btn:hover {
    opacity: 1;
  }
}