/**
 * SmartyPress AI Classic Editor Styles
 * Replicates Gutenberg modal styling with 98%+ accuracy
 */

/* ============================================
   AI Writer Button (above editor, near Add Media)
   ============================================ */

.smartypress-ai-classic-above-wrapper {
	position: relative;
	display: inline-block;
	margin-left: 8px;
	vertical-align: top;
}

.smartypress-ai-classic-above-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: transparent;
	border: none;
	padding: 6px 14px;
	font-size: 13px;
	font-weight: 600;
	color: #1e1e1e;
	cursor: pointer;
	white-space: nowrap;
	z-index: 0;
	line-height: 1.4;
	border-radius: 4px;
	transition: background 0.2s ease;
	height: 30px;
}

.smartypress-ai-classic-above-btn::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 4px;
	padding: 2px;
	background: linear-gradient(90deg, #2271B1, #E84393, #2271B1, #E84393);
	background-size: 200% 100%;
	animation: smartypress-border-flow 4s ease-in-out infinite;
	-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;
	z-index: -1;
}

.smartypress-ai-classic-above-btn:hover {
	background: rgba(34, 113, 177, 0.08);
}

.smartypress-ai-classic-above-btn:focus {
	outline: none;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.4);
}

.smartypress-ai-classic-above-btn .smartypress-ai-writer-icon {
	flex-shrink: 0;
}

/* WooCommerce product edit page: extra spacing for button */
body.post-type-product .smartypress-ai-classic-above-btn {
	margin-bottom: 5px;
}

/* Dropdown menu */
.smartypress-ai-classic-dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 160001;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
	min-width: 200px;
	padding: 4px 0;
	margin-top: 4px;
}

.smartypress-ai-classic-dropdown a {
	display: block;
	padding: 8px 16px;
	color: #1e1e1e;
	text-decoration: none;
	font-size: 13px;
	line-height: 1.4;
	transition: background 0.1s ease;
}

.smartypress-ai-classic-dropdown a:hover {
	background: #f0f0f1;
	color: #2271b1;
}

@keyframes smartypress-border-flow {
	0%, 100% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
}

/* ============================================
   TinyMCE toolbar button overrides
   ============================================ */

.mce-smartypress-ai-classic-wand-btn .mce-txt {
	display: none !important;
}

/* ============================================
   Modal Overlay
   ============================================ */

.smartypress-ce-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.35);
	z-index: 160000;
	display: flex;
	align-items: center;
	justify-content: center;
	animation: sp-ce-fadein 0.1s ease;
}

@keyframes sp-ce-fadein {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* ============================================
   Modal Container (matches Gutenberg wp-components Modal)
   ============================================ */

.smartypress-ce-modal {
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 10px 30px rgba(0, 0, 0, 0.2);
	max-width: 600px;
	width: 90%;
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	animation: sp-ce-slidein 0.1s ease;
}

@keyframes sp-ce-slidein {
	from { transform: scale(0.95); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

/* ============================================
   Modal Header (gradient border like Gutenberg)
   ============================================ */

.smartypress-ce-header {
	padding: 16px 24px 12px;
	border-bottom: 2px solid transparent;
	border-image: linear-gradient(135deg, #2271B1, #E84393) 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: #fff;
	border-radius: 8px 8px 0 0;
}

.smartypress-ce-header h2 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.4;
	color: #1e1e1e;
}

.smartypress-ce-close {
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	color: #757575;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 4px;
	transition: color 0.1s ease;
}

.smartypress-ce-close:hover {
	color: #1e1e1e;
}

.smartypress-ce-close .dashicons {
	width: 24px;
	height: 24px;
	font-size: 24px;
}

/* ============================================
   Modal Body
   ============================================ */

.smartypress-ce-body {
	padding: 20px 24px 24px;
	overflow-y: auto;
	flex: 1;
}

/* ============================================
   Form Fields (matches wp-components)
   ============================================ */

.smartypress-ce-field {
	margin-bottom: 16px;
}

.smartypress-ce-field label {
	display: block;
	margin-bottom: 8px;
	font-size: 11px;
	font-weight: 500;
	text-transform: uppercase;
	color: #1e1e1e;
}

.smartypress-ce-field textarea,
.smartypress-ce-field select,
.smartypress-ce-field input[type="text"] {
	width: 100%;
	padding: 8px 16px;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	font-size: 13px;
	line-height: 1.5;
	color: #1e1e1e;
	box-sizing: border-box;
}

.smartypress-ce-field textarea {
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
	font-size: 13px;
	line-height: 1.5;
	resize: vertical;
	min-height: 100px;
}

.smartypress-ce-field textarea:focus,
.smartypress-ce-field select:focus,
.smartypress-ce-field input[type="text"]:focus {
	border-color: #2271B1;
	box-shadow: 0 0 0 1px #2271B1;
	outline: none;
}

.smartypress-ce-field input[type="range"] {
	width: 100%;
	margin: 4px 0;
}

/* ============================================
   Variable Tags (matches Gutenberg)
   ============================================ */

.smartypress-ce-variables {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
}

.smartypress-ce-var {
	background: rgba(34, 113, 177, 0.08);
	border: 1px solid rgba(34, 113, 177, 0.2);
	border-radius: 12px;
	padding: 2px 10px;
	font-size: 12px;
	font-family: 'SFMono-Regular', Consolas, monospace;
	color: #2271B1;
	cursor: pointer;
	transition: all 0.15s ease;
	line-height: 1.5;
}

.smartypress-ce-var:hover {
	background: rgba(34, 113, 177, 0.15);
	border-color: #2271B1;
}

/* ============================================
   Help Text & Description
   ============================================ */

.smartypress-ce-help {
	margin-top: 8px;
	font-size: 12px;
	color: #757575;
}

.smartypress-ce-description {
	color: #646970;
	font-size: 13px;
	line-height: 1.6;
	margin-bottom: 16px;
}

/* ============================================
   Accordion (matches PanelBody)
   ============================================ */

.smartypress-ce-accordion {
	border: 1px solid #e0e0e0;
	border-radius: 4px;
	margin-bottom: 20px;
}

.smartypress-ce-accordion-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	background: none;
	border: none;
	padding: 12px 16px;
	font-size: 13px;
	font-weight: 500;
	color: #1e1e1e;
	cursor: pointer;
	text-align: left;
}

.smartypress-ce-accordion-toggle:hover {
	color: #2271B1;
}

.smartypress-ce-accordion-toggle .dashicons {
	width: 20px;
	height: 20px;
	font-size: 20px;
}

/* ============================================
   Settings Grid (matches Gutenberg layout)
   ============================================ */

.smartypress-ce-settings-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	padding: 16px;
	background: #f6f7f7;
	border-radius: 4px;
	border: 1px solid #e0e0e0;
}

.smartypress-ce-temp-field {
	grid-column: 1 / -1;
}

/* ============================================
   Error Message
   ============================================ */

.smartypress-ce-error {
	background: #fcf0f1;
	border-left: 4px solid #cc1818;
	color: #cc1818;
	padding: 8px 12px;
	margin-bottom: 16px;
	border-radius: 0 4px 4px 0;
	font-size: 13px;
}

/* ============================================
   Loading State
   ============================================ */

.smartypress-ce-loading {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px;
	background: #f6f7f7;
	border-radius: 4px;
	color: #646970;
	margin-bottom: 16px;
	font-size: 13px;
}

.smartypress-ce-loading .spinner {
	float: none;
	margin: 0;
}

/* ============================================
   Inline Diff View
   ============================================ */

.smartypress-ce-result {
	margin-bottom: 16px;
}

.smartypress-ce-diff-view {
	border-radius: 6px;
	border: 1px solid #e0e0e0;
	overflow: hidden;
	background: #fff;
}

.smartypress-ce-diff-view > label {
	display: flex;
	align-items: center;
	gap: 6px;
	font-weight: 600;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding: 8px 12px;
	margin: 0;
	color: #1e1e1e;
	background: #f6f7f7;
	border-bottom: 1px solid #e0e0e0;
}

.smartypress-ce-diff-view > label .dashicons {
	width: 16px;
	height: 16px;
	font-size: 16px;
	color: #2271B1;
}

.smartypress-ce-diff-legend {
	display: flex;
	gap: 16px;
	padding: 4px 12px;
	background: #f9fafb;
	border-bottom: 1px solid #f0f0f0;
	font-size: 11px;
}

.smartypress-ce-diff-legend span {
	display: inline-flex;
	align-items: center;
	gap: 4px;
}

.smartypress-ce-diff-legend-remove {
	color: #991b1b;
}

.smartypress-ce-diff-legend-remove::before {
	content: '';
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 2px;
	background: #fecaca;
	border: 1px solid #f87171;
}

.smartypress-ce-diff-legend-add {
	color: #166534;
}

.smartypress-ce-diff-legend-add::before {
	content: '';
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 2px;
	background: #bbf7d0;
	border: 1px solid #4ade80;
}

.smartypress-ce-diff-content {
	padding: 12px;
	font-size: 13px;
	line-height: 1.8;
	max-height: 300px;
	overflow-y: auto;
	color: #1e1e1e;
}

.smartypress-ce-diff-add {
	color: #166534;
	background: #dcfce7;
	border-radius: 2px;
	padding: 1px 2px;
}

.smartypress-ce-diff-remove {
	color: #991b1b;
	background: #fee2e2;
	border-radius: 2px;
	padding: 1px 2px;
	text-decoration: line-through;
}

/* ============================================
   Modal Footer
   ============================================ */

.smartypress-ce-footer {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	padding: 16px 24px;
	border-top: 1px solid #e0e0e0;
}

/* ============================================
   Buttons (matches Gutenberg)
   ============================================ */

.smartypress-ce-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 24px;
	font-size: 13px;
	font-weight: 600;
	border-radius: 4px;
	border: none;
	cursor: pointer;
	line-height: 1.4;
	transition: opacity 0.2s ease;
}

.smartypress-ce-btn:disabled {
	opacity: 0.5;
	cursor: default;
}

.smartypress-ce-btn-primary {
	background: linear-gradient(135deg, #2271B1, #E84393);
	color: #fff;
}

.smartypress-ce-btn-primary:hover:not(:disabled) {
	opacity: 0.9;
}

.smartypress-ce-btn-primary:focus {
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.4);
	outline: none;
}

.smartypress-ce-btn-secondary {
	background: transparent;
	border: 1px solid #1e1e1e;
	color: #1e1e1e;
}

.smartypress-ce-btn-secondary:hover:not(:disabled) {
	background: #f0f0f1;
}

/* ============================================
   Notice (toast)
   ============================================ */

.smartypress-ce-notice {
	position: fixed;
	bottom: 40px;
	left: 50%;
	transform: translateX(-50%);
	background: #1e1e1e;
	color: #fff;
	padding: 10px 20px;
	border-radius: 4px;
	font-size: 13px;
	z-index: 170000;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	animation: sp-ce-fadein 0.2s ease;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 782px) {
	.smartypress-ce-modal {
		max-width: 95%;
		max-height: 95vh;
	}

	.smartypress-ce-settings-grid {
		grid-template-columns: 1fr;
	}

	.smartypress-ai-classic-above-btn {
		font-size: 0;
		padding: 6px 8px;
	}
}
