/* ==================== MOBILE SIDEBAR & SOCIAL LINKS ==================== */

/* Social Links */
.social-links {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid #404040;
}

.social-title {
  font-size: 11px;
  font-weight: 600;
  color: #737373;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.social-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 4px;
  border-radius: 6px;
  text-decoration: none;
  color: #a3a3a3;
  font-size: 13px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.social-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: currentColor;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.social-item:hover {
  transform: translateX(2px);
  color: #e5e5e5;
}

.social-item:hover::before {
  transform: translateX(0);
}

/* Platform-specific colors */
.social-item.linkedin:hover {
  background: rgba(0, 119, 181, 0.1);
  color: #0077b5;
}

.social-item.linkedin:hover::before {
  background: #0077b5;
}

.social-item.youtube:hover {
  background: rgba(255, 0, 0, 0.1);
  color: #ff0000;
}

.social-item.youtube:hover::before {
  background: #ff0000;
}

.social-item.instagram:hover {
  background: linear-gradient(
    45deg,
    rgba(131, 58, 180, 0.1),
    rgba(253, 29, 29, 0.1),
    rgba(252, 176, 64, 0.1)
  );
  color: #e4405f;
}

.social-item.instagram:hover::before {
  background: linear-gradient(45deg, #833ab4, #fd1d1d, #fcb045);
}

.social-item svg {
  flex-shrink: 0;
}

/* ==================== MOBILE NAVIGATION ==================== */

/* Mobile hamburger menu */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1002;
  background: rgba(32, 32, 32, 0.95);
  border: 2px solid #525252;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  width: 44px;
  height: 44px;
}

.mobile-menu-toggle:hover {
  background: rgba(249, 115, 22, 0.1);
  border-color: #f97316;
  transform: scale(1.05);
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

.mobile-menu-toggle svg {
  color: #e5e5e5;
  width: 24px;
  height: 24px;
  display: block;
}

.mobile-menu-toggle:hover svg {
  color: #f97316;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ==================== MOBILE BREAKPOINTS ==================== */

@media (max-width: 768px) {
  /* Show mobile menu button */
  .mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Adjust chat header for hamburger menu */
  .chat-header {
    padding-left: 80px !important;
  }

  /* MOBILE SIDEBAR - Fixed scrolling */
  .sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #202020;
    border-right: 1px solid #404040;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    
    /* Enhanced scrolling */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    
    display: flex !important;
    flex-direction: column;
    padding-bottom: 20px;
    
    /* Prevent momentum hiding */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  .sidebar.open {
    left: 0;
    -webkit-transform: translateX(0) translateZ(0);
    transform: translateX(0) translateZ(0);
  }

  /* Sidebar scrollbar */
  .sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .sidebar::-webkit-scrollbar-track {
    background: #202020;
  }

  .sidebar::-webkit-scrollbar-thumb {
    background: #525252;
    border-radius: 2px;
  }

  .sidebar::-webkit-scrollbar-thumb:hover {
    background: #737373;
  }

  /* Sidebar content visibility */
  .sidebar .profile-section {
    flex-shrink: 0;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    padding: 20px;
    margin-bottom: 20px;
  }

  .sidebar .categories {
    flex: 1;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    padding: 0 20px;
    min-height: auto;
  }

  .sidebar .social-links {
    flex-shrink: 0;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    padding: 20px;
    margin-top: auto;
  }

  .sidebar .category-item {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    cursor: pointer;
    padding: 12px 14px;
    margin-bottom: 6px;
  }

  /* MAIN CONTAINER - Fixed layout */
  .container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available; /* iOS fix */
    overflow: hidden;
    display: flex;
    flex-direction: row;
  }

  /* CHAT CONTAINER - Fixed structure */
  .chat-container {
    flex: 1;
    width: 100%;
    margin-left: 0;
    display: flex !important;
    flex-direction: column !important;
    height: 100vh;
    height: -webkit-fill-available; /* iOS fix */
    background: #2f2f2f;
    overflow: hidden;
  }

  /* CHAT MESSAGES - Proper flex */
  .chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 15px !important;
    background: #2f2f2f;
    padding-bottom: 20px;
    min-height: 0; /* Critical for flex */
    -webkit-overflow-scrolling: touch;
  }

  /* CHAT INPUT - FIXED POSITIONING (Same as red/yellow test) */
  .chat-input-container {
    /* Use the EXACT same positioning that worked with red/yellow */
    position: relative !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 100 !important;
    
    /* Styling */
    background: #2f2f2f !important;
    padding: 15px !important;
    border-top: 1px solid #404040 !important;
    
    /* Flex behavior */
    flex-shrink: 0 !important;
    
    /* Visibility */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    
    /* iOS fixes */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    min-height: 70px;
  }

  /* INPUT WRAPPER - Proper styling */
  .input-wrapper {
    position: relative !important;
    background: #404040 !important;
    border: 1px solid #525252 !important;
    border-radius: 24px !important;
    padding: 14px 55px 14px 20px !important;
    transition: all 0.2s ease;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
  }

  .input-wrapper:focus-within {
    border-color: #f97316;
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.2);
  }

  /* CHAT INPUT - Proper styling */
  .chat-input {
    width: 100% !important;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 16px !important; /* iOS - prevent zoom */
    color: #e5e5e5 !important;
    resize: none !important;
    min-height: 22px !important;
    max-height: 120px !important;
  }

  .chat-input::placeholder {
    color: #737373;
  }

  /* INPUT BUTTONS */
  .input-buttons {
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: flex;
    gap: 6px;
  }

  .input-button {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #a3a3a3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
  }

  .input-button:hover {
    background: #525252;
    color: #e5e5e5;
  }

  .send-button {
    background: #f97316;
    color: white;
  }

  .send-button:hover {
    background: #ea580c;
  }

  .send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #525252;
  }

  /* SUGGESTIONS CONTAINER */
  .suggestions-container {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    margin-bottom: 15px;
    padding: 0 15px;
    display: none;
  }

  .suggestions-container.show {
    display: block;
  }

  .suggestion-item {
    padding: 12px 16px;
    background: #404040;
    border: 1px solid #525252;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #e5e5e5;
    text-align: left;
    margin-bottom: 8px;
  }

  /* WELCOME MESSAGE */
  .welcome-message {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: auto;
    padding: 20px 15px 100px 15px; /* Extra bottom padding */
    color: #a3a3a3;
    text-align: center;
  }

  .welcome-title {
    font-size: 24px;
  }

  .welcome-subtitle {
    font-size: 14px;
  }

  .welcome-suggestions {
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 20px;
  }

  .welcome-suggestion-item {
    padding: 12px 15px;
    font-size: 13px;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /* MESSAGE CONTENT */
  .message-content {
    max-width: 90%;
    font-size: 14px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  /* SOCIAL LINKS */
  .social-links {
    padding-top: 15px;
  }

  .social-item {
    padding: 8px 12px;
    font-size: 12px;
  }

  .social-item svg {
    width: 14px;
    height: 14px;
  }
}

/* ==================== SMALLER LAPTOP FIXES ==================== */

@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 260px;
    overflow-y: auto;
    height: 100vh;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #525252 #202020;
  }

  .sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .sidebar::-webkit-scrollbar-track {
    background: #202020;
  }

  .sidebar::-webkit-scrollbar-thumb {
    background: #525252;
    border-radius: 2px;
  }

  .sidebar .profile-section {
    padding: 15px;
    margin-bottom: 15px;
  }

  .sidebar .categories {
    padding: 0 15px;
  }

  .sidebar .social-links {
    padding: 15px;
    margin-top: 10px;
  }

  .sidebar .category-item {
    padding: 8px 12px;
    font-size: 12px;
  }

  .sidebar .social-item {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* Hide mobile menu on desktop */
@media (min-width: 769px) {
  .mobile-menu-toggle {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }

  .sidebar {
    position: static !important;
    left: auto !important;
    width: 280px !important;
    height: 100vh !important;
    box-shadow: none !important;
  }

  .chat-header {
    padding-left: 30px !important;
  }
}

/* Extra small mobile adjustments */
@media (max-width: 480px) {
  .mobile-menu-toggle {
    top: 15px;
    left: 15px;
    padding: 6px;
    width: 40px;
    height: 40px;
  }

  .mobile-menu-toggle svg {
    width: 22px;
    height: 22px;
  }

  .sidebar {
    width: 260px;
    left: -280px;
  }

  .chat-header {
    padding-left: 70px !important;
  }

  .chat-messages {
    padding: 15px 12px;
  }

  .chat-input-container {
    padding: 12px 15px 20px 15px !important; /* Extra bottom padding for small phones */
  }

  .input-wrapper {
    padding: 12px 50px 12px 15px;
  }

  .chat-input {
    font-size: 16px !important; /* Keep 16px to prevent zoom */
  }

  .input-buttons {
    right: 6px;
  }

  .input-button {
    width: 28px;
    height: 28px;
  }

  .social-title {
    font-size: 10px;
  }

  .social-item {
    padding: 6px 10px;
    font-size: 11px;
  }

  .welcome-message {
    padding: 25px 12px 120px 12px; /* Even more bottom padding */
  }

  .welcome-title {
    font-size: 22px;
  }

  .welcome-subtitle {
    font-size: 13px;
  }
}

/* ==================== iOS SPECIFIC FIXES ==================== */

@media (max-width: 768px) {
  /* Prevent iOS body scroll */
  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
  }

  /* Prevent iOS zoom on input focus */
  input, textarea, select {
    font-size: 16px !important;
  }

  .chat-input:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
  }
}

/* ==================== SIDEBAR VISIBILITY FIXES ==================== */

@media (max-width: 768px) {
  .sidebar.open {
    opacity: 1;
    visibility: visible;
  }

  .sidebar.open * {
    opacity: 1;
    visibility: visible;
  }

  .sidebar.open .profile-section,
  .sidebar.open .categories,
  .sidebar.open .social-links {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .sidebar .profile-name,
  .sidebar .profile-title,
  .sidebar .category-title,
  .sidebar .category-item,
  .sidebar .social-title,
  .sidebar .social-item {
    color: inherit;
    opacity: 1;
  }
}