/*
 * Chat Widget Styles for AleMaria Braids
 * Clean, modern chat interface with accessibility features
 */

/* CSS Variables for Chat Widget */
:root {
  --chat-primary: rgb(189, 29, 58);
  --chat-secondary: rgb(215, 129, 145);
  --chat-accent: rgb(240, 99, 99);
  --chat-bg: rgba(255, 255, 255, 0.95);
  --chat-shadow: rgba(0, 0, 0, 0.2);
  --chat-border: #e0e0e0;
  --chat-text: #333;
  --chat-text-light: #666;
  --chat-bot-bg: #ffeaef;
  --chat-scrollbar: #bd1d3a;
}

/* Floating Widget Button */
#chat-widget-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(189,29,58,0.6), rgba(255,45,84,0.6));
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(189,29,58,0.4);
    transition: transform 0.3s, box-shadow 0.3s;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #chat-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(189,29,58,0.5);
  }
  #chat-widget-btn svg {
    width: 30px;
    height: 30px;
  }
  
  /* Chatbox Modal */
  #chatbox-modal {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    max-width: 90vw;
    z-index: 1000;
    overflow: visible; /* allow emoji panel to show */
  }
  
  /* Chat Container */
  .chat-container {
    background: rgba(255,255,255,0.9);
    border-radius: 20px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    overflow: visible; /* allow emoji panel to show */
    display: flex;
    flex-direction: column;
    height: 500px;
    max-height: 70vh;
  }
  
  /* Chat Header */
  .chat-header {
    background: linear-gradient(145deg, rgba(189,29,58,0.8), rgba(255,45,84,0.8));
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
  }
  .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
  }
  
  /* Messages Area */
  .chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    margin: 5px 0;
    line-height: 1.4;
  }
  .message.user {
    background: linear-gradient(145deg, rgba(189,29,58,0.8), rgba(255,45,84,0.8));
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
  }
  .message.bot {
    background: #ffeaef;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
  }
  
  /* Input Area */
  .chat-input {
    position: relative;
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    align-items: center;
    overflow: visible; /* allow emoji panel to show */
  }
  #message-input {
    flex-grow: 1;
    border: 1px solid #ddd;
    padding: 8px 15px;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
  }
  
  /* Actions */
  .chat-actions {
    position: relative;
    display: flex;
    gap: 5px;
  }
  .action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
    color: #666;
    transition: color 0.3s ease;
  }
  .action-btn:hover {
    color: #bd1d3a;
  }
  
  /* Emoji Panel - hidden by default */
  .emoji-panel {
    display: none;
    position: absolute;
    bottom: 100%;   /* directly above the emoji button */
    right: 0;       /* anchor to right edge */
    background: rgba(255,255,255,0.95);
    border-radius: 8px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    padding: 8px;
    z-index: 9999;
  }
  
  /* Show as 4×2 box when active */
  .emoji-panel.active {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows:    repeat(2, 1fr);
    gap: 8px;
    width: max-content;
  }
  
  /* Each emoji is a simple span */
  .emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    border-radius: 4px;
  }
  .emoji-item:hover {
    background: #f0f0f0;
  }
  
  /* Typing Indicator */
  .typing {
    font-style: italic;
    color: #666;
  }
  
  /* Scrollbar Styling */
  .chat-messages::-webkit-scrollbar {
    width: 6px;
  }
  .chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
  }
  .chat-messages::-webkit-scrollbar-thumb {
    background: #bd1d3a;
    border-radius: 3px;
  }
  .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #ff2d54;
  }
  
  /* Responsive */
  @media (max-width: 480px) {
    #chatbox-modal {
      width: 90vw;
      right: 5vw;
    }
    .chat-container {
      height: 60vh;
    }
  }

  /* Accessibility improvements */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  /* Focus styles for keyboard navigation */
  #chat-widget-btn:focus,
  .close-btn:focus,
  .action-btn:focus,
  .emoji-item:focus {
    outline: 2px solid var(--chat-primary);
    outline-offset: 2px;
  }

  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .message.user {
      background: var(--chat-primary);
      color: #fff;
    }

    .message.bot {
      background: #fff;
      color: #000;
      border: 2px solid #000;
    }

    #chat-widget-btn {
      background: var(--chat-primary);
      color: #fff;
    }
  }

  /* Dark mode support */
  @media (prefers-color-scheme: dark) {
    #chatbox-modal {
      background: #2d2d2d;
      color: #fff;
    }

    .chat-messages {
      background: #1a1a1a;
    }

    .message.bot {
      background: #3d3d3d;
      color: #fff;
      border-color: #555;
    }

    .chat-input {
      background: #2d2d2d;
      border-top-color: #555;
    }

    .chat-input input {
      background: #1a1a1a;
      color: #fff;
      border-color: #555;
    }

    .emoji-panel {
      background: #2d2d2d;
      border-color: #555;
    }
  }
  