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

/* Mobile menu toggle button (hidden on desktop) */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1100;
  background: var(--primary-color);
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
  transition: background 0.3s ease;
}

.mobile-menu-toggle:active {
  background: var(--primary-hover);
}

.hamburger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Hamburger animation when sidebar is open */
.sidebar-open .mobile-menu-toggle .hamburger-line:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.sidebar-open .mobile-menu-toggle .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.sidebar-open .mobile-menu-toggle .hamburger-line:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Overlay backdrop (hidden on desktop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ========================================
   TABLET BREAKPOINT (≤1024px)
   ======================================== */
@media (max-width: 1024px) {
  /* Reduce sidebar width slightly on tablets */
  :root {
    --sidebar-width: 320px;
    --sidebar-min: 280px;
    --sidebar-max: 400px;
  }
}

/* ========================================
   MOBILE BREAKPOINT (≤768px)
   ======================================== */
@media (max-width: 768px) {
  /* Prevent horizontal scrolling on mobile */
  body {
    overflow-x: hidden;
    width: 100%;
  }

  #app {
    overflow-x: hidden;
    width: 100%;
  }

  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
  }

  /* Sidebar becomes full-width overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    z-index: 1000;
    transform: translateX(0);
    transition: left 0.3s ease;
    box-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-open .sidebar {
    left: 0;
  }

  /* Disable resize handle on mobile */
  .resize-handle {
    display: none;
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Adjust header buttons for mobile */
  .sidebar-header {
    padding: var(--spacing-lg);
  }

  .sidebar-header h1 {
    font-size: var(--font-xl);
    margin-bottom: var(--spacing-md);
  }

  .header-buttons {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }

  .header-buttons button {
    font-size: var(--font-xs);
    padding: 6px 10px;
  }

  /* Make assistant filter buttons stack on very small screens */
  .assistant-filter {
    flex-direction: row;
    gap: var(--spacing-xs);
  }

  .assistant-filter-btn {
    flex: 1;
    font-size: var(--font-sm);
    padding: 8px 6px;
  }

  /* Improve chat item spacing */
  .chat-item {
    padding: var(--spacing-md);
  }

  .chat-title {
    font-size: var(--font-md);
  }

  .chat-date {
    font-size: var(--font-xs);
  }

  /* Message content adjustments */
  .message-content {
    font-size: var(--font-md);
    padding: var(--spacing-md);
  }

  /* Modal adjustments for mobile */
  .modal-content {
    width: 95vw;
    max-width: 500px;
    margin: 20px;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Toast notifications */
  .toast {
    max-width: calc(100vw - 32px);
    margin: 0 16px;
  }

  /* Welcome message */
  .welcome-message {
    padding: var(--spacing-2xl);
  }

  .welcome-message h2 {
    font-size: var(--font-xl);
  }

  .welcome-message p {
    font-size: var(--font-md);
  }

  /* Disable chat-list internal scrolling - sidebar handles it */
  .chat-list {
    flex: 0 0 auto;
    overflow-y: visible;
  }

  /* Make chat-view scrollable so header scrolls with messages */
  .chat-view {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
  }

  /* Chat messages no longer scrolls - parent handles it */
  .chat-messages {
    flex: 0 0 auto;
    overflow-y: visible;
    height: auto;
  }

  /* Landscape-specific adjustments for shorter screens */
  @media (max-height: 500px) {
    .sidebar-header h1 {
      font-size: var(--font-md);
    }

    .header-buttons button {
      font-size: 10px;
      padding: 4px 8px;
    }

    .assistant-filter-btn {
      font-size: 11px;
      padding: 6px 8px;
    }

    .tag {
      font-size: 10px;
      padding: 2px 6px;
    }

    .chat-title {
      font-size: var(--font-sm);
    }

    .chat-date {
      font-size: 10px;
    }

    .search-input, .date-input {
      font-size: var(--font-sm);
      padding: 6px 8px;
    }

    .sidebar-header {
      padding: var(--spacing-sm);
    }

    .search-container {
      padding: var(--spacing-sm);
    }

    .tag-filter-section {
      padding: var(--spacing-sm);
    }
  }
}

/* ========================================
   SMALL MOBILE BREAKPOINT (≤480px)
   ======================================== */
@media (max-width: 480px) {
  /* Sidebar stays full-width */
  .sidebar {
    width: 100vw;
    max-width: 100vw;
  }

  /* Reduce font sizes */
  .sidebar-header h1 {
    font-size: var(--font-lg);
  }

  /* Stack assistant filters vertically */
  .assistant-filter {
    flex-direction: column;
  }

  .assistant-filter-btn {
    width: 100%;
  }

  /* Date inputs stack */
  .date-search {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .date-input {
    width: 100%;
  }

  /* Smaller message content */
  .message-content {
    font-size: var(--font-sm);
  }

  /* Compact conversation header */
  .conversation-header {
    padding: var(--spacing-md);
  }

  .conversation-title {
    font-size: var(--font-lg);
  }
}
