/* ===== LOGYS LabSystem | /assets/css/chat_logys.css ===== */
/* Estilos aislados del widget de chat. No toca configuracion_tema.php. */

:root {
    --lgs-chat-primary: var(--lgs-primary, #315CF6);
    --lgs-chat-info: var(--lgs-info, #088AB2);
    --lgs-chat-danger: var(--lgs-danger, #D92D20);
    --lgs-chat-success: var(--lgs-success, #079455);
    --lgs-chat-text: var(--lgs-text, #1D2939);
    --lgs-chat-head: var(--lgs-head, #101828);
    --lgs-chat-muted: var(--lgs-muted, #667085);
    --lgs-chat-panel: var(--lgs-panel, #FFFFFF);
    --lgs-chat-panel-2: var(--lgs-panel-2, #F7FAFD);
    --lgs-chat-border: var(--lgs-border, #DCE6F1);
    --lgs-chat-shadow: 0 20px 60px rgba(16, 24, 40, .18);
}

#logysChatConfig { display: none !important; }

.lgs-chat-floating-button,
.lgs-chat-panel,
.lgs-chat-panel * {
    box-sizing: border-box;
}

.lgs-chat-floating-button {
    position: fixed;
    right: 22px;
    bottom: 24px;
    z-index: 1500;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--lgs-chat-primary), var(--lgs-chat-info));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 16px 38px rgba(49, 92, 246, .32);
    transition: transform .18s ease, box-shadow .18s ease;
}

.lgs-chat-floating-button:hover,
.lgs-chat-floating-button.is-active {
    transform: translateY(-2px);
    box-shadow: 0 20px 46px rgba(49, 92, 246, .40);
}

.lgs-chat-floating-button iconify-icon { font-size: 24px; }

.lgs-chat-badge[hidden] {
    display: none !important;
}

.lgs-chat-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--lgs-chat-danger);
    border: 2px solid var(--lgs-chat-panel);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.lgs-chat-panel {
    position: fixed;
    right: 22px;
    bottom: 94px;
    z-index: 1499;
    width: min(660px, calc(100vw - 32px));
    max-height: min(650px, calc(100vh - 130px));
    background: color-mix(in srgb, var(--lgs-chat-panel) 96%, transparent);
    color: var(--lgs-chat-text);
    border: 1px solid var(--lgs-chat-border);
    border-radius: 22px;
    box-shadow: var(--lgs-chat-shadow);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(.985);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.lgs-chat-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.lgs-chat-panel-header {
    min-height: 78px;
    padding: 20px 24px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-top: 4px solid var(--lgs-chat-primary);
    border-bottom: 1px solid var(--lgs-chat-border);
    background: linear-gradient(135deg, color-mix(in srgb, var(--lgs-chat-panel) 94%, #fff), color-mix(in srgb, var(--lgs-chat-panel-2) 86%, var(--lgs-chat-primary)));
}

.lgs-chat-panel-header h3 {
    margin: 0;
    color: var(--lgs-chat-head);
    font-size: 17px;
    line-height: 1.15;
    font-weight: 800;
}

.lgs-chat-panel-header p {
    margin: 7px 0 0;
    color: var(--lgs-chat-muted);
    font-size: 12.5px;
    line-height: 1.35;
}

.lgs-chat-close {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 14px;
    border: 1px solid var(--lgs-chat-border);
    background: var(--lgs-chat-panel-2);
    color: var(--lgs-chat-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lgs-chat-close iconify-icon { font-size: 20px; }

.lgs-chat-panel-body {
    padding: 14px 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(min(650px, calc(100vh - 130px)) - 78px);
    overflow: hidden;
}

.lgs-chat-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    flex: 0 0 auto;
}

.lgs-chat-tabs:not(:has(#logysChatMasivoTab)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lgs-chat-tab,
.lgs-chat-button {
    min-height: 38px;
    border-radius: 13px;
    border: 1px solid var(--lgs-chat-border);
    background: var(--lgs-chat-panel);
    color: var(--lgs-chat-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.lgs-chat-tab:hover,
.lgs-chat-button:hover { transform: translateY(-1px); }

.lgs-chat-tab.is-active,
.lgs-chat-button.primary {
    background: var(--lgs-chat-primary);
    border-color: var(--lgs-chat-primary);
    color: #fff;
    box-shadow: 0 12px 28px rgba(49, 92, 246, .22);
}

.lgs-chat-button.danger {
    color: var(--lgs-chat-danger);
    background: color-mix(in srgb, var(--lgs-chat-danger) 7%, var(--lgs-chat-panel));
    border-color: color-mix(in srgb, var(--lgs-chat-danger) 28%, var(--lgs-chat-border));
}

.lgs-chat-view {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    overflow: hidden;
}

.lgs-chat-view[hidden] { display: none !important; }

.lgs-chat-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex: 0 0 auto;
}

.lgs-chat-toolbar h4 {
    margin: 0;
    color: var(--lgs-chat-head);
    font-size: 14px;
    line-height: 1.2;
    font-weight: 800;
}

.lgs-chat-toolbar p {
    margin: 6px 0 0;
    color: var(--lgs-chat-muted);
    font-size: 12.5px;
    line-height: 1.35;
}

.lgs-chat-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.lgs-chat-list {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    display: grid;
    gap: 9px;
}

#logysChatConversaciones { max-height: 330px; }
#logysChatContactos { max-height: 350px; }

.lgs-chat-list::-webkit-scrollbar,
.lgs-chat-messages::-webkit-scrollbar { width: 8px; }
.lgs-chat-list::-webkit-scrollbar-thumb,
.lgs-chat-messages::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--lgs-chat-muted) 35%, transparent);
    border-radius: 999px;
}

.lgs-chat-row-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: stretch;
}

.lgs-chat-row,
.lgs-chat-thread-contact {
    width: 100%;
    min-width: 0;
    min-height: 66px;
    border: 1px solid var(--lgs-chat-border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--lgs-chat-panel) 96%, var(--lgs-chat-panel-2));
    color: var(--lgs-chat-text);
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    text-align: left;
    cursor: pointer;
}

.lgs-chat-thread-contact {
    cursor: default;
    grid-template-columns: 48px minmax(0, 1fr);
    flex: 0 0 auto;
}

.lgs-chat-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid var(--lgs-chat-border);
    background: var(--lgs-chat-panel-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lgs-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lgs-chat-row-main {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.lgs-chat-row-main strong,
.lgs-chat-thread-contact h4 {
    margin: 0;
    color: var(--lgs-chat-head);
    font-size: 12.8px;
    font-weight: 800;
    line-height: 1.25;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.lgs-chat-row-main span,
.lgs-chat-thread-contact p {
    margin: 0;
    color: var(--lgs-chat-muted);
    font-size: 12px;
    line-height: 1.25;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.lgs-chat-row-main em {
    color: var(--lgs-chat-primary);
    font-size: 11.5px;
    line-height: 1.2;
    font-style: normal;
    font-weight: 800;
}

.lgs-chat-pill {
    border-radius: 999px;
    padding: 5px 8px;
    background: color-mix(in srgb, var(--lgs-chat-info) 12%, var(--lgs-chat-panel));
    color: var(--lgs-chat-info);
    border: 1px solid color-mix(in srgb, var(--lgs-chat-info) 38%, var(--lgs-chat-border));
    font-size: 11px;
    font-weight: 800;
}

.lgs-chat-delete {
    border: 1px solid color-mix(in srgb, var(--lgs-chat-danger) 28%, var(--lgs-chat-border));
    border-radius: 16px;
    background: color-mix(in srgb, var(--lgs-chat-danger) 7%, var(--lgs-chat-panel));
    color: var(--lgs-chat-danger);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lgs-chat-delete iconify-icon { font-size: 17px; }

.lgs-chat-field {
    display: grid;
    gap: 7px;
    flex: 0 0 auto;
}

.lgs-chat-field label {
    color: var(--lgs-chat-head);
    font-size: 12px;
    font-weight: 800;
}

.lgs-chat-field input,
.lgs-chat-field select,
.lgs-chat-field textarea,
.lgs-chat-composer textarea {
    width: 100%;
    border: 1px solid var(--lgs-chat-border);
    border-radius: 13px;
    background: var(--lgs-chat-panel);
    color: var(--lgs-chat-text);
    outline: none;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.35;
    resize: vertical;
}

.lgs-chat-field input:focus,
.lgs-chat-field select:focus,
.lgs-chat-field textarea:focus,
.lgs-chat-composer textarea:focus {
    border-color: var(--lgs-chat-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--lgs-chat-primary) 18%, transparent);
}

.lgs-chat-alert {
    flex: 0 0 auto;
    border-radius: 13px;
    border: 1px solid var(--lgs-chat-border);
    padding: 10px 13px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.35;
}

.lgs-chat-alert.success {
    background: color-mix(in srgb, var(--lgs-chat-success) 12%, var(--lgs-chat-panel));
    color: var(--lgs-chat-success);
    border-color: color-mix(in srgb, var(--lgs-chat-success) 35%, var(--lgs-chat-border));
}

.lgs-chat-alert.error {
    background: color-mix(in srgb, var(--lgs-chat-danger) 10%, var(--lgs-chat-panel));
    color: var(--lgs-chat-danger);
    border-color: color-mix(in srgb, var(--lgs-chat-danger) 35%, var(--lgs-chat-border));
}

.lgs-chat-thread-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.lgs-chat-messages {
    min-height: 190px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--lgs-chat-border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--lgs-chat-panel-2) 70%, var(--lgs-chat-panel));
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.lgs-chat-message {
    display: flex;
    width: 100%;
}

.lgs-chat-message.is-mine { justify-content: flex-end; }
.lgs-chat-message.is-other { justify-content: flex-start; }

.lgs-chat-message-bubble {
    max-width: 78%;
    border-radius: 16px;
    padding: 9px 11px;
    border: 1px solid var(--lgs-chat-border);
    background: var(--lgs-chat-panel);
    color: var(--lgs-chat-text);
}

.lgs-chat-message.is-mine .lgs-chat-message-bubble {
    background: var(--lgs-chat-primary);
    color: #fff;
    border-color: var(--lgs-chat-primary);
}

.lgs-chat-message-bubble p {
    margin: 0;
    font-size: 12.8px;
    line-height: 1.35;
}

.lgs-chat-message-bubble span {
    display: block;
    margin-top: 5px;
    font-size: 10.5px;
    opacity: .78;
}

.lgs-chat-composer {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 9px;
    align-items: stretch;
}

.lgs-chat-composer textarea {
    min-height: 48px;
    max-height: 92px;
    resize: vertical;
}

.lgs-chat-actions {
    display: flex;
    justify-content: flex-end;
}

.lgs-chat-empty {
    min-height: 132px;
    border: 1px dashed color-mix(in srgb, var(--lgs-chat-primary) 35%, var(--lgs-chat-border));
    border-radius: 16px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    padding: 20px;
    text-align: center;
    color: var(--lgs-chat-muted);
}

.lgs-chat-empty strong {
    color: var(--lgs-chat-head);
    font-size: 13px;
}

.lgs-chat-empty span {
    max-width: 360px;
    font-size: 12.5px;
    line-height: 1.35;
}

.lgs-chat-empty.error strong,
.lgs-chat-empty.error span { color: var(--lgs-chat-danger); }

@media (max-width: 760px) {
    .lgs-chat-panel {
        inset: auto 10px 82px 10px;
        width: auto;
        max-height: calc(100vh - 105px);
        border-radius: 18px;
    }

    .lgs-chat-panel-header { padding: 16px 18px 13px; }
    .lgs-chat-panel-body { padding: 12px 16px 16px; max-height: calc(100vh - 185px); }
    .lgs-chat-tabs { grid-template-columns: 1fr; }
    .lgs-chat-tabs:not(:has(#logysChatMasivoTab)) { grid-template-columns: 1fr; }
    .lgs-chat-toolbar { flex-direction: column; }
    .lgs-chat-toolbar-actions { width: 100%; justify-content: stretch; }
    .lgs-chat-toolbar-actions .lgs-chat-button { flex: 1 1 auto; }
    .lgs-chat-composer { grid-template-columns: 1fr; }
    .lgs-chat-row-wrap { grid-template-columns: minmax(0, 1fr) 40px; }
    .lgs-chat-row { grid-template-columns: 44px minmax(0, 1fr); }
    .lgs-chat-pill { display: none; }
    .lgs-chat-floating-button { right: 16px; bottom: 16px; }
}
