/* ==========================================================================
SETTINGS & GLOBALS
========================================================================== */

:root {
	--chat-font-family: Lato, Arial, sans-serif !important;
	
	/* Colors */
	--chat-background-color: #ffffff;
	--chat-border-color: #ADB5BD;
	--chat-separator-color: #CFD4DA;
	--chat-primary-text-color: #131518;
	--chat-secondary-text-color: #868E96;
	--chat-header-background-color: #DEE2E6;
	--chat-toolbar-background-color: #F8F9FA;
	--chat-message-background-color: #EAEDEF;
	--chat-message-outgoing-background-color: #CEDCD0;
	--chat-message-bg-background-color: #FFFFFF;
	--chat-readreceipt-background-color: #0A4F16;
	--chat-readreceipt-text-color: #FFFFFF;
	--chat-composer-button-background-colour: #0A4F16;
	--chat-scrollbar-color: transparent transparent;
	--chat-hover-scrollbar-color: #EAEDEF transparent;

	/* Sizing & Spacing */
	--chat-popup-maximised-height: 400px;
	--chat-popup-minimised-height: 50px;
	--chat-popup-width: 400px;
	--chat-spacing-tiny: 4px;
	--chat-spacing-small: 8px;
	--chat-spacing-medium: 12px;
	--chat-spacing-large: 16px;
	--chat-border-radius: 0;
	--chat-header-height: 48px;
	--chat-composer-height: 60px;
	--chat-toolbar-height: 40px;

	/* Effects */
	--chat-box-shadow: 2px 2px 27px -13px #000000;
	--chat-transition-speed: 0.2s;
}

.chat-template {
	display: none !important;
}

.startmessage {
    cursor: pointer;
}

/* ==========================================================================
MAIN CHAT WINDOW COMPONENT (.chat-popup / .conversation-window)
========================================================================== */

.chat-popup { /* Also known as .conversation-window in the JS */
	position: fixed;
	bottom: 90px;
	right: 20px;
	width: var(--chat-popup-width);
	max-width: calc(100% - 20px);
	height: var(--chat-popup-maximised-height);
	background-color: var(--chat-background-color);
	border-radius: var(--chat-border-radius);
	box-shadow: var(--chat-box-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transition: opacity var(--chat-transition-speed) ease, transform var(--chat-transition-speed) ease;
}

/* --- Window States --- */

.chat-popup.minimized { 
	height: var(--chat-popup-minimised-height);
	transition:all 0.5s; 
}

.chat-popup.maximized { 
	height: var(--chat-popup-maximised-height);
	transition:all 0.5s; 
}

.chat_window_control .close_button::after {
	content: none;
}

.chat_window_control .minmax_button {
	margin: 5px;
}

.chat_window_control {
	display: flex;
	align-items: flex-start;
	flex-direction: row;
}

.maximized .minmax_button .maximize,
.minimized .minmax_button .minimize {
	display: none;
}

.chat-popup.minimized .chat-popup, 
.chat-popup.minimized .chat_send_control { display: none; }

.chat-popup--closed {
	opacity: 0;
	transform: translateY(10px);
	pointer-events: none;
}

.conversation-window.ui-resizable-resizing {
	transition: none !important;
}

.is-shaking {
	animation: shake 0.6s;
	animation-delay: 50ms; 
}

@keyframes shake {
	10%, 90% { transform: translateX(-1px); }
	20%, 80% { transform: translateX(2px); }
	30%, 50%, 70% { transform: translateX(-4px); }
	40%, 60% { transform: translateX(4px); }
}


/* ==========================================================================
HEADER COMPONENT (.chat-header)
========================================================================== */

.chat-header {
	display: flex;
	align-items: center;
	/* flex-shrink: 0; */
	padding: var(--chat-spacing-large) var(--chat-spacing-tiny) var(--chat-spacing-large) var(--chat-spacing-large);
	border-bottom: 1px solid var(--chat-separator-color);
	background-color: var(--chat-header-background-color);
	height: var(--chat-header-height);
}

.chat-header__title {
	font-weight: bold;
	font-size: 16px;
	margin: 0;
	color: var(--chat-primary-text-color);
	height: 24px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	/* width: calc(100% - 70px); */
}
.chat-header__title-container {
	width: 100%;
	flex-grow: 1;
	min-width: 0;
}

.chat-header__title-container div {
	display: flex;
	width: 100%;
}

.chat-header__title-input {
	width: 100%;
	font-size: 16px;
	height: 32px;
	border: 1px solid var(--chat-border-color);
	border-radius: 4px;
	padding: 0 9px;
}

.chat-header__display-view {
	display: flex;
	align-items: center;
}

.chat-header__edit-view {
	width: 100%;
}

.chat-header__info {
	flex-grow: 1;
}

.chat-header__info .conversation_id {
	display: none;
}

.chat-header__title {
	font-weight: bold;
	font-size: 16px;
	margin: 0;
	color: var(--chat-primary-text-color);
}

.chat-header__status {
	font-size: 12px;
	color: var(--chat-secondary-text-color);
}

.chat-header__rename-btn {
	margin-left: var(--chat-spacing-small);
	flex-shrink: 0;
}

.chat-header__confirm-btn, 
.chat-header__cancel-btn {
	margin-left: var(--chat-spacing-small);
}

.chat-header__avatar,
.chat-header__info,
.chat-header__actions {
	flex-shrink: 0;
	width: 20px;
}

/* ==========================================================================
Chat Toolbar Block
========================================================================== */

.chat-toolbar {
	background-color: var(--chat-toolbar-background-color);
	color: var(--chat-secondary-text-color);
	flex-shrink: 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: var(--chat-spacing-small) var(--chat-spacing-large);
	border-bottom: 1px solid var(--chat-border-color);
	height: var(--chat-toolbar-height);
	box-shadow: 0 10px 10px 0 #fff;
	z-index: 1;
}

.translation-switch {
	display: none;
}

/* ==========================================================================
TRANSCRIPT & MESSAGE COMPONENTS
========================================================================== */

.chat-transcript {
	flex-grow: 1;
	overflow-y: auto;
	position: relative;
	scrollbar-width: thin;
	scrollbar-color: var(--chat-scrollbar-color);
}

.chat-transcript:hover {
	scrollbar-color: var(--chat-hover-scrollbar-color);
}

.chat-transcript.loading {
	background-image: url(../images/skins/sa/file-loading.gif);
	background-position: 50% 50%;
	background-repeat: no-repeat;
}

.chat-transcript__list {
	display: flex;
	flex-direction: column;
	list-style: none;
	padding: var(--chat-spacing-large);
	margin: 0;
}

.message-container {
	position: relative;
}

.message {
	display: flex;
	margin-bottom: 10px;
	flex-direction: column;
}

.message-bubble {
	display: flex;
	flex-direction: row;
}

.message.outgoing .message-bubble {
	justify-content: end;
}

.message-content-wrapper {
	max-width: 80%;
	display: flex;
	flex-direction: column;
}

.message .message-text {
	background-color: var(--chat-message-background-color);
	color: var(--chat-primary-text-color);
	padding: 10px;
	border-radius: 10px;
	word-wrap: break-word;
	white-space: break-spaces;
}

.message.outgoing .message-text {
	background-color: var(--chat-message-outgoing-background-color);
	color: var(--chat-primary-text-color);
}

.message-metadata {
	font-size: 12px;
	color: var(--chat-secondary-text-color);
	margin-bottom: 5px;
}

.message.outgoing .message-metadata {
	text-align: right;
}

.message-metadata .message_id {
	display:none; 
}

.sender {
	font-weight: bold;
	margin-right: 20px;
	color: var(--chat-primary-text-color);
}

.outgoing .sender {
	display: none;
}

.sending .message-text { 
	opacity: 0.25; 
}

/* --- Translation Styles --- */
/* --- Default State (Translations OFF) --- */

/* By default, the original text is styled as the "foreground" */
.message-untranslated {
    background-color: var(--chat-message-background-color);
    color: var(--chat-primary-text-color);
    position: relative;
}
.outgoing .message-untranslated {
    background-color: var(--chat-message-outgoing-background-color);
}

/* And the translated text is hidden */
.message-translated {
    display: none;
}


/* --- Active State (Translations ON) --- */
/* This block activates when the parent window has the .show-translations class */

/* The original text is now styled as the "background" */
.conversation-window.show-translations .message-untranslated {
    background: var(--chat-background-color);
    border: 1px solid var(--chat-separator-color);
    color: var(--chat-secondary-text-color);
    position: relative;
    left: -5px;
    top: 5px;
}

/* The translated text becomes visible and is styled as the "foreground" */
.conversation-window.show-translations .message-translated {
    display: block;
    background-color: var(--chat-message-background-color);
    color: var(--chat-primary-text-color);
    position: relative;
}
.conversation-window.show-translations .outgoing .message-translated {
    background-color: var(--chat-message-outgoing-background-color);
}

/* --- Read Receipt Styles --- */
.read_receipts {
	display: flex;
	flex-direction: row;
	align-items: flex-end;
	flex-wrap: wrap;
}
.message.outgoing .read_receipts {
	order:-1;
	padding-right: 10px;
}
.read_receipts .readreceipt {
	/* display: none; */
}
.read_receipts .readreceipt:last-child {
	display: inline-block;
}
span.readreceipt {
	/* These seem to conflict with the rule above, you may want to consolidate */
	/* display: none;  */
	background: var(--chat-readreceipt-background-color);
	border-radius: 20px;
	font-size: 10px;
	color: var(--chat-readreceipt-text-color);
	margin: 10px 1px;
	padding: 3px;
	height: 20px;
	min-width: 20px;
	text-align: center;
	cursor: default;
}

.system .read_receipts {
    display: none;
}

.system .message-metadata {
	text-align: center;
}

.system .message-text,
.system .message-translated {
	background: none !important;
	padding: 0;
	font-size: 11px;
}

.system .message-content-wrapper {
	width: 100%;
	max-width: 100%;
	text-align: center;
}

.show-translations .system .message-untranslated {
	display: none;
}


/* ==========================================================================
COMPOSER COMPONENT (.chat-composer)
========================================================================== */

.chat-composer {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	padding: var(--chat-spacing-medium);
	background-color: #fff;
	position: relative;
	height: var(--chat-composer-height);
	box-shadow: 0 -10px 10px 0 #fff;
	z-index: 1;
}

.chat-composer__input {
	width: 100%;
	position: absolute;
	left: 0;
	top: 0;
	border: 1px solid #ddd;
	box-sizing: border-box;
	resize: none;
	border-radius: 4px;
	height: 40px;
}

.chat-composer__send-button {
	width: 40px;
	position: absolute;
	right: 16px;
	top: 5px;
	height: 40px;
	border: 1px solid #ddd;
	font-size: x-small;
	font-weight: bold;
	color: var(--chat-secondary-text-color);
	text-shadow: 1px 1px 1px #fff;
	background: var(--chat-composer-button-background-colour);
	border-radius: 4px;
}
.chat-composer__send-button:hover {
	opacity: 0.9;
}


/* ==========================================================================
MISCELLANEOUS COMPONENTS
========================================================================== */

/* --- Kebab Menu --- */
.kebab-menu {
	position: relative;
}
.kebab-toggle {
	background: none;
	border: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	padding: 0 10px;
}
.kebab-toggle.active {
	background: var(--chat-header-background-color);
}

.kebab-dropdown {
	position: absolute;
	top: 24px;
	right: 0;
	background-color: white;
	border: 1px solid #ccc;
	border-radius: 4px;
	box-shadow: 0 2px 5px rgba(0,0,0,0.1);
	z-index: 100;
	width: 260px;
}
.kebab-dropdown ul {
	list-style: none;
	margin: 0;
	padding: 0;
}
.kebab-dropdown li a {
	display: block;
	padding: 8px 15px;
	color: var(--chat-primary-text-color);
	text-decoration: none;
	border-bottom: 1px solid var(--chat-separator-color);
}

.kebab-dropdown li:last-child a {
	border-bottom: none;
}

.kebab-dropdown li a:hover {
	background-color: var(--chat-toolbar-background-color)
}

/* --- New Messages Indicator --- */
.new-messages-indicator {
	position: absolute;
	bottom: 55px;
	padding: 8px;
	background-color: var(--chat-background-color);
	color: #ADB5BD;
	color: var(--chat-border-color);
	cursor: pointer;
	z-index: 10;
	font-size: 12px;
	width: 100%;
	text-align: center;
	border-top: var(--chat-header-background-color);
	margin: 0;
	opacity: 0.75;
}