.public-chat-widget {
    bottom: 22px;
    display: grid;
    justify-items: end;
    position: fixed;
    right: 22px;
    z-index: 1200;
}

.public-chat-launcher {
    align-items: center;
    background: linear-gradient(145deg, #078575, #006b61);
    border: 0;
    border-radius: 50%;
    box-shadow: 0 14px 35px rgba(0, 107, 97, .3);
    color: #fff;
    display: flex;
    font-size: 22px;
    height: 58px;
    justify-content: center;
    position: relative;
    transition: transform .18s ease, box-shadow .18s ease;
    width: 58px;
}

.public-chat-launcher:hover { box-shadow: 0 16px 40px rgba(0, 107, 97, .4); transform: translateY(-2px); }
.public-chat-launcher > span { align-items: center; background: #e44754; border: 2px solid #fff; border-radius: 20px; display: flex; font-size: 10px; font-weight: 800; height: 20px; justify-content: center; min-width: 20px; padding: 0 4px; position: absolute; right: -2px; top: -2px; }

.public-chat-panel {
    background: #fff;
    border: 1px solid #dce9e7;
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(23, 57, 67, .24);
    display: grid;
    grid-template-rows: auto minmax(220px, 1fr) auto auto;
    height: min(590px, calc(100vh - 115px));
    margin-bottom: 12px;
    overflow: hidden;
    width: min(380px, calc(100vw - 28px));
}

.public-chat-panel > header { align-items: center; background: linear-gradient(135deg, #087f73, #00655f); color: #fff; display: flex; gap: 11px; min-height: 70px; padding: 13px 14px; }
.public-chat-panel > header > div { display: grid; flex: 1; line-height: 1.15; }
.public-chat-panel > header strong { font-size: 15px; }
.public-chat-panel > header small { align-items: center; display: flex; font-size: 11px; gap: 5px; margin-top: 6px; opacity: .82; }
.public-chat-panel > header small i { background: #5ee1a1; border-radius: 50%; height: 7px; width: 7px; }
.public-chat-panel > header button { background: rgba(255,255,255,.14); border: 0; border-radius: 8px; color: #fff; height: 34px; width: 34px; }
.public-chat-avatar { align-items: center; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.2); border-radius: 50%; display: flex; flex: 0 0 42px; font-size: 18px; height: 42px; justify-content: center; }

.public-chat-messages { background: #f5f9f8; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 16px 14px; }
.public-chat-welcome { background: #e7f4f1; border: 1px solid #cce7e2; border-radius: 12px; color: #365e59; display: grid; font-size: 12px; gap: 3px; margin-bottom: 4px; padding: 11px 12px; }
.public-chat-welcome strong { color: #126b62; font-size: 13px; }
.public-chat-message { align-self: flex-start; display: grid; max-width: 84%; }
.public-chat-message.is-mine { align-self: flex-end; justify-items: end; }
.public-chat-message small { color: #69827e; font-size: 10px; margin: 0 0 3px 8px; }
.public-chat-message > div { background: #fff; border: 1px solid #dfe9e7; border-radius: 5px 14px 14px 14px; color: #294946; font-size: 13px; line-height: 1.45; padding: 9px 11px; white-space: pre-wrap; word-break: break-word; }
.public-chat-message.is-mine > div { background: #087b70; border-color: #087b70; border-radius: 14px 5px 14px 14px; color: #fff; }
.public-chat-message.is-bot > div { background: #e8f5f2; border-color: #c6e5df; color: #235b54; }
.public-chat-message.is-bot small { color: #087b70; font-weight: 700; }
.public-chat-message time { color: #8a9c99; font-size: 9px; margin-top: 3px; padding: 0 4px; }
.public-chat-typing { align-items: center; align-self: flex-start; background: #fff; border: 1px solid #dfe9e7; border-radius: 14px; color: #66817c; display: flex; font-size: 11px; gap: 7px; padding: 9px 12px; }
.public-chat-state { color: #69827e; font-size: 12px; margin: auto; }
.public-chat-error { background: #fff2f2; border-top: 1px solid #f4d7d7; color: #a43e46; font-size: 11px; padding: 7px 13px; }
.public-chat-panel > footer { align-items: center; background: #fff; border-top: 1px solid #e2ecea; display: flex; gap: 8px; padding: 11px; }
.public-chat-panel > footer input { background: #f5f8f8; border: 1px solid #dce7e5; border-radius: 22px; color: #294946; flex: 1; font-size: 13px; height: 42px; outline: none; padding: 0 15px; }
.public-chat-panel > footer input:focus { border-color: #61aaa1; box-shadow: 0 0 0 3px rgba(8,123,112,.08); }
.public-chat-panel > footer button { align-items: center; background: #087b70; border: 0; border-radius: 50%; color: #fff; display: flex; flex: 0 0 42px; height: 42px; justify-content: center; }
.public-chat-panel > footer button:disabled { opacity: .5; }

.chat-admin-page { margin: 0 auto; max-width: 1500px; padding: 26px 24px 40px; }
.chat-admin-heading { align-items: end; display: flex; gap: 20px; justify-content: space-between; margin-bottom: 20px; }
.chat-admin-heading > div:first-child > span { color: #0c8075; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.chat-admin-heading h1 { color: #173d4a; font-size: 28px; margin: 4px 0; }
.chat-admin-heading p { color: #728994; margin: 0; }
.chat-admin-summary { align-items: center; display: flex; gap: 10px; }
.chat-admin-summary > div { background: #fff; border: 1px solid #dce8eb; border-radius: 10px; display: grid; min-width: 84px; padding: 8px 12px; }
.chat-admin-summary small { color: #81949d; font-size: 10px; text-transform: uppercase; }
.chat-admin-summary strong { color: #126f68; font-size: 19px; }

.chat-admin-shell { background: #fff; border: 1px solid #dce8eb; border-radius: 14px; box-shadow: 0 13px 35px rgba(31,74,89,.07); display: grid; grid-template-columns: 350px minmax(0,1fr); height: calc(100vh - 205px); min-height: 560px; overflow: hidden; }
.chat-admin-inbox { border-right: 1px solid #e1eaed; display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.chat-admin-inbox > header { align-items: center; border-bottom: 1px solid #e4ecee; color: #254c59; display: flex; justify-content: space-between; min-height: 59px; padding: 0 16px; }
.chat-admin-inbox > header span { background: #e6f2f1; border-radius: 20px; color: #08766e; font-size: 11px; font-weight: 800; padding: 3px 8px; }
.chat-admin-conversations { overflow-y: auto; }
.chat-admin-conversation { align-items: center; background: #fff; border: 0; border-bottom: 1px solid #edf2f3; color: inherit; display: flex; gap: 10px; min-height: 82px; padding: 11px 13px; position: relative; text-align: left; width: 100%; }
.chat-admin-conversation:hover, .chat-admin-conversation.is-active { background: #edf7f6; }
.chat-admin-conversation.needs-human { background: #fff9eb; }
.chat-admin-conversation.needs-human:hover, .chat-admin-conversation.needs-human.is-active { background: #fff3d2; }
.chat-admin-conversation.is-active::before { background: #087b70; bottom: 0; content: ""; left: 0; position: absolute; top: 0; width: 3px; }
.chat-admin-conversation-avatar { align-items: center; background: #dbeeed; border-radius: 50%; color: #08756c; display: flex; flex: 0 0 42px; font-size: 13px; font-weight: 800; height: 42px; justify-content: center; }
.chat-admin-conversation-body { display: grid; flex: 1; min-width: 0; position: relative; }
.chat-admin-conversation-body strong { color: #294e59; font-size: 13px; overflow: hidden; padding-right: 38px; text-overflow: ellipsis; white-space: nowrap; }
.chat-admin-conversation-body strong i { color: #0a8a7d; font-size: 10px; }
.chat-admin-conversation-body small { color: #788d95; font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-admin-workflow { font-size: 9px; font-weight: 700; margin-top: 3px; }
.chat-admin-workflow.mode-bot { color: #087b70; }
.chat-admin-workflow.mode-waiting_human { color: #b36a00; }
.chat-admin-workflow.mode-human { color: #3869a8; }
.chat-admin-conversation-body time { color: #9aa9ae; font-size: 9px; position: absolute; right: 0; top: 1px; }
.chat-admin-conversation > b { align-items: center; background: #e34e59; border-radius: 20px; color: #fff; display: flex; font-size: 9px; height: 19px; justify-content: center; min-width: 19px; padding: 0 4px; }

.chat-admin-thread { display: grid; grid-template-rows: auto auto 1fr auto; min-width: 0; }
.chat-admin-thread > header { align-items: center; border-bottom: 1px solid #e3ecee; display: flex; justify-content: space-between; min-height: 65px; padding: 10px 17px; }
.chat-admin-thread > header > div { align-items: center; display: flex; gap: 10px; }
.chat-admin-thread > header > div > span:last-child { display: grid; }
.chat-admin-thread > header strong { color: #294e59; font-size: 14px; }
.chat-admin-thread > header small { font-size: 10px; margin-top: 3px; }
.chat-admin-thread > header small.status-open { color: #15806d; }
.chat-admin-thread > header small.status-closed { color: #87969a; }
.chat-admin-thread-actions { display: flex; gap: 8px; }
.chat-admin-handoff { align-items: center; background: #fff6dc; border-bottom: 1px solid #efdca6; color: #70541b; display: flex; font-size: 11px; gap: 10px; grid-row: 2; padding: 9px 18px; }
.chat-admin-handoff > i { color: #ba7600; font-size: 18px; }
.chat-admin-handoff > span { display: grid; }
.chat-admin-handoff strong { color: #8a5800; font-size: 11px; }
.chat-admin-messages { background: #f4f8f8; display: flex; flex-direction: column; gap: 12px; grid-row: 3; overflow-y: auto; padding: 20px; }
.chat-admin-message { align-self: flex-start; display: grid; max-width: 68%; }
.chat-admin-message.is-user { align-self: flex-end; justify-items: end; }
.chat-admin-message small { color: #748b91; font-size: 10px; margin: 0 7px 3px; }
.chat-admin-message > div { background: #fff; border: 1px solid #dfe8ea; border-radius: 5px 14px 14px 14px; color: #294850; font-size: 13px; line-height: 1.5; padding: 10px 13px; white-space: pre-wrap; word-break: break-word; }
.chat-admin-message.is-user > div { background: #087a71; border-color: #087a71; border-radius: 14px 5px 14px 14px; color: #fff; }
.chat-admin-message.is-bot > div { background: #e4f3f0; border-color: #c5e1dc; color: #245c55; }
.chat-admin-message.is-bot small { color: #087a71; font-weight: 700; }
.chat-admin-message time { color: #91a0a5; font-size: 9px; margin-top: 3px; padding: 0 5px; }
.chat-admin-thread > footer { align-items: center; border-top: 1px solid #e1eaec; display: flex; gap: 10px; grid-row: 4; padding: 12px 15px; }
.chat-admin-thread > footer input { background: #f7f9f9; border: 1px solid #d8e4e6; border-radius: 8px; flex: 1; font-size: 13px; height: 42px; outline: none; padding: 0 13px; }
.chat-admin-thread > footer input:focus { border-color: #67aaa4; }
.chat-admin-thread > footer button { background: #087a71; border: 0; border-radius: 8px; color: #fff; font-size: 12px; font-weight: 700; height: 42px; padding: 0 17px; }
.chat-admin-thread > footer button:disabled { opacity: .5; }
.chat-admin-empty { align-items: center; color: #899ba1; display: flex; flex-direction: column; gap: 9px; justify-content: center; min-height: 180px; padding: 20px; text-align: center; }
.chat-admin-empty > i { color: #b8cacd; font-size: 34px; }
.chat-admin-empty.is-thread { height: 100%; }

@media (max-width: 900px) {
    .chat-admin-page { padding: 18px 12px 30px; }
    .chat-admin-heading { align-items: flex-start; flex-direction: column; }
    .chat-admin-summary { flex-wrap: wrap; }
    .chat-admin-shell { grid-template-columns: 290px minmax(0,1fr); }
}

@media (max-width: 680px) {
    .public-chat-widget { bottom: 13px; right: 13px; }
    .public-chat-panel { border-radius: 15px; height: calc(100vh - 92px); width: calc(100vw - 26px); }
    .public-chat-launcher { height: 54px; width: 54px; }
    .chat-admin-shell { display: block; height: auto; min-height: 0; overflow: visible; }
    .chat-admin-inbox { border-bottom: 1px solid #e1eaed; border-right: 0; max-height: 330px; }
    .chat-admin-thread { height: 620px; }
    .chat-admin-message { max-width: 86%; }
}
