/* Responsive CSS for Claw Desktop - Mobile First Approach */

/* =========================================
   BASE STYLES (Mobile - < 768px)
   ========================================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Mobile: Full-width sidebar at top */
#sidebar {
  width: 100%;
  height: auto;
  position: relative;
  border-right: none;
  border-bottom: 1px solid #333;
  padding: 15px;
}

/* Mobile: Chat container takes full width */
#chat-container {
  margin-left: 0;
  width: 100%;
  padding: 10px;
}

/* Mobile: Messages take most of width */
.message {
  max-width: 95%;
  font-size: 14px;
  padding: 8px 12px;
  margin-bottom: 8px;
}

/* Mobile: Prevent iOS zoom on input focus */
#message-input {
  font-size: 16px !important; /* iOS won't zoom if >= 16px */
  padding: 12px;
  width: 100%;
}

/* Mobile: Limit conversation list height */
#conversation-list {
  max-height: 200px;
  overflow-y: auto;
}

/* Mobile: Touch-friendly buttons */
button {
  min-height: 44px; /* iOS recommended tap target size */
  min-width: 44px;
  padding: 12px 16px;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  transition: background-color 0.2s;
}

#send-button {
  padding: 12px 20px;
  min-width: 80px;
}

/* Mobile: Stack input and button vertically */
#input-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

#input-container #message-input {
  flex: 1;
}

#input-container #send-button {
  width: 100%;
}

/* =========================================
   TABLET (768px - 1024px)
   ========================================= */

@media (min-width: 768px) {
  /* Tablet: 30% sidebar */
  #sidebar {
    width: 30%;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    border-right: 1px solid #333;
    border-bottom: none;
    padding: 20px;
    overflow-y: auto;
  }

  /* Tablet: Chat container with left margin */
  #chat-container {
    margin-left: 30%;
    width: 70%;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* Tablet: Slightly larger messages */
  .message {
    max-width: 85%;
    font-size: 15px;
    padding: 10px 14px;
  }

  /* Tablet: Conversation list full height */
  #conversation-list {
    max-height: none;
  }

  /* Tablet: Horizontal input layout */
  #input-container {
    flex-direction: row;
    align-items: center;
  }

  #input-container #send-button {
    width: auto;
    min-width: 100px;
  }
}

/* =========================================
   DESKTOP (> 1024px)
   ========================================= */

@media (min-width: 1024px) {
  /* Desktop: Fixed 250px sidebar */
  #sidebar {
    width: 250px;
  }

  /* Desktop: Chat container with fixed sidebar offset */
  #chat-container {
    margin-left: 250px;
    width: calc(100% - 250px);
  }

  /* Desktop: Standard message width */
  .message {
    max-width: 80%;
    font-size: 16px;
    padding: 12px 16px;
  }

  /* Desktop: Larger buttons */
  button {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* =========================================
   LANDSCAPE MODE (Tablets/Phones)
   ========================================= */

@media (max-width: 1024px) and (orientation: landscape) {
  /* Landscape: Collapse sidebar to narrow width */
  #sidebar {
    width: 250px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
  }

  #chat-container {
    margin-left: 250px;
    width: calc(100% - 250px);
  }
}

/* =========================================
   UTILITY CLASSES
   ========================================= */

/* Hide on mobile */
.hide-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
}

/* Show only on mobile */
.show-mobile {
  display: block;
}

@media (min-width: 768px) {
  .show-mobile {
    display: none;
  }
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Safe area insets for iOS notch */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}

/* Prevent text selection on buttons */
button {
  -webkit-user-select: none;
  user-select: none;
}

/* Smooth transitions */
#sidebar,
#chat-container {
  transition: width 0.3s ease, margin-left 0.3s ease;
}

/* Improve scrollbar appearance on desktop */
@media (min-width: 1024px) {
  ::-webkit-scrollbar {
    width: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #1a1a1a;
  }

  ::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #555;
  }
}

/* Loading spinner (if needed) */
.spinner {
  border: 3px solid #333;
  border-top: 3px solid #007AFF;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
}

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

/* Error message styling */
.error-message {
  color: #ff4444;
  background-color: rgba(255, 68, 68, 0.1);
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
  font-size: 14px;
}

/* Success message styling */
.success-message {
  color: #44ff44;
  background-color: rgba(68, 255, 68, 0.1);
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
  font-size: 14px;
}
