/**
 * ═══════════════════════════════════════════════════════════════
 *  H&R Roofing Chatbot Widget Styles v5.0
 *  Pairs with chat-widget.js v5.0 and main.py v5.0
 * ═══════════════════════════════════════════════════════════════
 *
 *  COLOR CUSTOMIZATION:
 *  Edit the CSS variables below in :root to change colors.
 *  Everything references these variables, so one change
 *  updates the entire widget.
 *
 *  CLASS NAME REFERENCE:
 *  .hr-chat-button     — Floating circle button (bottom-right)
 *  .hr-chat-window     — The chat window container
 *  .hr-chat-header     — Blue header bar with company name
 *  .hr-chat-messages   — Scrollable messages area
 *  .hr-chat-message    — Single message row (bot or user)
 *  .hr-chat-bubble     — The actual message bubble
 *  .hr-chat-bot        — Bot message alignment (left)
 *  .hr-chat-user       — User message alignment (right)
 *  .hr-chat-input-area — Bottom bar with input + buttons
 *  .hr-chat-send-btn   — Round send button
 *  .hr-chat-attach-btn — Round photo attach button
 *
 *  FILE LOCATION (HawkHost):
 *    /home/recondit/hrroofingandconstruction.com/
 *    wp-content/plugins/hr-chatbot/chat-widget.css
 * ═══════════════════════════════════════════════════════════════
 */


/* ═══════════════════════════════════════════════════════════════
   COLOR VARIABLES
   Change these to re-skin the widget for a different client.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --hr-primary: #0066cc;       /* Main brand color — header, send button, user bubbles */
  --hr-primary-hover: #0052a3; /* Darker shade for hover states */
  --hr-bg: #f7f9fc;            /* Messages area background */
  --hr-white: #ffffff;          /* Bot bubble + input background */
  --hr-border: #e5e7eb;        /* Borders and dividers */
  --hr-text: #1f2937;          /* Primary text color */
  --hr-muted: #9ca3af;         /* Secondary text, placeholders */
  --hr-badge: #ff4444;         /* Notification badge on floating button */
}


/* ═══════════════════════════════════════════════════════════════
   BASE
   Scope all widget styles under #hr-chatbot to avoid conflicts
   with the WordPress theme's global styles.
   ═══════════════════════════════════════════════════════════════ */

#hr-chatbot {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  z-index: 9999;
}

/* Reset box-sizing for all widget elements */
#hr-chatbot *,
#hr-chatbot *::before,
#hr-chatbot *::after {
  box-sizing: border-box;
}


/* ═══════════════════════════════════════════════════════════════
   FLOATING CHAT BUTTON
   Round button in the bottom-right corner that opens the chat.
   Shows a speech bubble icon with a "Chat" badge.
   ═══════════════════════════════════════════════════════════════ */

.hr-chat-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: var(--hr-primary);
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  color: white;
  z-index: 99999;
}

.hr-chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* "Chat" badge — red pill in top-right corner of the button */
.hr-chat-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--hr-badge);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}


/* ═══════════════════════════════════════════════════════════════
   CHAT WINDOW
   The main chat container — fixed position, bottom-right.
   Goes fullscreen on mobile (see media query below).
   ═══════════════════════════════════════════════════════════════ */

.hr-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 48px);
  background: var(--hr-white);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  /* Prevent iOS double-tap zoom */
  touch-action: manipulation;
}


/* ═══════════════════════════════════════════════════════════════
   HEADER
   Blue bar at the top — company name, status, close button.
   ═══════════════════════════════════════════════════════════════ */

.hr-chat-header {
  background: var(--hr-primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  min-height: 68px;
}

/* Text container — allows text to shrink without pushing close button */
.hr-chat-header > div {
  flex: 1;
  min-width: 0;
}

.hr-chat-header strong {
  font-size: 16px;
  display: block;
  margin-bottom: 2px;
}

/* "Usually responds instantly" subtitle */
.hr-chat-status {
  font-size: 12px;
  opacity: 0.9;
}

/* Close button (×) */
.hr-chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
  flex-shrink: 0;
  margin-left: 12px;
  position: relative;
  z-index: 100;
}

.hr-chat-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hr-chat-close:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}


/* ═══════════════════════════════════════════════════════════════
   MESSAGES AREA
   Scrollable container for all message bubbles.
   ═══════════════════════════════════════════════════════════════ */

.hr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--hr-bg);
}

/* Single message row — contains one bubble */
.hr-chat-message {
  margin-bottom: 16px;
  display: flex;
}

/* Bot messages align left */
.hr-chat-bot {
  justify-content: flex-start;
}

/* User messages align right */
.hr-chat-user {
  justify-content: flex-end;
}

/* Message bubble — shared styles */
.hr-chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

/* Bot bubble — white with border, left-aligned tail */
.hr-chat-bot .hr-chat-bubble {
  background: var(--hr-white);
  border: 1px solid var(--hr-border);
  color: var(--hr-text);
}

/* User bubble — blue, right-aligned tail */
.hr-chat-user .hr-chat-bubble {
  background: var(--hr-primary);
  color: white;
}


/* ═══════════════════════════════════════════════════════════════
   TYPING INDICATOR
   Three bouncing dots shown while waiting for bot response.
   ═══════════════════════════════════════════════════════════════ */

.hr-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.hr-typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hr-muted);
  animation: hr-typing-bounce 1.4s infinite;
}

.hr-typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.hr-typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes hr-typing-bounce {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-8px);
  }
}


/* ═══════════════════════════════════════════════════════════════
   PHOTO PREVIEW
   Thumbnail of attached photo shown in a user bubble.
   ═══════════════════════════════════════════════════════════════ */

.hr-chat-photo-preview {
  max-width: 200px;
  border-radius: 10px;
  display: block;
  margin-top: 4px;
}


/* ═══════════════════════════════════════════════════════════════
   INPUT AREA
   Bottom bar — contains: [attach button] [text input] [send button]
   ═══════════════════════════════════════════════════════════════ */

.hr-chat-input-area {
  padding: 12px 16px;
  background: var(--hr-white);
  border-top: 1px solid var(--hr-border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* Text input field */
#hr-chat-input {
  flex: 1;
  border: 1px solid var(--hr-border);
  border-radius: 24px;
  padding: 12px 16px;
  font-size: 16px;  /* CRITICAL: 16px+ prevents iOS auto-zoom on focus */
  outline: none;
  transition: border-color 0.2s;
  color: var(--hr-text);
  font-family: inherit;
  -webkit-appearance: none;  /* Remove iOS default styling */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#hr-chat-input::placeholder {
  color: var(--hr-muted);
}

#hr-chat-input:focus {
  border-color: var(--hr-primary);
}

/* ── Send button ───────────────────────────────────────────────
   Round blue circle with white arrow icon.
   44px meets iOS minimum touch target guidelines.
   ──────────────────────────────────────────────────────────── */

.hr-chat-send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;   /* Prevent shrinking in flex layout */
  min-height: 44px;
  border-radius: 22px;
  background: var(--hr-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.hr-chat-send-btn:hover {
  background: var(--hr-primary-hover);
}

.hr-chat-send-btn:active {
  transform: scale(0.95);
}

/* Ensure SVG inside send button displays correctly */
.hr-chat-send-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Attach (photo) button ─────────────────────────────────────
   Round button matching the send button size and shape.
   Uses a lighter background to visually distinguish it as
   secondary to the send button.
   ──────────────────────────────────────────────────────────── */

.hr-chat-attach-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 22px;
  background: var(--hr-bg);
  border: 1px solid var(--hr-border);
  color: var(--hr-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.hr-chat-attach-btn:hover {
  border-color: var(--hr-primary);
  color: var(--hr-primary);
  background: var(--hr-white);
}

.hr-chat-attach-btn:active {
  transform: scale(0.95);
}

/* Ensure SVG inside attach button displays correctly */
.hr-chat-attach-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   On screens 768px and below, the chat window goes fullscreen.
   This prevents awkward partial-screen layouts on phones.
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .hr-chat-window {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    /* iPhone notch and home indicator safe areas */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .hr-chat-header {
    padding: 20px;
    min-height: 60px;
  }

  /* Bigger close button on mobile for easier tapping */
  .hr-chat-close {
    width: 40px;
    height: 40px;
    font-size: 36px;
    position: relative;
    z-index: 10;
  }

  .hr-chat-messages {
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;  /* Smooth scrolling on iOS */
  }

  .hr-chat-input-area {
    padding: 12px;
    /* Stay above iPhone home indicator */
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .hr-chat-button {
    bottom: 20px;
    right: 20px;
    width: 64px;
    height: 64px;
    /* Position above iPhone home indicator */
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 8px));
  }
}

/* Bigger close button on touch devices (any screen size) */
@media (hover: none) and (pointer: coarse) {
  .hr-chat-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 36px;
  }
}

/* Lock page scroll when chat is fullscreen on mobile */
body.hr-chat-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}


/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR STYLING
   Thin, subtle scrollbar for the messages area.
   Only affects WebKit browsers (Chrome, Safari, Edge).
   Firefox uses its own thin scrollbar by default.
   ═══════════════════════════════════════════════════════════════ */

.hr-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.hr-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.hr-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.hr-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--hr-muted);
}