/**
 * ═══════════════════════════════════════════════════════════════════
 * MOBILE REDESIGN V4 - CLAUDE STYLE
 * ═══════════════════════════════════════════════════════════════════
 * 
 * Features:
 * - Wide message bubbles (85% width)
 * - User messages: RIGHT (avatar on right)
 * - AI messages: LEFT (avatar on left)
 * - Small copy/star icons below text
 * - Clean, spacious design
 */

@media (max-width: 768px) {
  /* ═══════════════════════════════════════════════════════════════
     HEADER - With hamburger menu
     ═══════════════════════════════════════════════════════════════ */
  
  .app-header {
    background: rgba(15, 27, 45, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    border-bottom: 1px solid rgba(212, 168, 83, 0.1) !important;
    padding: 16px !important; /* Increased from 12px for better hamburger fit */
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    min-height: 64px !important; /* Ensure enough height for 44px button */
  }
  
  .header-left {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    min-width: 0 !important;
  }
  
  .header-brand__main {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: rgba(255, 255, 255, 0.95) !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
  }

  .header-brand__sub {
    font-size: 10px !important;
    font-weight: 600 !important;
    color: rgba(255, 255, 255, 0.55) !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
  }

  .header-title {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: rgba(255, 255, 255, 0.95) !important;
    line-height: 1.05 !important;
    white-space: nowrap !important;
  }
  
  .logo-small {
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
  }

  .logo-small img {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    object-fit: contain !important;
    padding: 2px !important;
  }
  
  .tab-nav {
    display: none !important;
  }
  
  /* ═══════════════════════════════════════════════════════════════
     HAMBURGER MENU & SIDEBAR
     ═══════════════════════════════════════════════════════════════ */
  
  .mobile-hamburger-btn {
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    background: rgba(212, 168, 83, 0.08) !important;
    border: 1.5px solid rgba(212, 168, 83, 0.2) !important;
    transition: all 0.2s ease !important;
  }
  
  .mobile-hamburger-btn:active {
    background: rgba(212, 168, 83, 0.15) !important;
    transform: scale(0.95) !important;
  }
  
  .mobile-hamburger-btn span {
    width: 18px !important;
    height: 2px !important;
    background: rgba(212, 168, 83, 0.9) !important;
    border-radius: 2px !important;
    display: block !important;
  }
  
  /* Sidebar overlay */
  .mobile-sidebar-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 999 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
  }
  
  .mobile-sidebar-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* Sidebar panel */
  .mobile-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    background: rgba(10, 18, 32, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    border-right: 1px solid rgba(212, 168, 83, 0.15) !important;
    z-index: 1000 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow-y: auto !important;
    padding: 20px 0 !important;
  }
  
  .mobile-sidebar.active {
    transform: translateX(0) !important;
  }
  
  .mobile-sidebar-header {
    padding: 0 20px 20px !important;
    border-bottom: 1px solid rgba(212, 168, 83, 0.1) !important;
  }
  
  .mobile-sidebar-title {
    font-size: 24px !important;
    font-weight: 700 !important;
    color: rgba(255, 255, 255, 0.95) !important;
    margin-bottom: 4px !important;
  }
  
  .mobile-sidebar-subtitle {
    font-size: 13px !important;
    color: rgba(212, 168, 83, 0.6) !important;
  }
  
  .mobile-sidebar-menu {
    padding: 16px 0 !important;
  }
  
  .mobile-sidebar-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 14px 20px !important;
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: none !important;
    background: transparent !important;
    width: 100% !important;
    text-align: left !important;
  }
  
  .mobile-sidebar-item:active {
    background: rgba(212, 168, 83, 0.15) !important;
  }
  
  .mobile-sidebar-item.active {
    background: rgba(212, 168, 83, 0.1) !important;
    border-left: 3px solid rgba(212, 168, 83, 0.8) !important;
  }
  
  .mobile-sidebar-item-icon {
    font-size: 20px !important;
  }
  
  /* ═══════════════════════════════════════════════════════════════
     MESSAGES - CLAUDE STYLE LAYOUT
     ═══════════════════════════════════════════════════════════════ */
  
  .chat-messages {
    padding: 20px 12px 100px !important;
    gap: 6px !important; /* Very compact spacing - User to AI */
  }
  
  /* Base message styles - WRAP to column on mobile */
  .message {
    display: flex !important;
    flex-wrap: wrap !important; /* Allow wrapping */
    align-items: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
    margin-bottom: 0 !important;
  }
  
  /* Message avatar */
  .message-avatar {
    flex-shrink: 0 !important;
    width: 32px !important;
    height: 32px !important;
    order: 1 !important;
  }
  
  .message-avatar img {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
  }
  
  /* Message bubble */
  .message-content {
    padding: 14px 16px !important;
    border-radius: 16px !important;
    font-size: 15px !important;
    line-height: 1.6 !important;
    word-wrap: break-word !important;
    max-width: 85% !important;
    flex-grow: 1 !important;
    order: 2 !important; /* Content second */
  }
  
  /* USER messages - align RIGHT */
  .message.user {
    justify-content: flex-end !important;
    margin-top: 12px !important; /* Compact spacing before new user question */
  }
  
  .message.user .message-avatar {
    order: 2 !important; /* Avatar on right */
  }
  
  .message.user .message-content {
    order: 1 !important;
    background: linear-gradient(135deg, #1a3050 0%, #14243d 100%) !important;
    color: #F5F0E8 !important;
    border: 1px solid rgba(212, 168, 83, 0.15) !important;
    border-bottom-right-radius: 4px !important;
  }
  
  .message.user .timestamp-actions-container {
    padding-right: 40px !important; /* Right padding for user */
    padding-left: 0 !important;
    justify-content: flex-end !important;
  }
  
  /* AI messages - align LEFT */
  .message.assistant {
    justify-content: flex-start !important;
    margin-bottom: 18px !important; /* Extra space: 12px gap + 18px = 30px total */
  }
  
  .message.assistant .message-avatar {
    order: 1 !important; /* Avatar on left */
  }
  
  .message.assistant .message-content {
    order: 2 !important; /* Content on right */
    background: rgba(255, 255, 255, 0.95) !important;
    color: #1a1a1a !important;
    border-bottom-left-radius: 4px !important;
  }
  
  .message.assistant .timestamp-actions-container {
    padding-left: 40px !important;
    justify-content: flex-start !important;
  }
  
  /* ═══════════════════════════════════════════════════════════════
     COPY/STAR BUTTONS - BELOW TEXT (CLAUDE STYLE)
     ═══════════════════════════════════════════════════════════════ */
  
  .timestamp-actions-container {
    order: 3 !important; /* Actions LAST - after avatar + content */
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 2px 0 0 40px !important; /* Minimal top padding - closer to message */
    margin: 0 !important;
    position: relative !important;
    width: 100% !important; /* Full width to force new line */
    flex-basis: 100% !important; /* Force to new line */
  }
  
  /* Hide timestamp on mobile */
  .message-timestamp {
    display: none !important;
  }
  
  /* Actions container */
  .message-actions {
    display: flex !important;
    gap: 4px !important;
    opacity: 0.5 !important;
    transition: opacity 0.2s ease !important;
  }
  
  .message:active .message-actions {
    opacity: 0.8 !important;
  }
  
  /* Copy and star buttons */
  .copy-button,
  .favorite-button {
    background: transparent !important;
    border: none !important;
    padding: 4px !important;
    margin: 0 !important;
    font-size: 16px !important;
    color: rgba(212, 168, 83, 0.6) !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 24px !important;
    min-height: 24px !important;
    transition: all 0.15s ease !important;
  }
  
  .copy-button:active,
  .favorite-button:active {
    background: rgba(212, 168, 83, 0.1) !important;
    color: rgba(212, 168, 83, 0.9) !important;
    transform: scale(0.9) !important;
  }
  
  .favorite-button.favorited {
    color: rgba(255, 215, 0, 0.9) !important;
  }
  
  .copy-button svg,
  .favorite-button svg {
    width: 14px !important;
    height: 14px !important;
  }
  
  /* USER message buttons - align right */
  .message.user .timestamp-actions-container {
    justify-content: flex-end !important;
  }
  
  /* AI message buttons - align left */
  .message.assistant .timestamp-actions-container {
    justify-content: flex-start !important;
  }
  
  /* ═══════════════════════════════════════════════════════════════
     INPUT AREA
     ═══════════════════════════════════════════════════════════════ */
  
  .chat-input-container {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 8px 12px 12px !important;
    background: rgba(15, 27, 45, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(212, 168, 83, 0.1) !important;
    z-index: 100 !important;
  }
  
  #voiceInputBtn {
    display: none !important;
  }
  
  .chat-input-wrapper {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 24px !important;
    padding: 8px 8px 8px 16px !important;
  }
  
  #chatInput {
    font-size: 16px !important;
    color: rgba(255, 255, 255, 0.95) !important;
  }
  
  /* ═══════════════════════════════════════════════════════════════
     CLEAR CHAT BUTTON
     ═══════════════════════════════════════════════════════════════ */
  
  .chat-actions {
    margin-top: 8px !important;
    text-align: center !important;
  }
  
  .text-btn {
    font-size: 13px !important;
    padding: 8px 16px !important;
    color: rgba(212, 168, 83, 0.5) !important;
  }
  
  /* ═══════════════════════════════════════════════════════════════
     FOLLOW-UP PROMPTS
     ═══════════════════════════════════════════════════════════════ */
  
  .follow-up-prompts {
    margin: 16px 0 8px !important; /* Reduced bottom margin - closer to next message */
    padding: 12px !important;
  }
  
  .follow-up-prompt-btn {
    padding: 10px 14px !important;
    font-size: 14px !important;
    margin-bottom: 6px !important;
  }
  
  /* ═══════════════════════════════════════════════════════════════
     FULL HEIGHT TABS - FREE SCROLLING (iOS Safari fix)
     ═══════════════════════════════════════════════════════════════ */
  
  #dailyMessageTab,
  #profileTab {
    position: relative !important;
    min-height: calc(100vh - 120px) !important;
    overflow-y: scroll !important; /* Use scroll, not auto for iOS */
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 80px !important;
  }
  
  /* Prevent nested scroll containers - only parent scrolls */
  #dailyMessageContainer,
  .daily-message-wrapper,
  .profile-view-container {
    min-height: auto !important;
    overflow: visible !important; /* Critical for iOS - no nested scroll */
    padding-bottom: 40px !important;
  }
  
  /* iOS Safari scroll fix - ensure content is scrollable */
  #dailyMessageTab > *,
  #profileTab > * {
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
  }
}

