/* Extracted from whatsapp.html */

/* =========================================================================
       BASE RESET & SHELL
       ========================================================================= */

    *, *::before, *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    html, body {
      height: 100%;
    }

    body {
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      color: var(--color-text-primary);
      background-color: var(--color-bg-base);
      overflow: hidden;
    }

    [data-theme="modern"] body {
      background-image: radial-gradient(
        circle,
        var(--dot-grid-color) 1px,
        transparent 1px
      );
      background-size: var(--dot-grid-size) var(--dot-grid-size);
    }

    /* =========================================================================
       LAYOUT: sidebar offset + full-height messenger
       ========================================================================= */

    .page-shell {
      display: flex;
      height: 100vh;
      overflow: hidden;
    }

    .main-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    /* =========================================================================
       TOP BAR
       ========================================================================= */

    .top-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      height: 48px;
      padding: 0 var(--space-4);
      background: var(--color-bg-elevated);
      border-bottom: 1px solid var(--color-border);
      flex-shrink: 0;
    }

    .top-bar__title {
      font-family: var(--font-heading);
      font-size: var(--text-body);
      font-weight: var(--font-weight-bold);
      letter-spacing: var(--tracking-wide);
      text-transform: uppercase;
      color: var(--color-text-primary);
      display: flex;
      align-items: center;
      gap: var(--space-2);
    }

    .top-bar__title svg {
      color: #25D366;
    }

    .top-bar__actions {
      display: flex;
      gap: var(--space-2);
      align-items: center;
    }

    .top-bar__status {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: var(--text-caption);
      color: var(--color-text-muted);
    }

    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--color-text-muted);
    }

    .status-dot--ok   { background: var(--color-success); }
    .status-dot--warn  { background: var(--color-warning); }
    .status-dot--error { background: var(--color-error); }

    /* =========================================================================
       MESSENGER LAYOUT: conversations list + chat panel
       ========================================================================= */

    .messenger {
      flex: 1;
      display: flex;
      overflow: hidden;
    }

    /* ─── Left panel: conversation list ──────────────────────────────── */

    .conv-panel {
      width: 320px;
      min-width: 260px;
      display: flex;
      flex-direction: column;
      border-right: 1px solid var(--color-border);
      background: var(--color-bg-elevated);
    }

    .conv-panel__header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: var(--space-3) var(--space-4);
      border-bottom: 1px solid var(--color-border);
      flex-shrink: 0;
    }

    .conv-panel__title {
      font-weight: var(--font-weight-semibold);
      font-size: var(--text-body-sm);
      color: var(--color-text-secondary);
      text-transform: uppercase;
      letter-spacing: var(--tracking-wider);
    }

    .conv-panel__list {
      flex: 1;
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: var(--scrollbar-thumb, #444) var(--scrollbar-track, #222);
    }

    .conv-item {
      display: flex;
      flex-direction: column;
      padding: var(--space-3) var(--space-4);
      border-bottom: 1px solid var(--color-border);
      cursor: pointer;
      transition: background var(--duration-fast) var(--ease-in-out);
    }

    .conv-item:hover {
      background: var(--color-surface-2, rgba(255,255,255,0.04));
    }

    .conv-item.is-active {
      background: var(--color-primary-muted, rgba(245,166,35,0.12));
      border-left: 3px solid var(--color-primary);
    }

    .conv-item__phone {
      font-weight: var(--font-weight-semibold);
      font-size: var(--text-body-sm);
      color: var(--color-text-primary);
    }

    .conv-item__preview {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-top: 2px;
    }

    .conv-item__time {
      font-size: 0.6875rem;
      color: var(--color-text-muted);
      margin-top: 2px;
    }

    .conv-item__delete {
      position: absolute;
      top: 8px;
      right: 8px;
      background: none;
      border: none;
      color: var(--color-text-muted);
      font-size: 16px;
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.15s;
      padding: 2px 6px;
      border-radius: 4px;
    }
    .conv-item:hover .conv-item__delete { opacity: 1; }
    .conv-item__delete:hover { color: #F85149; background: rgba(248,81,73,0.1); }
    .conv-item { position: relative; }

    .conv-empty {
      padding: var(--space-6);
      text-align: center;
      color: var(--color-text-muted);
      font-size: var(--text-body-sm);
    }

    /* ─── Right panel: chat view ─────────────────────────────────────── */

    .wa-chat-panel {
      flex: 1;
      display: flex;
      flex-direction: column;
      background: var(--color-bg-base);
    }

    .wa-chat-panel__header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: var(--space-3) var(--space-4);
      background: var(--color-bg-elevated);
      border-bottom: 1px solid var(--color-border);
      flex-shrink: 0;
    }

    .wa-chat-panel__phone {
      font-weight: var(--font-weight-semibold);
      font-size: var(--text-body);
      color: var(--color-text-primary);
    }

    .wa-chat-panel__actions {
      display: flex;
      gap: var(--space-2);
    }

    .wa-chat-panel__messages {
      flex: 1;
      overflow-y: auto;
      padding: var(--space-4);
      display: flex;
      flex-direction: column;
      gap: var(--space-2);
      scrollbar-width: thin;
      scrollbar-color: var(--scrollbar-thumb, #444) var(--scrollbar-track, #222);
    }

    /* ─── Message bubbles ────────────────────────────────────────────── */

    .msg-bubble {
      max-width: 70%;
      padding: var(--space-2) var(--space-3);
      border-radius: var(--radius-md, 8px);
      word-wrap: break-word;
      line-height: 1.5;
    }

    .msg-bubble--in {
      align-self: flex-start;
      background: var(--color-surface-2, rgba(255,255,255,0.06));
      color: var(--color-text-primary);
      border-bottom-left-radius: var(--radius-xs, 2px);
    }

    [data-theme="modern"] .msg-bubble--in {
      background: var(--color-neutral-100);
    }

    .msg-bubble--out {
      align-self: flex-end;
      background: var(--color-primary-muted, rgba(245,166,35,0.15));
      color: var(--color-text-primary);
      border-bottom-right-radius: var(--radius-xs, 2px);
    }

    [data-theme="modern"] .msg-bubble--out {
      background: #dcf8c6;
      color: #111;
    }

    .msg-bubble__text {
      font-size: var(--text-body-sm);
    }

    .msg-bubble__meta {
      font-size: 0.6875rem;
      color: var(--color-text-muted);
      margin-top: 4px;
      text-align: right;
    }

    .msg-status {
      display: inline-block;
      font-size: 0.625rem;
      padding: 1px 4px;
      border-radius: var(--radius-xs, 2px);
      background: var(--color-surface-3, rgba(255,255,255,0.04));
      color: var(--color-text-muted);
      margin-left: 4px;
    }

    .chat-empty {
      text-align: center;
      color: var(--color-text-muted);
      padding: var(--space-8);
    }

    /* ─── Chat input bar ─────────────────────────────────────────────── */

    .chat-input-bar {
      display: flex;
      gap: var(--space-2);
      padding: var(--space-3) var(--space-4);
      border-top: 1px solid var(--color-border);
      background: var(--color-bg-elevated);
      flex-shrink: 0;
    }

    .chat-input-bar textarea {
      flex: 1;
      resize: none;
      border: 1px solid var(--color-border);
      border-radius: var(--radius-md, 8px);
      background: var(--color-bg-base);
      color: var(--color-text-primary);
      padding: var(--space-2) var(--space-3);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      line-height: 1.4;
      min-height: 40px;
      max-height: 100px;
    }

    .chat-input-bar textarea:focus {
      outline: none;
      border-color: var(--color-primary);
      box-shadow: 0 0 0 2px var(--color-primary-muted, rgba(245,166,35,0.2));
    }

    .chat-input-bar textarea::placeholder {
      color: var(--color-text-muted);
    }

    /* ─── Buttons ────────────────────────────────────────────────────── */

    .btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: var(--space-2) var(--space-3);
      border: 1px solid var(--color-border);
      border-radius: var(--radius-sm, 4px);
      background: var(--color-bg-elevated);
      color: var(--color-text-primary);
      font-family: var(--font-body);
      font-size: var(--text-body-sm);
      font-weight: var(--font-weight-semibold);
      cursor: pointer;
      transition: all var(--duration-fast) var(--ease-in-out);
      white-space: nowrap;
    }

    .btn:hover {
      background: var(--color-surface-2, rgba(255,255,255,0.06));
    }

    .btn--primary {
      background: var(--color-primary);
      color: var(--color-text-inverse, #fff);
      border-color: var(--color-primary);
    }

    .btn--primary:hover {
      opacity: 0.9;
    }

    .btn--primary:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .btn--sm {
      padding: 4px 8px;
      font-size: var(--text-caption);
    }

    .btn--whatsapp {
      background: #25D366;
      color: #fff;
      border-color: #25D366;
    }

    .btn--whatsapp:hover {
      background: #1da851;
    }

    /* ─── Empty state (no conversation selected) ─────────────────────── */

    .empty-state {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      color: var(--color-text-muted);
      gap: var(--space-4);
    }

    .empty-state svg {
      opacity: 0.3;
    }

    .empty-state__text {
      font-size: var(--text-body);
      text-align: center;
    }

    .empty-state__hint {
      font-size: var(--text-caption);
      color: var(--color-text-muted);
    }

    /* ─── Connection / QR section ────────────────────────────────────── */

    .connect-section {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: var(--space-4);
      padding: var(--space-6);
      text-align: center;
    }

    .connect-section__title {
      font-family: var(--font-heading);
      font-size: var(--text-h3, 1.25rem);
      font-weight: var(--font-weight-bold);
      color: var(--color-text-primary);
    }

    .connect-section__desc {
      font-size: var(--text-body-sm);
      color: var(--color-text-muted);
      max-width: 400px;
      line-height: 1.5;
    }

    .connect-section__qr {
      border: 2px dashed var(--color-border);
      border-radius: var(--radius-md, 8px);
      padding: var(--space-4);
      background: var(--color-bg-elevated);
      min-width: 280px;
      min-height: 280px;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .connect-section__qr img {
      max-width: 256px;
      max-height: 256px;
      border-radius: var(--radius-sm, 4px);
    }

    .connect-section__qr-placeholder {
      color: var(--color-text-muted);
      font-size: var(--text-body-sm);
    }

    .connect-section__actions {
      display: flex;
      gap: var(--space-2);
    }

    /* ─── Industrial theme cuts ──────────────────────────────────────── */

    [data-theme="industrial"] .btn--primary {
      clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
    }

    [data-theme="industrial"] .msg-bubble--out {
      clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
    }

    /* ─── Responsive ─────────────────────────────────────────────────── */

    @media (max-width: 768px) {
      .conv-panel { width: 100%; min-width: 0; }
      .wa-chat-panel { display: none; width: 100%; }
      .messenger.has-active-chat .conv-panel { display: none; }
      .messenger.has-active-chat .wa-chat-panel { display: flex !important; width: 100%; }
    }
