/**
 * Thimpress AI — Copy Dropdown styles
 *
 * Styles for the Copy URL / Copy as Markdown dropdown
 * injected into DocsPress single page headers.
 * Matches the GitBook "Ask" premium aesthetic.
 *
 * @package thimpress-ai
 */

/* ---------------------------------------------------------------
 * Wrapper
 * --------------------------------------------------------------- */
.tpai-copy-wrapper {
	position: relative;
	display: inline-flex;
	align-items: center;
	vertical-align: middle;
}

/* Header Positioning */
.entry-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 16px;
}

.tpai-header-actions {
	margin-left: auto;
}

/* ---------------------------------------------------------------
 * Split trigger button (AI icon + "Ask" | chevron)
 * --------------------------------------------------------------- */
.tpai-copy-trigger {
	display: inline-flex;
	align-items: stretch;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	background: #fff;
	color: #4b5563;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.2;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	overflow: hidden;
	transition: border-color 0.2s ease;
}

.tpai-copy-trigger:hover {
	border-color: #d1d5db;
}

/* Main clickable area: icon + "Ask" label */
.tpai-trigger-main {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 10px;
	border: none;
	background: transparent;
	color: inherit;
	font-size: inherit;
	font-weight: inherit;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.tpai-trigger-main:hover {
	background: #f3f4f6;
	color: #111827;
}

/* Divider */
.tpai-trigger-chevron {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 4px 7px;
	border: none;
	border-left: 1px solid #e5e7eb;
	background: transparent;
	color: #9ca3af;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.tpai-trigger-chevron:hover,
.tpai-open .tpai-trigger-chevron {
	background: #f3f4f6;
	color: #4b5563;
}

.tpai-trigger-chevron .tpai-chevron {
	transition: transform 0.2s ease;
}

.tpai-open .tpai-trigger-chevron .tpai-chevron {
	transform: rotate(180deg);
}

/* ---------------------------------------------------------------
 * Dropdown menu
 * --------------------------------------------------------------- */
.tpai-copy-menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	min-width: 280px;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 12px;
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
	padding: 8px;
	z-index: 99999;
	opacity: 0;
	transform: translateY(-10px);
	pointer-events: none;
	transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tpai-open .tpai-copy-menu {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

/* ---------------------------------------------------------------
 * Menu items
 * --------------------------------------------------------------- */
.tpai-copy-item {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	width: 100%;
	padding: 10px 12px;
	border: none;
	border-radius: 8px;
	background: transparent;
	text-align: left;
	cursor: pointer;
	transition: background 0.15s ease;
}

.tpai-copy-item:hover,
.tpai-copy-item:focus {
	background: #f3f4f6;
	outline: none;
}

/* Icons in items */
.tpai-copy-item svg {
	flex-shrink: 0;
	margin-top: 3px;
	color: #6b7280;
	transition: color 0.15s ease;
}

/* Close button specific */
.tpai-item-close {
	color: #9ca3af;
}

.tpai-item-close:hover {
	background: #fef2f2 !important;
	color: #dc2626 !important;
}

.tpai-item-close:hover svg {
	color: #dc2626 !important;
}

.tpai-item-content {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tpai-item-title {
	font-weight: 600;
	color: #111827;
	font-size: 14px;
	line-height: 1.4;
}

.tpai-item-desc {
	font-size: 12px;
	color: #6b7280;
	line-height: 1.4;
}

/* Separator */
.tpai-menu-sep {
	height: 1px;
	background: #f3f4f6;
	margin: 8px 12px;
}

/* Copied state */
.tpai-copy-item.tpai-copied {
	background: #059669 !important;
	color: #fff !important;
}

.tpai-copy-item.tpai-copied .tpai-item-title,
.tpai-copy-item.tpai-copied .tpai-item-desc,
.tpai-copy-item.tpai-copied svg {
	color: #fff !important;
}

/* ===============================================================
 * Chat Panel — ThimPress Assistant
 * =============================================================== */

/* Overlay (full viewport, semi-transparent) */
.tpai-chat-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: rgba(0, 0, 0, 0.25);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.tpai-chat-overlay.tpai-chat-visible {
	opacity: 1;
}

/* Slide-in panel */
.tpai-chat-panel {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 380px;
	max-width: 96vw;
	background: #fff;
	border-left: 1px solid #e5e7eb;
	box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
	overflow: hidden;
}

.tpai-chat-visible .tpai-chat-panel {
	transform: translateX(0);
}

/* ---------------------------------------------------------------
 * Header
 * --------------------------------------------------------------- */
.tpai-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid #f3f4f6;
	flex-shrink: 0;
}

.tpai-chat-header-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	font-size: 15px;
	color: #111827;
}

.tpai-chat-header-actions {
	display: flex;
	align-items: center;
	gap: 6px;
}

.tpai-chat-new,
.tpai-chat-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: 1px solid #f3f4f6;
	border-radius: 8px;
	background: #fff;
	color: #64748b;
	cursor: pointer;
	padding: 0;
	transition: all 0.2s ease;
}

.tpai-chat-new:hover,
.tpai-chat-close:hover {
	background: #f8fafc;
	color: #1e293b;
	border-color: #e2e8f0;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.tpai-chat-close:hover {
	color: #ef4444;
	/* red for close hover */
}

/* ---------------------------------------------------------------
 * Body (scrollable)
 * --------------------------------------------------------------- */
.tpai-chat-body {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 24px;
}

/* Greeting */
.tpai-chat-greeting {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	text-align: center;
	padding-top: 24px;
}

.tpai-chat-greeting-icon {
	width: 80px;
	height: 80px;
	border-radius: 50%;
	background: #f3f4f6;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #6b7280;
}

.tpai-chat-greeting-title {
	font-size: 20px;
	font-weight: 700;
	color: #111827;
	margin: 0;
}

.tpai-chat-greeting-sub {
	font-size: 13px;
	color: #6b7280;
	line-height: 1.6;
	margin: 0;
}

.tpai-chat-greeting-sub em {
	font-style: normal;
	font-weight: 500;
	color: #374151;
}

/* Suggestion chips */
.tpai-chat-suggestions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
}

.tpai-suggestion {
	padding: 10px 16px;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	background: #fff;
	color: #374151;
	font-size: 13px;
	font-family: inherit;
	cursor: pointer;
	text-align: left;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.tpai-suggestion:hover {
	background: #f9fafb;
	border-color: #d1d5db;
	color: #111827;
}

/* ---------------------------------------------------------------
 * Footer (input)
 * --------------------------------------------------------------- */
.tpai-chat-footer {
	padding: 12px 16px 16px;
	border-top: 1px solid #f3f4f6;
	flex-shrink: 0;
}

.tpai-chat-input-row {
	display: flex;
	align-items: center;
	gap: 8px;
	border: none;
	border-radius: 10px;
	padding: 8px 12px;
	background: #fff;
	transition: background 0.2s ease;
}

.tpai-chat-input-row:focus-within {
	background: #f9fafb;
}

.tpai-chat-input {
	flex: 1;
	border: none;
	outline: none;
	font-size: 13px;
	font-family: inherit;
	color: #111827;
	background: transparent;
	resize: none;
	height: auto;
	min-height: 20px;
	padding: 2px 0;
	line-height: 1.5;
	transition: height 0.1s ease;
}

.tpai-chat-input::placeholder {
	color: #9ca3af;
}

.tpai-chat-send {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 5px 10px;
	border: none;
	border-radius: 6px;
	background: #6366f1;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: background 0.15s ease;
	flex-shrink: 0;
}

.tpai-chat-send:hover {
	background: #4f46e5;
}

.tpai-chat-footer-note {
	font-size: 11px;
	color: #9ca3af;
	text-align: center;
	margin: 8px 0 0;
}

/* ---------------------------------------------------------------
 * Chat Messages
 * --------------------------------------------------------------- */
.tpai-messages {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 0 0 4px;
	width: 100%;
}

.tpai-msg {
	width: auto;
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.6;
	word-break: break-word;
	white-space: pre-wrap;
	position: relative;
}

.tpai-msg-user {
	align-self: flex-end;
	background: #6366f1;
	color: #fff;
	border-bottom-right-radius: 4px;
}

.tpai-msg-assistant {
	align-self: stretch;
	max-width: 100%;
	background: transparent;
	color: #111827;
	border-radius: 0;
	padding: 0;
	margin-bottom: 8px;
	border-bottom: 1px solid #f3f4f6;
}

.tpai-msg-assistant a {
	color: #2563eb;
	/* Blue 600 */
	text-decoration: none;
	font-weight: 500;
	transition: color 0.15s ease;
}

.tpai-msg-assistant a:hover {
	color: #1e40af;
	/* Blue 800 */
	text-decoration: underline;
}

.tpai-msg-assistant:last-child {
	border-bottom: none;
}

/* Bubble Copy Button */
.tpai-bubble-copy {
	position: absolute;
	top: 12px;
	right: 0;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: transparent;
	color: #9ca3af;
	cursor: pointer;
	border-radius: 4px;
	opacity: 0;
	transition: all 0.2s ease;
}

.tpai-msg-assistant:hover .tpai-bubble-copy {
	opacity: 1;
}

.tpai-bubble-copy:hover {
	background: #e5e7eb;
	color: #4b5563;
}

.tpai-bubble-copy.tpai-copied {
	color: #059669;
}


/* Typing indicator (three animated dots) */
.tpai-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
}

.tpai-typing span {
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #9ca3af;
	animation: tpai-bounce 1.2s infinite;
}

.tpai-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.tpai-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes tpai-bounce {

	0%,
	80%,
	100% {
		transform: translateY(0);
		opacity: 0.5;
	}

	40% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

/* ---------------------------------------------------------------
 * Markdown Formatting inside Assistant Messages
 * --------------------------------------------------------------- */
.tpai-msg-assistant strong {
	font-weight: 600;
	color: #111827;
}

.tpai-msg-assistant em {
	font-style: italic;
}

.tpai-msg-assistant code {
	background-color: #f1f5f9;
	color: #db2777;
	padding: 2px 4px;
	border-radius: 4px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 0.85em;
}

.tpai-msg-assistant pre {
	background-color: #1e293b;
	color: #f8fafc;
	padding: 12px;
	border-radius: 8px;
	overflow-x: auto;
	margin: 8px 0;
	font-size: 0.85em;
	line-height: 1.5;
}

.tpai-msg-assistant pre code {
	background-color: transparent;
	color: inherit;
	padding: 0;
	border-radius: 0;
}

/* Code Block Wrapper & Header */
.tpai-code-wrapper {
	position: relative;
	margin: 16px 0;
	background: #0f172a;
	/* Slate 900 */
	border-radius: 8px;
	overflow: hidden;
}

.tpai-code-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 12px;
	background: #1e293b;
	/* Slate 800 */
	border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tpai-code-lang {
	font-size: 11px;
	font-weight: 600;
	color: #94a3b8;
	/* Slate 400 */
	text-transform: lowercase;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tpai-code-wrapper pre {
	margin: 0 !important;
	padding: 16px !important;
	background: transparent !important;
	/* Managed by wrapper */
}

/* Code Copy Button (Premium) */
.tpai-code-copy {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 8px;
	border: none;
	background: rgba(255, 255, 255, 0.08);
	color: #e2e8f0;
	/* Slate 200 */
	cursor: pointer;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 500;
	font-family: inherit;
	transition: all 0.2s ease;
}

.tpai-code-copy:hover {
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
}

.tpai-code-copy svg {
	width: 14px;
	height: 14px;
	color: inherit !important;
}

.tpai-code-copy.tpai-copied {
	background: #059669;
	color: #fff;
}


.tpai-msg-assistant br {
	content: "";
	display: block;
	margin-top: 4px;
}