/* ===============================
   FRONTEND CHAT UI
   =============================== */

   .m196media-chat-container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
  }
  
  /* Wrapper + inner scroll area */
  .m196media-chat-wrapper {
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 15px 40px rgba(15, 23, 42, 0.15);
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
    min-height: 260px;
    max-height: 520px;
    box-sizing: border-box;
  }
  
  .m196media-chat-inner {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .m196media-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 6px;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Each message row */
  .m196media-chat-messages > div {
    display: flex;
    margin-bottom: 8px;
  }
  
  /* Chat bubbles */
  .m196media-chat-bubble {
    max-width: 90%;
    padding: 8px 11px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    box-sizing: border-box;
    text-align: left; /* ensure left-aligned text */
  }
  
  /* Bot bubble: left */
  .m196media-chat-bot {
    align-self: flex-start;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.18);
    background-color: var(--m196media-bot-bg, #ffffff);
    color: var(--m196media-bot-text, #0f172a);
  }
  
  /* User bubble: right */
  .m196media-chat-user {
    align-self: flex-end;
    margin-left: auto; /* critical for right alignment */
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
    background-color: var(--m196media-user-bg, #2563eb);
    color: var(--m196media-user-text, #ffffff);
  }
  
  /* Subtitle under bot text (question caption) */
  .m196media-subtitle {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    opacity: 0.8;
  }
  
  /* Options */
  .m196media-chat-options {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .m196media-chat-option-btn {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: #ffffff;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  }
  
  .m196media-chat-option-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
  }
  
  .m196media-chat-option-btn:disabled {
    opacity: 0.6;
    cursor: default;
  }
  
  /* Text input form */
  .m196media-chat-text-form {
    display: flex;
    gap: 6px;
    margin-top: 6px;
  }
  
  .m196media-chat-text-input {
    flex: 1 1 auto;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    padding: 6px 10px;
    font-size: 13px;
  }
  
  .m196media-chat-text-submit {
    flex: 0 0 auto;
    border-radius: 999px;
    border: none;
    background: var(--m196media-accent, #2563eb);
    color: #ffffff;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
  }
  
  /* Typing indicator */
  .m196media-chat-typing {
    display: none;
    padding: 4px 6px;
  }
  
  .m196media-chat-typing.is-visible {
    display: flex;
  }
  
  .m196media-chat-typing span {
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.8);
    margin-right: 3px;
    animation: m196media-typing-bounce 1.1s infinite ease-in-out;
  }
  
  .m196media-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
  }
  
  .m196media-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
  }
  
  @keyframes m196media-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
    40% { transform: translateY(-3px); opacity: 1; }
  }
  
  /* Footer (progress + restart) – if you add this later */
  .m196media-chat-footer {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .m196media-chat-progress {
    flex: 1 1 auto;
    min-width: 150px;
  }
  
  .m196media-chat-progress-label {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 2px;
  }
  
  .m196media-chat-progress-bar {
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.2);
    overflow: hidden;
  }
  
  .m196media-chat-progress-bar-inner {
    width: 0;
    height: 100%;
    background: var(--m196media-accent, #2563eb);
    transition: width 0.25s ease;
  }
  
  .m196media-chat-restart-btn {
    flex: 0 0 auto;
    border-radius: 999px;
    border: none;
    background: #0f172a;
    color: #f9fafb;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
  }
  
  .m196media-chat-restart-btn:hover {
    background: #111827;
    transform: translateY(-1px);
  }
  
  /* Mobile tweaks */
  @media (max-width: 480px) {
    .m196media-chat-wrapper {
      padding: 8px;
      border-radius: 12px;
    }
    .m196media-chat-bubble {
      max-width: 90%;
    }
  }
  
  /* ===============================
     ADMIN UI (Builder + Analytics)
     =============================== */
  
  .m196media-admin-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
  }
  
  .m196media-admin-left {
    flex: 1 1 60%;
    min-width: 320px;
  }
  
  .m196media-admin-right {
    flex: 1 1 35%;
    min-width: 260px;
  }
  
  .m196media-intro-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
  }
  
  .m196media-question-card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    padding: 14px 16px;
    margin-bottom: 14px;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
  }
  
  .m196media-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  
  .m196media-question-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
  }
  
  .button-link-delete {
    border: none;
    background: none;
    color: #b91c1c;
    cursor: pointer;
    font-size: 11px;
    text-decoration: underline;
    padding: 0;
  }
  
  .m196media-options-wrapper {
    margin-top: 4px;
  }
  
  .m196media-options-wrapper h5,
  .m196media-conditional-wrapper h5 {
    margin: 10px 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
  }
  
  .m196media-option-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
  }
  
  .m196media-option-row input[type="text"] {
    flex: 1 1 auto;
  }
  
  .m196media-option-row input[type="number"] {
    max-width: 80px;
  }
  
  .m196media-redirect-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
  }
  
  /* Color preview */
  .m196media-preview {
    margin-top: 8px;
  }
  
  .m196media-preview-wrapper {
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
  }
  
  .m196media-preview-bubble {
    display: inline-block;
    padding: 8px 10px;
    border-radius: 16px;
    font-size: 12px;
    margin-bottom: 6px;
    max-width: 80%;
  }
  
  .m196media-preview-bot {
    align-self: flex-start;
  }
  
  .m196media-preview-user {
    align-self: flex-end;
    text-align: left;
    margin-left: auto;
  }
  
  .m196media-preview-progress {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    margin-top: 8px;
  }
  
  .m196media-preview-progress-inner {
    width: 60%;
    height: 100%;
  }
  
  /* Analytics header */
  .m196media-analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
  }
  
  .m196media-analytics-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-width: 520px;
  }
  
  .m196media-analytics-summary-item {
    min-width: 130px;
    padding: 6px 8px;
    border-radius: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
  }
  
  .m196media-analytics-label {
    display: block;
    font-size: 11px;
    color: #6b7280;
  }
  
  .m196media-analytics-value {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-top: 1px;
  }
  
  .m196media-stats-dates {
    display: flex;
    align-items: flex-end;
    gap: 8px;
  }
  
  .m196media-stats-date input[type="date"] {
    width: 150px;
  }
  
  .m196media-stats-date-btn button {
    margin-top: 14px;
  }
  
  .m196media-stats-results {
    margin-top: 10px;
  }
  
  /* ==========================================================
     ADMIN – Tabs
     ========================================================== */
  .m196media-tabs-wrap {
    margin-bottom: 8px;
  }
  .m196media-tabs .nav-tab {
    cursor: pointer;
  }
  
  /* ==========================================================
     ADMIN – Analytics chart (single, cleaned-up version)
     ========================================================== */
  
  .m196media-stats-chart {
    margin-top: 10px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    padding: 10px 12px;
    height: 220px;            /* fixed height so % heights work */
    display: flex;
    align-items: flex-end;
    gap: 16px;
    overflow-x: auto;
    box-sizing: border-box;
  }
  
  .m196media-chart-empty {
    font-size: 12px;
    color: #6b7280;
  }
  
  .m196media-chart-loading {
    opacity: 0.5;
  }
  
  .m196media-chart-bar {
    flex: 0 0 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;              /* IMPORTANT: inner bar height % is based on this */
  }
  
  .m196media-chart-bar-inner {
    width: 100%;
    background: #3b82f6;
    border-radius: 8px 8px 0 0;
    height: 0;                 /* will be overridden by JS with pct% */
    transition: height 0.25s ease-out;
  }
  
  .m196media-chart-bar-label {
    margin-top: 4px;
    font-size: 11px;
    text-align: center;
    color: #4b5563;
  }
  
  .m196media-chart-bar-pct {
    display: block;
  }
  
  .m196media-chart-bar-q {
    display: block;
    color: #9ca3af;
  }
  
  /* Responsive admin */
  @media (max-width: 900px) {
    .m196media-admin-wrapper {
      flex-direction: column;
    }
    .m196media-admin-right {
      width: 100%;
    }
  }