﻿  /* * NEW DESIGN PARADIGM: Glassmorphism, Floating UI, iOS-style Bubbles
   */
  :root {
    --brand-accent: #f4b183;
    --brand-accent-hover: #e09a5f;
    --brand-accent-ink: #1e1c1a;
    --concierge-panel-bg: #ffffff;
    --surface-glass: #ffffff;
    --surface-solid: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bubble-agent: #f3f4f6;
    --bubble-user: var(--brand-accent);
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.12);
    --radius-pill: 9999px;
    --radius-box: 24px;
    --radius-bubble: 20px;
  }

  .concierge-chat {
    --concierge-inset-x: 2rem;
    --concierge-inset-bottom: 2rem;
    --concierge-toggle-size: 64px;
    --concierge-panel-gap: 16px;
    --concierge-inset-top: max(12px, env(safe-area-inset-top, 0px) + 12px);
    position: fixed;
    bottom: var(--concierge-inset-bottom);
    right: var(--concierge-inset-x);
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
  }

  /* Fixed between top safe area and toggle, never taller than the viewport */
  .concierge-chat-panel {
    position: fixed;
    right: var(--concierge-inset-x);
    bottom: calc(var(--concierge-inset-bottom) + var(--concierge-toggle-size) + var(--concierge-panel-gap));
    top: var(--concierge-inset-top);
    left: auto;
    width: min(380px, calc(100vw - (var(--concierge-inset-x) * 2)));
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    background: var(--concierge-panel-bg);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-box);
    box-shadow: var(--shadow-heavy);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }

  .concierge-chat-panel[hidden] {
    display: none;
    opacity: 0;
    transform: scale(0.8) translateY(40px);
    pointer-events: none;
  }

  /* Minimalist Header, override app.css green header and white text */
  .concierge-chat .concierge-chat-header {
    padding: 16px 16px 12px;
    background: var(--concierge-panel-bg) !important;
    color: #1f2937 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    min-height: 72px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  }

  .header-profile {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
    flex: 1;
  }

  #concierge-chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    object-fit: contain;
    padding: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    display: block;
  }

  .header-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
  }

  .concierge-chat .header-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.3px;
    line-height: 1.25;
    color: #111827 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .concierge-chat .header-subtitle,
  .concierge-chat #concierge-chat-agent-status {
    font-size: 12px;
    color: var(--brand-accent) !important;
    margin: 2px 0 0 0;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    gap: 5px;
  }

  .concierge-chat #concierge-chat-agent-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 9999px;
    background: var(--brand-accent);
    flex: 0 0 auto;
  }

  .concierge-chat #concierge-chat-close {
    background: rgba(0,0,0,0.05);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280 !important;
    transition: background 0.2s;
    flex-shrink: 0;
  }

  #concierge-chat-close:hover {
    background: rgba(0,0,0,0.1);
    color: var(--text-primary);
  }

  /* Seamless Messages Area */
  .concierge-chat .concierge-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--concierge-panel-bg) !important;
  }

  .concierge-chat-messages::-webkit-scrollbar { width: 6px; }
  .concierge-chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }

  /* True Modern Bubbles */
  .chat-row {
    display: flex;
    width: 100%;
    animation: fadeIn 0.3s ease forwards;
  }

  .chat-row-agent {
    justify-content: flex-start;
  }

  .chat-row-user {
    justify-content: flex-end;
  }

  .chat-row-user-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: min(82%, 300px);
    min-width: 0;
    gap: 4px;
  }

  .chat-message-meta {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    letter-spacing: 0.02em;
    padding-right: 4px;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.22s ease, transform 0.22s ease;
  }

  .chat-message-meta.is-fading {
    opacity: 0;
    transform: translateY(-2px);
  }

  .chat-message-meta[hidden] {
    display: none;
  }

  .chat-system-line {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin: 4px 0 8px;
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 9999px;
    align-self: center;
    max-width: 90%;
  }

  .chat-bubble {
    max-width: min(85%, 300px);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    width: auto;
  }

  .chat-row-user .chat-bubble {
    min-width: 72px;
    max-width: 100%;
    text-align: left;
  }

  /* Agent: Soft gray, fully rounded except top-left */
  .chat-row-agent .chat-bubble {
    background: var(--bubble-agent);
    color: var(--text-primary);
    border-radius: 4px var(--radius-bubble) var(--radius-bubble) var(--radius-bubble);
  }

  .chat-row-agent .chat-bubble a.concierge-chat-link {
    color: #b8732e;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
  }

  .chat-row-agent .chat-bubble a.concierge-chat-link:hover {
    color: var(--brand-accent-hover);
  }

  .chat-row-agent .chat-bubble strong a.concierge-chat-link {
    font-weight: 700;
  }

  /* User: Solid brand color, fully rounded except bottom-right */
  .chat-row-user .chat-bubble {
    background: var(--bubble-user);
    color: var(--brand-accent-ink);
    border-radius: var(--radius-bubble) var(--radius-bubble) 4px var(--radius-bubble);
    box-shadow: 0 4px 12px rgba(244, 177, 131, 0.35);
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Floating Input Area */
  .concierge-chat .concierge-chat-footer {
    padding: 12px 20px 20px;
    background: var(--concierge-panel-bg) !important;
    border-top: none !important;
    flex-shrink: 0;
  }

  .concierge-chat-form {
    display: flex;
    background: var(--surface-solid);
    border-radius: var(--radius-box);
    padding: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.05);
    align-items: center;
  }

  .input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 12px;
  }

  .concierge-chat .concierge-chat-form #concierge-chat-input {
    width: 100%;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 14px;
    color: var(--text-primary);
    outline: none !important;
    padding: 8px 0;
  }

  .concierge-chat .concierge-chat-form #concierge-chat-input:focus {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  #concierge-chat-input::placeholder {
    color: #9ca3af;
  }

  .btn-icon {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s;
  }

  .btn-icon:hover { color: var(--brand-accent); }

  #concierge-chat-send {
    background: var(--brand-accent);
    color: var(--brand-accent-ink);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
  }

  #concierge-chat-send:hover {
    background: var(--brand-accent-hover);
    transform: scale(1.05);
  }

  /* Redesigned Lead/Action Forms */
  .concierge-chat .concierge-chat-actions {
    display: flex;
    gap: 8px;
    padding: 0 20px 12px;
    margin-top: 0;
    margin-bottom: 0;
    flex-wrap: wrap;
    flex-shrink: 0;
    background: var(--concierge-panel-bg) !important;
    border-top: none !important;
  }

  .concierge-chat #concierge-chat-quick-replies {
    background: var(--concierge-panel-bg);
    padding: 0 20px 12px;
  }

  .action-chip {
    background: #f9fafb;
    border: 1px solid rgba(0,0,0,0.1);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.2s;
  }

  .action-chip:hover {
    border-color: var(--brand-accent);
    color: var(--brand-accent);
  }

  .concierge-chat .embedded-form-container {
    background: var(--concierge-panel-bg) !important;
    box-shadow: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    margin: 0 20px 16px;
    padding: 16px 0 0;
    border-radius: 0;
    flex-shrink: 0;
  }

  .embedded-form-container input,
  .embedded-form-container textarea {
    width: 100%;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
    box-sizing: border-box;
    outline: none;
  }

  .embedded-form-container input:focus,
  .embedded-form-container textarea:focus {
    border-color: var(--brand-accent);
  }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .form-submit-btn {
    width: 100%;
    background: var(--text-primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    margin-top: 4px;
    transition: background 0.2s;
  }

  .form-submit-btn:hover {
    background: #000000;
  }

  /* Main Trigger Button - Liquid Animation */
  #concierge-chat-toggle {
    background: var(--text-primary);
    color: white;
    border: none;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: var(--shadow-heavy);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
  }

  #concierge-chat-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--brand-accent);
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  #concierge-chat-toggle:hover {
    transform: scale(1.08);
  }

  #concierge-chat-toggle:hover::before {
    opacity: 1;
  }

  #concierge-chat-toggle svg {
    position: relative;
    z-index: 2;
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
  }

  .toggle-close { display: none; }
  
  #concierge-chat-toggle[aria-expanded="true"] .toggle-open { display: none; }
  #concierge-chat-toggle[aria-expanded="true"] .toggle-close { display: block; transform: rotate(90deg); }
  #concierge-chat-toggle[aria-expanded="true"] {
    background: var(--brand-accent);
    color: var(--brand-accent-ink);
    transform: scale(0.9);
  }

  /* Extra safeguards for very small screens */
  @media (max-width: 640px) {
    .concierge-chat {
      --concierge-inset-x: max(1rem, env(safe-area-inset-right, 0px) + 0.5rem);
      --concierge-inset-bottom: max(1rem, env(safe-area-inset-bottom, 0px) + 0.5rem);
      --concierge-panel-gap: 12px;
    }

    .concierge-chat-panel {
      width: calc(100vw - (var(--concierge-inset-x) * 2));
      height: auto !important;
      max-height: none !important;
      min-height: 0 !important;
    }
  }
