.chat-page{padding:1rem 1.25rem 1.5rem;display:flex;flex-direction:column;gap:.75rem;background:transparent}
.chat-header{display:flex;justify-content:space-between;align-items:center;gap:1rem}
.chat-header h1{margin:0;font-size:1.25rem}
.chat-filters{display:flex;gap:.75rem;align-items:center}
.chat-filters select,.chat-filters button{padding:.6rem .9rem;border-radius:var(--radius-sm);border:1px solid #cfddd7;background:#fff;min-height:44px;font-size:14px}
.chat-modal-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0f172a73;display:flex;align-items:center;justify-content:center;z-index:50}
.chat-modal{background:#fff;border-radius:var(--radius-md);padding:20px 24px;width:min(90vw,360px);box-shadow:0 18px 40px #0f172a33;text-align:center}
.chat-modal h3{margin:0 0 8px;font-size:18px}
.chat-modal p{margin:0 0 16px;color:#475569;font-size:14px}
.chat-modal-actions{display:flex;justify-content:center}
.chat-modal-actions-split{gap:12px}
.chat-modal-actions .chat-secondary{background:#e5e7eb;color:#111827}
.chat-modal-actions button{border:none;background:linear-gradient(135deg,#0f766e,#0b5f58);color:#fff;padding:12px 20px;border-radius:var(--radius-md);cursor:pointer;font-weight:600;min-height:44px}
.chat-modal-actions button:active{background:#0b5f58}
.chat-filters button{background:linear-gradient(135deg,#0f766e,#0b5f58);color:#fff;border:none}
.chat-alert{background:#fef2f2;color:#991b1b;padding:.75rem 1rem;border-radius:var(--radius-md)}
.chat-layout{display:grid;grid-template-columns:350px minmax(0,1fr);gap:1rem;min-height:calc(100dvh - 190px)}
.chat-list{background:#fff;border-radius:var(--radius-lg);border:1px solid #dbe5e0;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 8px 20px #12342d12}
.chat-list-body{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}
.chat-list-header{padding:.85rem 1rem;display:flex;justify-content:space-between;border-bottom:1px solid #e5e7eb;font-size:.9rem;color:#6b7280}
.chat-list-toolbar{padding:.7rem 1rem;border-bottom:1px solid #e5e7eb;background:#f8fafc}
.chat-list-toolbar input{width:100%;min-height:40px;border:1px solid #d1d5db;border-radius:var(--radius-sm);padding:.55rem .75rem;font-size:14px;background:#fff}
.chat-list-toolbar input:focus{outline:none;border-color:#3d9f95;box-shadow:0 0 0 2px #3d9f9529}
.chat-tabs{display:flex;gap:8px;padding:.75rem 1rem;border-bottom:1px solid #e5e7eb;background:#fff}
.chat-tabs button{border:1px solid #e2e8f0;background:#fff;color:#1f2937;padding:8px 12px;border-radius:var(--radius-sm);cursor:pointer;font-size:13px;font-weight:600;min-height:44px}
.chat-tabs button:active{background:#f3f4f6}
.chat-tabs button.active{background:linear-gradient(135deg,#0f766e,#0b5f58);color:#fff}
.chat-mobile-tabs{display:none}
.chat-mobile-tab-button{text-align:center;padding:10px;border-radius:var(--radius-md);font-size:13px;font-weight:600;border:1px solid #e5e7eb;background:#f8fafc;color:#111827;cursor:pointer;min-height:44px}
.chat-mobile-tab-button:disabled{opacity:.55;cursor:not-allowed}
.chat-mobile-tab-button.active{background:linear-gradient(135deg,#0f766e,#0b5f58);color:#fff;border-color:transparent}
.chat-item{border:none;background:#fff;text-align:left;padding:12px 14px;border-bottom:1px solid #f3f4f6;cursor:pointer;display:flex;flex-direction:column;gap:7px;touch-action:manipulation;width:100%}
.chat-item.active{background:#e7f4ef;border-left:3px solid #0f766e}
.chat-item-title{display:flex;justify-content:space-between;align-items:center}
.chat-item-title strong{font-size:14px;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chat-item-body{color:#6b7280;font-size:13px;line-height:1.35;display:flex;flex-direction:column;gap:2px;overflow:hidden}
.chat-item-product{color:#1f2937;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-item-last{color:#6b7280;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden}
.chat-item-meta{display:flex;gap:.5rem;font-size:12px;color:#9ca3af}
.chat-customer{color:#6b7280;font-weight:500}
.chat-unread{background:#ef4444;color:#fff;font-size:.7rem;padding:.15rem .5rem;border-radius:var(--radius-full)}
.chat-thread{background:#fff;border-radius:var(--radius-lg);border:1px solid #e5e7eb;display:flex;flex-direction:column;overflow:visible;min-height:0;box-shadow:0 8px 24px #0f172a0f}
.chat-conversation-layout{min-height:0;height:100%}
.chat-thread-header{padding:.9rem 1rem;border-bottom:1px solid #e5e7eb;display:flex;justify-content:space-between;align-items:flex-start;gap:1rem}
.chat-thread-main{display:flex;align-items:flex-start;flex-direction:column;gap:.35rem;width:100%}
.chat-thread-info{display:flex;flex-direction:column}
.chat-thread-meta{display:flex;flex-direction:column;align-items:flex-start;gap:.25rem}
.chat-thread-meta span{font-size:12px;color:#64748b}
.chat-thread-actions{display:flex;justify-content:flex-end}
.chat-close-button{border:none;background:#ef4444;color:#fff;padding:.6rem 1rem;border-radius:var(--radius-md);cursor:pointer;font-weight:700;font-size:.85rem;min-height:44px}
.chat-close-button:active:not(:disabled){background:#dc2626}
.chat-close-button:disabled{opacity:.7;cursor:not-allowed}
.chat-product-image{width:48px;height:48px;border-radius:var(--radius-md);object-fit:cover;border:1px solid #e5e7eb;background:#f9fafb}
.chat-thread-header h2{margin:0;font-size:1rem;line-height:1.35;color:#0f172a}
.chat-messages{flex:1;padding:.9rem 1rem;overflow-y:auto;display:flex;flex-direction:column;gap:.55rem;-webkit-overflow-scrolling:touch;scroll-padding-bottom:80px;overscroll-behavior:contain;min-height:0}
.chat-reply-bar{border-top:1px solid #e5e7eb;padding:10px 12px;display:flex;align-items:center;gap:8px;background:#fff;min-height:48px}
.chat-reply-actions{display:flex;align-items:center;gap:.75rem;font-size:.85rem;color:#6b7280}
.chat-reply-actions button{padding:.45rem 1rem;border-radius:var(--radius-md);border:none;background:#111827;color:#fff;cursor:pointer;min-height:44px}
.chat-reply-actions button:disabled{opacity:.6;cursor:not-allowed}
@media (max-width: 1024px){.chat-layout{grid-template-columns:1fr}
}
@media (max-width: 768px){.chat-page{padding:1rem;background:#f5f6f8;flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.chat-layout{flex:1;min-height:0;display:flex;flex-direction:column;gap:12px;overflow:hidden}
.chat-list-toolbar{padding:.6rem .75rem}
.chat-mobile-tabs{display:grid;grid-template-columns:repeat(2,1fr);gap:8px;background:#fff;padding:8px;border-radius:var(--radius-md);box-shadow:0 6px 16px #0f172a14;flex-shrink:0}
.chat-list,.chat-thread{min-height:0}
.chat-layout:not(.mobile-thread-open) .chat-thread{display:none}
.chat-layout.mobile-thread-open .chat-list{display:none}
.chat-layout.mobile-thread-open .chat-thread{display:flex;flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch}
body.keyboard-open .chat-page .chat-header,body.keyboard-open .chat-page .chat-filters,body.keyboard-open .chat-page .chat-mobile-tabs,body.keyboard-open .chat-page .chat-list-header,body.keyboard-open .chat-page .chat-tabs,body.keyboard-open .app-header{display:none!important}
body.keyboard-open .chat-page .chat-layout.mobile-thread-open{height:var(--app-dvh, 100dvh)}
.chat-header{gap:.5rem;flex-shrink:0}
.chat-header p{display:none}
.chat-filters{width:100%;flex-wrap:wrap}
.chat-layout:not(.mobile-thread-open) .chat-list{flex:1;min-height:0}
.chat-filters select,.chat-filters button{width:100%}
.chat-thread-header{flex-direction:column;align-items:flex-start;flex-shrink:0}
.chat-thread{min-height:0}
.chat-conversation-layout{height:auto}
.chat-thread-back{border:none;background:#e5e7eb;color:#111827;border-radius:var(--radius-md);padding:10px 14px;font-size:13px;font-weight:700;width:fit-content;min-height:44px}
.chat-thread-back:active{background:#d1d5db}
.chat-messages{padding:10px 12px;padding-bottom:calc(12px + env(safe-area-inset-bottom));min-height:0;flex:0 0 auto;overflow:visible}
html[data-kb="1"] .chat-messages{padding-bottom:12px}
.chat-reply-bar{position:static;flex-shrink:0;padding:8px 10px;padding-bottom:calc(8px + env(safe-area-inset-bottom));background:#fff;box-shadow:0 -4px 12px #0f172a0f;border-top:1px solid #e5e7eb}
.chat-conversation-layout .conversation-input.chat-reply-bar{position:static;bottom:auto;z-index:auto;padding-bottom:calc(8px + env(safe-area-inset-bottom))}
html[data-kb="1"] .chat-reply-bar{padding-bottom:8px}
.chat-modal{max-height:calc(var(--app-dvh, 100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));overflow-y:auto;-webkit-overflow-scrolling:touch}
.chat-composer{display:flex;gap:8px;flex:1}
.chat-composer button{min-height:44px}
}
@media (max-width: 768px){.chat-mobile-shell{width:100%;min-height:0;flex:1}
.chat-mobile-shell .chat-layout{display:flex;flex-direction:column;height:var(--app-dvh, 100dvh);min-height:0;gap:0}
.chat-mobile-shell .chat-header{height:auto;max-height:60px;overflow:hidden}
.chat-mobile-shell .chat-messages{flex:1;overflow-y:auto;padding:10px;padding-bottom:calc(84px + env(safe-area-inset-bottom));min-height:0;display:flex;flex-direction:column;gap:.55rem}
.chat-mobile-shell .chat-input{position:sticky;bottom:0;width:100%;background:#fff;z-index:30;border-top:1px solid #e5e7eb;padding-bottom:calc(env(safe-area-inset-bottom) + 2px)}
body.keyboard-open .chat-mobile-shell .chat-header,body.keyboard-open .chat-mobile-shell .filters,body.keyboard-open .chat-mobile-shell .top-actions,body.keyboard-open .chat-mobile-shell .toolbar{display:none!important}
body.keyboard-open .chat-mobile-shell .chat-layout{height:var(--app-dvh, 100dvh)}
body.keyboard-open .chat-mobile-shell .chat-messages{padding-bottom:calc(76px + env(safe-area-inset-bottom) + var(--chat-kb-offset, 0px))}
body.keyboard-open .chat-mobile-shell .chat-input{position:fixed;left:0;right:0;bottom:var(--chat-kb-offset, 0px);width:100%;z-index:45;box-shadow:0 -8px 18px #0f172a1a}
}
@media (max-width: 480px){.chat-page{padding:.75rem}
.chat-header h1{font-size:1.1rem}
.chat-message{max-width:92%}
}
.chat-reply-bar textarea{border-radius:var(--radius-md);border:1px solid #d1d5db;padding:8px 12px;resize:none;font-family:inherit;font-size:16px}
.chat-ai-result{background:#fff;border:1px solid #e5e7eb;border-radius:var(--radius-md);padding:.75rem 1rem;color:#111827;display:flex;flex-direction:column;gap:.5rem}
.chat-ai-result ul{margin:0;padding-left:1.1rem;color:#6b7280;font-size:.85rem}
.chat-message{max-width:min(82%,760px);padding:10px 12px;border-radius:var(--radius-md);background:#eef2f7;border:1px solid #dce3ec;display:flex;flex-direction:column;gap:.4rem;font-size:14px;line-height:1.45}
.chat-product-message{display:flex;gap:10px;align-items:flex-start}
.chat-product-thumb{width:56px;height:56px;object-fit:cover;border-radius:10px;border:1px solid #dbe2ea;background:#f8fafc;flex-shrink:0}
.chat-product-message__content{display:flex;flex-direction:column;gap:2px}
.chat-product-message__content strong{color:#0f172a;font-size:13px;line-height:1.35}
.chat-product-message__content span{color:#475569;font-size:12px}
.chat-product-message__content a{color:#2563eb;font-size:12px;text-decoration:none;font-weight:600}
.chat-product-message__content a:hover{text-decoration:underline}
.chat-message.seller{align-self:flex-end;background:#2563eb;border-color:#1d4ed8;color:#fff}
.chat-message.seller .chat-message-meta,.chat-message.seller .chat-moderation{color:#ffffffd9}
.chat-message-meta{display:flex;justify-content:space-between;font-size:12px;color:#6b7280}
.chat-message.grouped{margin-top:-.45rem;padding-top:4px;padding-bottom:4px}
.chat-message.seller.grouped{margin-top:-.45rem}
.chat-day-separator,.chat-new-marker{display:flex;align-items:center;gap:.75rem;margin:.5rem 0;-webkit-user-select:none;user-select:none}
.chat-day-separator{position:sticky;top:0;z-index:2;background:#fff;padding:4px 0}
.chat-day-separator:before,.chat-day-separator:after,.chat-new-marker:before,.chat-new-marker:after{content:"";flex:1;height:1px;background:#e5e7eb}
.chat-day-separator span,.chat-new-marker span{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.04em;white-space:nowrap;padding:2px 0}
.chat-day-separator span{color:#9ca3af}
.chat-new-marker:before,.chat-new-marker:after{background:#ef4444}
.chat-new-marker span{color:#ef4444}
.chat-moderation{font-size:.7rem;color:#9ca3af}
.chat-composer{display:flex;gap:8px;align-items:flex-end;flex:1}
.chat-composer textarea{flex:1;border-radius:var(--radius-md);border:1px solid #d1d5db;padding:8px 12px;resize:none;font-family:inherit;min-height:36px;max-height:120px;line-height:1.4;font-size:16px}
.chat-composer button{padding:8px 16px;border-radius:var(--radius-md);border:none;background:#2563eb;color:#fff;cursor:pointer;min-height:44px;white-space:nowrap;font-size:14px}
.chat-composer button:active{background:#1d4ed8}
.chat-empty{padding:2rem;text-align:center;color:#9ca3af;display:flex;flex-direction:column;align-items:center;gap:1rem;width:100%}
.chat-empty p{margin:0}
.chat-status{font-size:.7rem;padding:.2rem .45rem;border-radius:var(--radius-full);background:#e5e7eb;color:#6b7280;text-transform:uppercase;letter-spacing:.3px}
.chat-status.opened{background:#dcfce7;color:#15803d}
.chat-status.closed{background:#fee2e2;color:#b91c1c}
.chat-status.pending,.chat-status.waiting,.chat-status.waiting_reply,.chat-status.waiting_answer{background:#fef3c7;color:#b45309}
.chat-status.answered,.chat-status.resolved,.chat-status.done{background:#dbeafe;color:#1d4ed8}
.chat-status.moderated,.chat-status.review,.chat-status.under_review{background:#e0f2fe;color:#0369a1}
.chat-status.cancelled,.chat-status.canceled,.chat-status.failed{background:#fce7f3;color:#be185d}
.chat-company{font-weight:600;color:#111827}
.chat-error-info{font-size:.85rem;color:#d97706;background:#fef3c7;padding:.5rem .75rem;border-radius:var(--radius-sm);margin-top:.5rem;font-family:monospace;word-break:break-word}
.chat-id-info{font-size:.75rem;color:#9ca3af;font-family:monospace;margin-top:.5rem;display:block}
.chat-product{display:flex;flex-direction:column;gap:.25rem;margin-top:.5rem;font-size:.85rem;color:#6b7280}
.chat-product-name{font-weight:600;color:#111827}
.chat-product-sku{font-family:monospace}


.chat-pagination{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px;font-size:12px}
.chat-pagination button,.chat-filters select{border:1px solid #dbe3ee;background:#fff;border-radius:8px;padding:8px 10px;color:#1e40af}
.chat-pagination button:disabled{opacity:.5;cursor:not-allowed}
.chat-item-title small{color:#64748b;font-size:11px}
.chat-pagination button:focus-visible{outline:2px solid #2563eb;outline-offset:2px}

