/**
 * Chatbot Frontend Styles
 *
 * @package School_Chatbot
 */

/* CSS Variables & Base Reset */
:root {
	--scb-primary: #0073aa;
	--scb-secondary: #005177;
	--scb-bg-light: #f8fafc;
	--scb-bg-white: #ffffff;
	--scb-text-primary: #1e293b;
	--scb-text-secondary: #64748b;
	--scb-text-muted: #94a3b8;
	--scb-border-light: #e2e8f0;
	--scb-border-medium: #cbd5e1;
	--scb-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
	--scb-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
	--scb-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
	--scb-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
	--scb-radius-sm: 8px;
	--scb-radius-md: 12px;
	--scb-radius-lg: 16px;
	--scb-radius-xl: 20px;
	--scb-radius-full: 9999px;
	--scb-transition-fast: 150ms ease;
	--scb-transition-normal: 250ms ease;
	--scb-transition-slow: 350ms ease;
}

/* Widget Container */
#scb-chatbot-widget {
	position: fixed;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

#scb-chatbot-widget * {
	box-sizing: border-box;
}

.scb-widget-bottom-right {
	bottom: 24px;
	right: 24px;
}

.scb-widget-bottom-left {
	bottom: 24px;
	left: 24px;
}

/* Toggle Button */
.scb-toggle-btn {
	width: 64px;
	height: 64px;
	border-radius: var(--scb-radius-full);
	background: linear-gradient(135deg, var(--scb-primary) 0%, var(--scb-secondary) 100%);
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: var(--scb-shadow-lg), 0 0 0 0 rgba(0, 115, 170, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all var(--scb-transition-normal);
	position: relative;
	overflow: hidden;
}

.scb-toggle-btn::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
	border-radius: inherit;
}

.scb-toggle-btn:hover {
	transform: scale(1.08) translateY(-2px);
	box-shadow: var(--scb-shadow-xl), 0 0 0 8px rgba(0, 115, 170, 0.15);
}

.scb-toggle-btn:active {
	transform: scale(1.02);
}

.scb-toggle-btn svg {
	width: 28px;
	height: 28px;
	position: relative;
	z-index: 1;
}

/* Pulse animation for toggle button */
@keyframes pulse {
	0%, 100% {
		box-shadow: var(--scb-shadow-lg), 0 0 0 0 rgba(0, 115, 170, 0.4);
	}
	50% {
		box-shadow: var(--scb-shadow-lg), 0 0 0 12px rgba(0, 115, 170, 0);
	}
}

.scb-toggle-btn:not(:hover) {
	animation: pulse 3s infinite;
}

/* Chat Container */
.scb-chat-container {
	width: 400px;
	height: 620px;
	background: var(--scb-bg-white);
	border-radius: var(--scb-radius-xl);
	box-shadow: var(--scb-shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	margin-bottom: 16px;
	transform-origin: bottom right;
	animation: slideUp var(--scb-transition-slow) ease-out;
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.95);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

/* Chat Header */
.scb-chat-header {
	background: linear-gradient(135deg, var(--scb-primary) 0%, var(--scb-secondary) 100%);
	color: #fff;
	padding: 20px 24px;
	position: relative;
	overflow: hidden;
}

.scb-chat-header::before {
	content: '';
	position: absolute;
	top: -50%;
	right: -50%;
	width: 100%;
	height: 200%;
	background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
}

.scb-header-content {
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: relative;
	z-index: 1;
}

/* Header identity (logo + name + status) */
.scb-header-identity {
	display: flex;
	align-items: center;
	gap: 12px;
}

.scb-bot-logo {
	width: 42px;
	height: 42px;
	border-radius: var(--scb-radius-full);
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.4);
	flex-shrink: 0;
}

.scb-bot-logo-placeholder {
	width: 42px;
	height: 42px;
	border-radius: var(--scb-radius-full);
	background: rgba(255, 255, 255, 0.2);
	border: 2px solid rgba(255, 255, 255, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.scb-header-text {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.scb-chat-header h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.2;
}

.scb-header-status {
	font-size: 12px;
	opacity: 0.85;
	display: flex;
	align-items: center;
	gap: 5px;
}

.scb-header-status::before {
	content: '';
	width: 7px;
	height: 7px;
	background: #22c55e;
	border-radius: 50%;
	box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
	animation: onlinePulse 2s infinite;
	flex-shrink: 0;
}

@keyframes onlinePulse {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.6;
	}
}

.scb-close-btn {
	background: rgba(255, 255, 255, 0.15);
	border: none;
	color: #fff;
	font-size: 20px;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--scb-radius-full);
	transition: all var(--scb-transition-fast);
	backdrop-filter: blur(4px);
}

.scb-close-btn:hover {
	background: rgba(255, 255, 255, 0.25);
	transform: rotate(90deg);
}

/* Messages Area */
.scb-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 24px;
	background: var(--scb-bg-light);
	scroll-behavior: smooth;
}

.scb-chat-messages::-webkit-scrollbar {
	width: 6px;
}

.scb-chat-messages::-webkit-scrollbar-track {
	background: transparent;
}

.scb-chat-messages::-webkit-scrollbar-thumb {
	background: var(--scb-border-medium);
	border-radius: var(--scb-radius-full);
}

.scb-chat-messages::-webkit-scrollbar-thumb:hover {
	background: var(--scb-text-muted);
}

.scb-message {
	margin-bottom: 16px;
	display: flex;
	animation: messageSlide var(--scb-transition-normal) ease-out;
}

@keyframes messageSlide {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.scb-user-message {
	justify-content: flex-end;
}

.scb-bot-message {
	justify-content: flex-start;
}

.scb-message-content {
	max-width: 80%;
	padding: 14px 18px;
	border-radius: var(--scb-radius-lg);
	word-wrap: break-word;
	line-height: 1.5;
	font-size: 14px;
}

.scb-user-message .scb-message-content {
	background: linear-gradient(135deg, var(--scb-primary) 0%, var(--scb-secondary) 100%);
	color: #fff;
	border-bottom-right-radius: 4px;
	box-shadow: var(--scb-shadow-md);
}

.scb-bot-message .scb-message-content {
	background: var(--scb-bg-white);
	color: var(--scb-text-primary);
	border-bottom-left-radius: 4px;
	box-shadow: var(--scb-shadow-sm), 0 0 0 1px var(--scb-border-light);
}

.scb-message-content a {
	color: var(--scb-primary);
	text-decoration: none;
	font-weight: 500;
	border-bottom: 1px solid transparent;
	transition: border-color var(--scb-transition-fast);
}

.scb-message-content a:hover {
	border-bottom-color: var(--scb-primary);
}

.scb-message-content ul,
.scb-message-content ol {
	margin: 12px 0;
	padding-left: 24px;
}

.scb-message-content li {
	margin-bottom: 6px;
}

/* Bot Avatar */
.scb-bot-message::before {
	content: '';
	width: 32px;
	height: 32px;
	min-width: 32px;
	background: linear-gradient(135deg, var(--scb-primary) 0%, var(--scb-secondary) 100%);
	border-radius: var(--scb-radius-full);
	margin-right: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: var(--scb-shadow-sm);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 16px;
}

/* Typing Indicator */
.scb-typing {
	display: flex;
	gap: 6px;
	padding: 14px 18px;
	align-items: center;
}

.scb-typing span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--scb-text-muted);
	animation: typingBounce 1.4s infinite ease-in-out;
}

.scb-typing span:nth-child(1) {
	animation-delay: 0s;
}

.scb-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.scb-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes typingBounce {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.5;
	}
	30% {
		transform: translateY(-8px);
		opacity: 1;
	}
}

/* Suggestions */
.scb-suggestions {
	padding: 12px 16px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	background: var(--scb-bg-white);
	border-top: 1px solid var(--scb-border-light);
	max-height: 120px;
	overflow-y: auto;
}

.scb-suggestions:empty {
	display: none;
}

.scb-suggestion-btn {
	padding: 8px 16px;
	background: var(--scb-bg-light);
	border: 1px solid var(--scb-border-light);
	border-radius: var(--scb-radius-full);
	font-size: 13px;
	color: var(--scb-text-primary);
	cursor: pointer;
	transition: all var(--scb-transition-fast);
	font-weight: 500;
	white-space: nowrap;
}

.scb-suggestion-btn:hover {
	background: var(--scb-primary);
	color: #fff;
	border-color: var(--scb-primary);
	transform: translateY(-1px);
	box-shadow: var(--scb-shadow-sm);
}

.scb-suggestion-btn:active {
	transform: translateY(0);
}

/* Related questions rendered inside bot messages */
.scb-related-questions {
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px solid var(--scb-border-light);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.scb-related-questions .scb-suggestion-btn {
	text-align: left;
	white-space: normal;
	border-radius: var(--scb-radius-sm);
}

/* Input Area */
.scb-chat-input-area {
	background: var(--scb-bg-white);
	border-top: 1px solid var(--scb-border-light);
}

.scb-input-wrapper {
	display: flex;
	padding: 16px 20px;
	gap: 12px;
	align-items: center;
}

.scb-input {
	flex: 1;
	padding: 14px 20px;
	border: 2px solid var(--scb-border-light);
	border-radius: var(--scb-radius-full);
	font-size: 14px;
	font-family: inherit;
	outline: none;
	transition: all var(--scb-transition-fast);
	background: var(--scb-bg-light);
	color: var(--scb-text-primary);
}

.scb-input::placeholder {
	color: var(--scb-text-muted);
}

.scb-input:focus {
	border-color: var(--scb-primary);
	background: var(--scb-bg-white);
	box-shadow: 0 0 0 4px rgba(0, 115, 170, 0.1);
}

.scb-send-btn {
	width: 48px;
	height: 48px;
	border-radius: var(--scb-radius-full);
	background: linear-gradient(135deg, var(--scb-primary) 0%, var(--scb-secondary) 100%);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all var(--scb-transition-fast);
	flex-shrink: 0;
	box-shadow: var(--scb-shadow-md);
}

.scb-send-btn:hover {
	transform: scale(1.05);
	box-shadow: var(--scb-shadow-lg);
}

.scb-send-btn:active {
	transform: scale(0.98);
}

.scb-send-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}

.scb-send-btn svg {
	width: 20px;
	height: 20px;
}

.scb-contact-form-btn {
	width: 40px;
	height: 40px;
	border-radius: var(--scb-radius-full);
	background: transparent;
	border: 1.5px solid var(--scb-border-light);
	color: var(--scb-text-muted);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: all var(--scb-transition-fast);
	flex-shrink: 0;
}

.scb-contact-form-btn:hover {
	background: var(--scb-bg-light);
	border-color: var(--scb-primary);
	color: var(--scb-primary);
}

.scb-input-footer {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 20px 12px;
}

.scb-open-contact-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 14px;
	border-radius: var(--scb-radius-full);
	background: transparent;
	border: 1px solid var(--scb-border-light);
	color: var(--scb-text-muted);
	font-size: 12px;
	font-weight: 500;
	cursor: pointer;
	transition: all var(--scb-transition-fast);
}

.scb-open-contact-btn:hover {
	background: var(--scb-bg-light);
	border-color: var(--scb-primary);
	color: var(--scb-primary);
}

/* Contact Modal */
.scb-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(15, 23, 42, 0.6);
	backdrop-filter: blur(4px);
	z-index: 1000000;
	display: flex;
	align-items: center;
	justify-content: center;
	animation: modalFadeIn var(--scb-transition-normal) ease-out;
	padding: 24px;
}

@keyframes modalFadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.scb-modal-content {
	background: var(--scb-bg-white);
	border-radius: var(--scb-radius-xl);
	width: 100%;
	max-width: 480px;
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	box-shadow: var(--scb-shadow-xl);
	animation: modalSlideUp var(--scb-transition-slow) ease-out;
}

@keyframes modalSlideUp {
	from {
		opacity: 0;
		transform: translateY(24px) scale(0.95);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.scb-modal-header {
	padding: 24px 28px 20px;
	border-bottom: 1px solid var(--scb-border-light);
	display: flex;
	justify-content: space-between;
	align-items: center;
	position: sticky;
	top: 0;
	background: var(--scb-bg-white);
	z-index: 1;
}

.scb-modal-header h3 {
	margin: 0;
	font-size: 20px;
	font-weight: 600;
	color: var(--scb-text-primary);
	letter-spacing: -0.02em;
}

.scb-modal-close {
	background: var(--scb-bg-light);
	border: none;
	font-size: 24px;
	cursor: pointer;
	line-height: 1;
	color: var(--scb-text-secondary);
	transition: all var(--scb-transition-fast);
	width: 40px;
	height: 40px;
	border-radius: var(--scb-radius-full);
	display: flex;
	align-items: center;
	justify-content: center;
}

.scb-modal-close:hover {
	background: var(--scb-border-light);
	color: var(--scb-text-primary);
}

.scb-contact-form {
	padding: 24px;
	box-sizing: border-box;
	width: 100%;
}

.scb-form-field {
	margin-bottom: 20px;
}

.scb-form-field:last-of-type {
	margin-bottom: 0;
}

.scb-form-field label {
	display: block;
	margin-bottom: 10px;
	font-weight: 600;
	color: var(--scb-text-primary);
	font-size: 14px;
}

.scb-form-field .required {
	color: #ef4444;
	margin-left: 2px;
}

.scb-form-input {
	width: 100%;
	box-sizing: border-box;
	padding: 12px 14px;
	border: 2px solid var(--scb-border-light);
	border-radius: var(--scb-radius-md);
	font-size: 14px;
	font-family: inherit;
	outline: none;
	transition: all var(--scb-transition-fast);
	background: var(--scb-bg-light);
	color: var(--scb-text-primary);
}

.scb-form-input::placeholder {
	color: var(--scb-text-muted);
}

.scb-form-input:focus {
	border-color: var(--scb-primary);
	background: var(--scb-bg-white);
	box-shadow: 0 0 0 4px rgba(0, 115, 170, 0.1);
}

.scb-form-input[type="textarea"],
textarea.scb-form-input {
	min-height: 120px;
	resize: vertical;
	line-height: 1.6;
}

.scb-form-actions {
	display: flex;
	gap: 12px;
	justify-content: flex-end;
	margin-top: 32px;
	padding-top: 24px;
	border-top: 1px solid var(--scb-border-light);
}

.scb-submit-btn,
.scb-cancel-btn {
	padding: 14px 28px;
	border: none;
	border-radius: var(--scb-radius-md);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all var(--scb-transition-fast);
	font-family: inherit;
}

.scb-submit-btn {
	background: linear-gradient(135deg, var(--scb-primary) 0%, var(--scb-secondary) 100%);
	color: #fff;
	box-shadow: var(--scb-shadow-md);
}

.scb-submit-btn:hover {
	transform: translateY(-2px);
	box-shadow: var(--scb-shadow-lg);
}

.scb-submit-btn:active {
	transform: translateY(0);
}

.scb-cancel-btn {
	background: var(--scb-bg-light);
	color: var(--scb-text-secondary);
	border: 1px solid var(--scb-border-light);
}

.scb-cancel-btn:hover {
	background: var(--scb-border-light);
	color: var(--scb-text-primary);
}

/* Responsive */
@media (max-width: 480px) {
	.scb-chat-container {
		width: calc(100vw - 32px);
		height: calc(100vh - 120px);
		max-height: 600px;
		border-radius: var(--scb-radius-lg);
	}

	.scb-widget-bottom-right,
	.scb-widget-bottom-left {
		bottom: 16px;
		right: 16px;
		left: 16px;
	}

	.scb-toggle-btn {
		width: 56px;
		height: 56px;
	}

	.scb-toggle-btn svg {
		width: 24px;
		height: 24px;
	}

	.scb-chat-header {
		padding: 14px 16px;
	}

	.scb-chat-header h3 {
		font-size: 15px;
	}

	.scb-bot-logo,
	.scb-bot-logo-placeholder {
		width: 36px;
		height: 36px;
	}

	.scb-header-identity {
		gap: 10px;
	}

	.scb-chat-messages {
		padding: 16px;
	}

	.scb-message {
		margin-bottom: 12px;
	}

	.scb-message-content {
		padding: 12px 16px;
		font-size: 14px;
		max-width: 85%;
	}

	.scb-bot-message::before {
		width: 28px;
		height: 28px;
		min-width: 28px;
		margin-right: 10px;
		background-size: 14px;
	}

	.scb-input-wrapper {
		padding: 12px 16px;
		gap: 10px;
	}

	.scb-input {
		padding: 12px 16px;
		font-size: 16px; /* Prevents zoom on iOS */
	}

	.scb-send-btn {
		width: 44px;
		height: 44px;
	}

	.scb-modal {
		padding: 16px;
	}

	.scb-modal-content {
		border-radius: var(--scb-radius-lg);
	}

	.scb-modal-header {
		padding: 20px 20px 16px;
	}

	.scb-modal-header h3 {
		font-size: 18px;
	}

	.scb-contact-form {
		padding: 20px;
	}

	.scb-form-field {
		margin-bottom: 20px;
	}

	.scb-form-input {
		padding: 12px 16px;
		font-size: 16px; /* Prevents zoom on iOS */
	}

	.scb-form-actions {
		flex-direction: column-reverse;
		gap: 10px;
		margin-top: 24px;
		padding-top: 20px;
	}

	.scb-submit-btn,
	.scb-cancel-btn {
		width: 100%;
		padding: 14px 20px;
		justify-content: center;
	}
}

/* Tablet adjustments */
@media (min-width: 481px) and (max-width: 768px) {
	.scb-chat-container {
		width: 380px;
		height: 580px;
	}
}

/* Shortcode inline style */
.scb-inline {
	position: relative;
	margin: 32px 0;
}

.scb-inline .scb-chat-container {
	position: relative;
	margin: 0 auto;
	box-shadow: var(--scb-shadow-lg), 0 0 0 1px var(--scb-border-light);
	animation: none;
	max-width: 100%;
}

.scb-inline .scb-toggle-btn {
	display: none;
}

.scb-inline .scb-close-btn {
	display: none;
}

/* Dark mode support (optional - follows system preference) */
@media (prefers-color-scheme: dark) {
	#scb-chatbot-widget.scb-dark-mode {
		--scb-bg-light: #1e293b;
		--scb-bg-white: #0f172a;
		--scb-text-primary: #f1f5f9;
		--scb-text-secondary: #94a3b8;
		--scb-text-muted: #64748b;
		--scb-border-light: #334155;
		--scb-border-medium: #475569;
	}
}

/* Accessibility - Focus States */
.scb-toggle-btn:focus-visible,
.scb-close-btn:focus-visible,
.scb-send-btn:focus-visible,
.scb-suggestion-btn:focus-visible,
.scb-submit-btn:focus-visible,
.scb-cancel-btn:focus-visible,
.scb-modal-close:focus-visible {
	outline: 2px solid var(--scb-primary);
	outline-offset: 2px;
}

.scb-input:focus-visible,
.scb-form-input:focus-visible {
	outline: none;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
	.scb-toggle-btn,
	.scb-chat-container,
	.scb-message,
	.scb-modal,
	.scb-modal-content,
	.scb-typing span {
		animation: none;
		transition: none;
	}

	.scb-toggle-btn:not(:hover) {
		animation: none;
	}
}

/* Lead capture hint message */
.scb-lead-hint .scb-message-content {
	background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
	border: 1px dashed var(--scb-primary);
	color: var(--scb-text-secondary);
	font-size: 13px;
}

/* Lead required indicator on suggestions */
.scb-suggestions-lead-required {
	position: relative;
}

.scb-suggestions-lead-required::before {
	content: '';
	position: absolute;
	top: -1px;
	left: 0;
	right: 0;
	height: 3px;
	background: linear-gradient(90deg, var(--scb-primary), var(--scb-secondary));
	border-radius: 3px 3px 0 0;
}
