/**
 * WP AI Text Helper — Editor Styles (V5)
 *
 * Gradient AI icon, floating popup with action tags,
 * inline shorten input, and change history cards.
 */

/* === Base font === */
[class^="wpaith-"], [class*=" wpaith-"] {
	font-family: "Assistant", sans-serif;
}

/* === AI Icon === */
.wpaith-icon {
	position: absolute;
	z-index: 99998;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: linear-gradient(135deg, #1389b5 0%, #9b51e0 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 5px rgba(155, 81, 224, 0.3);
	user-select: none;
	transition: transform 0.15s, box-shadow 0.15s;
	border: none;
}
.wpaith-icon:hover {
	transform: scale(1.1);
	box-shadow: 0 3px 8px rgba(155, 81, 224, 0.45);
}
.wpaith-icon svg {
	width: 14px;
	height: 14px;
	pointer-events: none;
}

/* === Floating Popup === */
.wpaith-popup {
	position: absolute;
	direction: rtl;
	text-align: right;
	font-family: 'Segoe UI', 'Assistant', Tahoma, Arial, sans-serif;
	background: #ffffff;
	border: 1px solid #dcdcdc;
	box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
	border-radius: 8px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	max-height: 420px;
	z-index: 99999;
}

/* === Actions bar (wraps to multiple lines) === */
.wpaith-actions-container {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	padding: 12px;
	border-bottom: 1px solid #dcdcdc;
	background-color: #fcfcfc;
	align-items: center;
	flex-shrink: 0;
}

/* === Action tags === */
.wpaith-tag {
	padding: 0 12px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 20px;
	font-size: 11px;
    font-weight: normal;
	cursor: pointer;
	transition: all 0.2s;
	font-family: inherit;
	box-sizing: border-box;
	flex-shrink: 0;
	border: 1px solid;
	white-space: nowrap;
}
.wpaith-tag-blue {
	background: #e8f4f8;
	color: #1389b5;
	border-color: #1389b5;
}
.wpaith-tag-blue:hover {
	background: #1389b5;
	color: #ffffff;
}
.wpaith-tag-gray {
	background: #f0f0f0;
	color: #333;
	border-color: #ccc;
}
.wpaith-tag-gray:hover {
	background: #e0e0e0;
	border-color: #999;
}

/* === Inline shorten tag === */
.wpaith-tag-with-input {
	background: #f0f0f0;
	color: #333;
	border: 1px solid #ccc;
	padding: 0 12px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	border-radius: 20px;
	font-size: 13px;
	flex-shrink: 0;
	white-space: nowrap;
	cursor: pointer;
	transition: all 0.2s;
	gap: 4px;
}
.wpaith-tag-with-input:hover {
	background: #e0e0e0;
	border-color: #999;
}

/* Override theme rules (e.g. .span_circle span) that hide inner spans. */
.wpaith-tag-with-input span,
.wpaith-tag-with-input label {
	position: static !important;
	opacity: 1 !important;
	visibility: visible !important;
	display: inline !important;
	width: auto !important;
	height: auto !important;
	overflow: visible !important;
	float: none !important;
	font-size: 11px !important;
	color: #333 !important;
	pointer-events: none;
    padding: 0px !important;
}

/* Arrow indicator next to the shorten tag — signals "click to apply" */
.wpaith-shorten-arrow {
	display: inline-flex !important;
	align-items: center;
	color: #1389b5 !important;
	margin-right: 2px;
	pointer-events: none;
	transition: transform 0.15s;
}
.wpaith-tag-with-input:hover .wpaith-shorten-arrow {
	transform: translateX(-2px);
}

.wpaith-shorten-input {
	width: 42px;
	height: 20px;
	border: 1px solid #ccc;
	border-radius: 4px;
	text-align: center;
	color: #333;
	font-weight: bold;
	font-size: 13px;
	outline: none;
	background: #fff;
	padding: 0 2px;
	-moz-appearance: textfield;
}
.wpaith-shorten-input::-webkit-outer-spin-button,
.wpaith-shorten-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}
.wpaith-shorten-input:focus {
	border-color: #999;
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

/* === History section === */
.wpaith-history-section {
	display: none;
	flex-direction: column;
	flex-grow: 1;
	overflow: hidden;
	background: #f4f7f9;
}
.wpaith-history-title {
	padding: 10px 15px;
	font-size: 14px;
	font-weight: bold;
	color: #444;
	background: #fff;
	border-bottom: 1px solid #eee;
	flex-shrink: 0;
}
.wpaith-history-list {
	padding: 12px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 10px;
	flex-grow: 1;
}
.wpaith-history-list::-webkit-scrollbar { width: 6px; }
.wpaith-history-list::-webkit-scrollbar-track { background: #f1f1f1; }
.wpaith-history-list::-webkit-scrollbar-thumb { background: #a0a0a0; border-radius: 10px; }

/* === History item card === */
.wpaith-history-item {
	border: 1px solid #e0e0e0;
	border-radius: 6px;
	padding: 10px 12px;
	background: #ffffff;
	display: flex;
	flex-direction: column;
	gap: 8px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
/* Source (original text) entry — soft blue background */
.wpaith-history-item-source {
	background: #e8f4f8;
	border-color: #b8e0ff;
}
.wpaith-history-main-row {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	width: 100%;
	gap: 15px;
}

/* Right: text + timestamp */
.wpaith-history-right {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	text-align: right;
}
.wpaith-history-content {
	font-size: 13px;
	color: #222;
	line-height: 1.5;
	margin: 0;
	padding-top: 2px;
	white-space: pre-wrap;
	word-wrap: break-word;
}
.wpaith-history-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 6px;
}
.wpaith-history-timestamp {
	color: #aaa;
	font-size: 11px;
}

/* Left: copy button */
.wpaith-history-left {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	flex-shrink: 0;
}
.wpaith-copy-btn {
	background: none;
	border: none;
	cursor: pointer;
	color: #888;
	padding: 2px;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.15s, background 0.15s;
}
.wpaith-copy-btn:hover { color: #1389b5; background: #f5f5f5; }
.wpaith-copy-btn svg { pointer-events: none; }

.wpaith-history-badge {
	background: #f0f4f8;
	color: #4A5568;
	border: 1px solid #CBD5E1;
	padding: 2px 8px;
	border-radius: 10px;
	font-size: 11px;
	font-weight: 500;
	white-space: nowrap;
}

/* === History action buttons === */
.wpaith-history-actions {
	display: flex;
	gap: 8px;
	border-top: 1px dashed #eee;
	padding-top: 8px;
	margin-top: 2px;
}
.wpaith-btn-accept {
	padding: 4px 12px;
	border-radius: 4px;
	font-size: 11.5px;
	cursor: pointer;
	font-weight: 500;
	border: none;
	background: #1389b5;
	color: white;
	font-family: inherit;
	transition: opacity 0.2s;
}
.wpaith-btn-accept:hover { opacity: 0.85; }

.wpaith-btn-cancel {
	padding: 4px 12px;
	border-radius: 4px;
	font-size: 11.5px;
	cursor: pointer;
	font-weight: 500;
	border: none;
	background: #f0f0f0;
	color: #555;
	font-family: inherit;
	transition: background 0.2s;
}
.wpaith-btn-cancel:hover { background: #e4e4e4; }

.wpaith-accepted-msg {
	color: #329946;
	font-size: 12px;
	font-weight: 600;
}

/* === Loading state === */
.wpaith-loading-item { border-color: #e8f4f8; background: #f9fcfe; }
.wpaith-loading-item .wpaith-history-right { flex-direction: row; align-items: center; gap: 10px; }
.wpaith-loading-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid #e0e0e0;
	border-top-color: #1389b5;
	border-radius: 50%;
	animation: wpaith-spin 0.8s linear infinite;
	flex-shrink: 0;
}
@keyframes wpaith-spin { to { transform: rotate(360deg); } }
.wpaith-loading-text { color: #666; font-size: 13px; }

/* === Error state === */
.wpaith-error-item { border-color: #f5c6cb; background: #fef2f2; }
.wpaith-error-msg { color: #d9534f; font-size: 13px; }
