/* ==========================================================================
   CloudGO Support Widget - Modern PCB Styling
   ========================================================================== */

:root {
	--cgw-brand: #0d54c0;
	--cgw-brand-hover: #0b459e;
	--cgw-brand-light: #1868e4;
	--cgw-accent: #FF6500;
	--cgw-accent-hover: #e05800;
	--cgw-text: #172b4d;
	--cgw-text-muted: #6b778c;
	--cgw-bg: #ffffff;
	--cgw-border: #dfe1e6;
	--cgw-radius: 18px;
	--cgw-shadow: 0 16px 44px rgba(13, 84, 192, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
	--cgw-transition: all 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Bilingual Display Control (strictly driven by website header / language class) */
#cgw-widget-container.cgw-lang-vi .cgw-text-en { display: none !important; }
#cgw-widget-container.cgw-lang-vi .cgw-text-vi { display: inline; }
#cgw-widget-container.cgw-lang-en .cgw-text-vi { display: none !important; }
#cgw-widget-container.cgw-lang-en .cgw-text-en { display: inline; }

p#cgw-widget-container.cgw-lang-vi .cgw-text-vi,
div#cgw-widget-container.cgw-lang-vi .cgw-text-vi { display: block; }
p#cgw-widget-container.cgw-lang-en .cgw-text-en,
div#cgw-widget-container.cgw-lang-en .cgw-text-en { display: block; }

/* Container Position & System Font */
#cgw-widget-container,
#cgw-widget-container * {
	font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
	box-sizing: border-box;
}

#cgw-widget-container {
	position: fixed;
	z-index: 999999;
	color: var(--cgw-text);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

#cgw-widget-container.cgw-pos-bottom-right {
	bottom: 24px;
	right: 24px;
}

#cgw-widget-container.cgw-pos-bottom-left {
	bottom: 24px;
	left: 24px;
}

/* Ensure to-top button sits gracefully above widget */
#to_top_scrollup {
	bottom: 95px !important;
	transition: bottom 0.3s ease, opacity 0.3s ease !important;
}

/* ==========================================================================
   Floating Trigger Button & Pill
   ========================================================================== */

.cgw-trigger {
	display: flex;
	align-items: center;
	cursor: pointer;
	user-select: none;
	gap: 10px;
	position: relative;
	transition: var(--cgw-transition);
}

.cgw-pos-bottom-right .cgw-trigger {
	flex-direction: row;
}

.cgw-pos-bottom-left .cgw-trigger {
	flex-direction: row-reverse;
}

/* Pill badge with text */
.cgw-trigger-pill {
	background: #ffffff;
	color: var(--cgw-brand);
	font-size: 13.5px;
	font-weight: 600;
	padding: 8px 16px;
	border-radius: 30px;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
	border: 1px solid rgba(13, 84, 192, 0.15);
	white-space: nowrap;
	transition: var(--cgw-transition);
	pointer-events: none;
}

.cgw-trigger:hover .cgw-trigger-pill {
	transform: translateY(-2px);
	box-shadow: 0 6px 22px rgba(13, 84, 192, 0.22);
	background: #fdfdfd;
}

/* Circular Button */
.cgw-trigger-btn {
	width: 58px;
	height: 58px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--cgw-brand) 0%, var(--cgw-brand-light) 100%);
	color: #ffffff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(13, 84, 192, 0.4);
	position: relative;
	transition: var(--cgw-transition);
}

.cgw-trigger:hover .cgw-trigger-btn {
	transform: scale(1.06);
	box-shadow: 0 12px 30px rgba(13, 84, 192, 0.48);
}

.cgw-trigger-btn .cgw-icon {
	width: 26px;
	height: 26px;
	transition: var(--cgw-transition);
}

.cgw-trigger-btn .cgw-icon-close {
	display: none;
	width: 24px;
	height: 24px;
}

/* Active Trigger State -> Orange #FF6500 when open */
#cgw-widget-container.cgw-open .cgw-trigger-btn {
	background: #FF6500;
	box-shadow: 0 8px 24px rgba(255, 101, 0, 0.45);
	transform: rotate(90deg);
}

#cgw-widget-container.cgw-open .cgw-icon-chat {
	display: none;
}

#cgw-widget-container.cgw-open .cgw-icon-close {
	display: block;
}

#cgw-widget-container.cgw-open .cgw-trigger-pill {
	opacity: 0;
	transform: scale(0.8);
	pointer-events: none;
}

/* Online Dot */
.cgw-online-dot {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 14px;
	height: 14px;
	background-color: #22c55e;
	border: 2.5px solid #ffffff;
	border-radius: 50%;
	z-index: 2;
}

/* Pulse Ring in vibrant ORANGE #FF6500 */
.cgw-pulse-ring {
	position: absolute;
	top: -5px;
	left: -5px;
	right: -5px;
	bottom: -5px;
	border-radius: 50%;
	border: 2.5px solid #FF6500;
	opacity: 0.85;
	animation: cgw-pulse 2.2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
	pointer-events: none;
}

#cgw-widget-container.cgw-open .cgw-pulse-ring {
	display: none;
}

@keyframes cgw-pulse {
	0% {
		transform: scale(0.95);
		opacity: 0.85;
	}
	70% {
		transform: scale(1.35);
		opacity: 0;
	}
	100% {
		transform: scale(1.35);
		opacity: 0;
	}
}

/* ==========================================================================
   Popup Window Card
   ========================================================================== */

.cgw-window {
	position: absolute;
	bottom: 74px;
	width: 395px;
	max-width: calc(100vw - 32px);
	background: #ffffff;
	border-radius: var(--cgw-radius);
	box-shadow: var(--cgw-shadow);
	border: 1px solid rgba(0, 0, 0, 0.08);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	max-height: 85vh;
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px) scale(0.95);
	transform-origin: bottom right;
	transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
	z-index: 10;
}

.cgw-pos-bottom-right .cgw-window {
	right: 0;
	transform-origin: bottom right;
}

.cgw-pos-bottom-left .cgw-window {
	left: 0;
	transform-origin: bottom left;
}

#cgw-widget-container.cgw-open .cgw-window {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

/* Header */
.cgw-header {
	background: linear-gradient(135deg, #0d54c0 0%, #1664d9 100%);
	color: #ffffff;
	padding: 18px 20px;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	position: relative;
	box-shadow: 0 4px 14px rgba(13, 84, 192, 0.18);
}

.cgw-header-brand {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	flex: 1;
	min-width: 0;
}

.cgw-avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.22);
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	flex-shrink: 0;
	margin-top: 2px;
}

.cgw-avatar svg {
	width: 22px;
	height: 22px;
	color: #ffffff;
}

.cgw-avatar-status {
	position: absolute;
	bottom: 0;
	right: 0;
	width: 11px;
	height: 11px;
	background: #22c55e;
	border: 2px solid #ffffff;
	border-radius: 50%;
}

.cgw-header-text {
	flex: 1;
	min-width: 0;
}

.cgw-title {
	margin: 0;
	font-size: 16px;
	font-weight: 800;
	color: #ffffff;
	line-height: 1.3;
	letter-spacing: 0.5px;
	text-transform: uppercase;
}

/* Subtitle: Full visibility without truncation */
.cgw-desc {
	margin: 5px 0 0;
	font-size: 12.5px;
	color: rgba(255, 255, 255, 0.94);
	line-height: 1.45;
	white-space: normal;
	word-break: normal;
}

/* Header Actions */
.cgw-header-actions {
	margin-left: 12px;
	flex-shrink: 0;
	margin-top: 2px;
}

/* Small Close Button in Header -> Orange background with white X */
.cgw-close-btn {
	background: #FF6500;
	border: none;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
	cursor: pointer;
	transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
	padding: 0;
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.cgw-close-btn:hover {
	background: #e05800;
	transform: scale(1.1) rotate(90deg);
	box-shadow: 0 4px 14px rgba(255, 101, 0, 0.45);
}

.cgw-close-btn svg {
	width: 15px;
	height: 15px;
	stroke: #ffffff;
}

/* ==========================================================================
   Body & Form
   ========================================================================== */

.cgw-body {
	padding: 20px 22px;
	overflow-y: auto;
	max-height: calc(85vh - 120px);
	scrollbar-width: thin;
	scrollbar-color: #d1d5db transparent;
}

.cgw-body::-webkit-scrollbar {
	width: 5px;
}
.cgw-body::-webkit-scrollbar-thumb {
	background-color: #d1d5db;
	border-radius: 10px;
}

.cgw-form-group {
	margin-bottom: 15px;
}

.cgw-form-group label {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: #334155;
	margin-bottom: 6px;
}

.cgw-req {
	color: #ef4444;
	font-weight: 600;
}

.cgw-input,
.cgw-textarea {
	width: 100%;
	padding: 10px 14px;
	font-size: 13.5px;
	color: #1e293b;
	background: #f8fafc;
	border: 1px solid var(--cgw-border);
	border-radius: 10px;
	transition: all 0.2s ease;
	outline: none;
	font-family: inherit;
}

/* Light grey placeholder */
.cgw-input::placeholder,
.cgw-textarea::placeholder {
	color: #94a3b8 !important;
	opacity: 1;
	font-size: 13px;
	font-weight: 400;
}

.cgw-input:focus,
.cgw-textarea:focus {
	background: #ffffff;
	border-color: #0d54c0;
	box-shadow: 0 0 0 3px rgba(13, 84, 192, 0.15);
}

.cgw-textarea {
	resize: vertical;
	min-height: 75px;
	line-height: 1.45;
}

/* File Dropzone */
.cgw-file-dropzone {
	position: relative;
	border: 1.5px dashed #cbd5e1;
	border-radius: 10px;
	padding: 12px 14px;
	text-align: center;
	background: #f8fafc;
	cursor: pointer;
	transition: all 0.2s ease;
}

.cgw-file-dropzone:hover {
	border-color: #0d54c0;
	background: #f1f5f9;
}

.cgw-file-input {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
	z-index: 2;
}

.cgw-file-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	color: #64748b;
	font-size: 12px;
}

.cgw-file-placeholder svg {
	width: 18px;
	height: 18px;
	color: #0d54c0;
	flex-shrink: 0;
}

.cgw-file-selected {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: #ffffff;
	padding: 6px 10px;
	border-radius: 6px;
	border: 1px solid #e2e8f0;
	font-size: 12px;
	color: #1e293b;
	z-index: 3;
	position: relative;
}

.cgw-filename {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 80%;
}

.cgw-remove-file {
	background: #fee2e2;
	color: #ef4444;
	border: none;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.cgw-remove-file:hover {
	background: #fca5a5;
}

/* Error Box */
.cgw-error-box {
	background: #fef2f2;
	border: 1px solid #fecaca;
	color: #b91c1c;
	font-size: 12px;
	padding: 9px 13px;
	border-radius: 8px;
	margin-bottom: 14px;
	animation: cgw-shake 0.3s ease;
	line-height: 1.4;
}

@keyframes cgw-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

/* Submit Button */
.cgw-submit-wrap {
	margin-top: 18px;
}

.cgw-submit-btn {
	width: 100%;
	background: linear-gradient(135deg, #0d54c0 0%, #1664d9 100%);
	color: #ffffff;
	border: none;
	padding: 13px 20px;
	font-size: 15px;
	font-weight: 600;
	border-radius: 10px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-shadow: 0 4px 14px rgba(13, 84, 192, 0.3);
	transition: all 0.25s ease;
	font-family: inherit;
}

.cgw-submit-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(13, 84, 192, 0.42);
	background: linear-gradient(135deg, #0b459e 0%, #0d54c0 100%);
}

.cgw-submit-btn:active {
	transform: translateY(1px);
}

.cgw-btn-icon {
	width: 16px;
	height: 16px;
	transition: transform 0.2s ease;
}

.cgw-submit-btn:hover .cgw-btn-icon {
	transform: translateX(3px);
}

.cgw-submit-btn.loading {
	opacity: 0.85;
	pointer-events: none;
}

.cgw-submit-btn.loading .cgw-btn-icon {
	display: none;
}

.cgw-btn-spinner {
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.4);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: cgw-spin 0.7s linear infinite;
}

@keyframes cgw-spin {
	to { transform: rotate(360deg); }
}

/* ==========================================================================
   Success View Screen
   ========================================================================== */

.cgw-success-view {
	text-align: center;
	padding: 30px 10px 20px;
	animation: cgw-fade-in 0.4s ease;
}

@keyframes cgw-fade-in {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

.cgw-success-icon-wrap {
	width: 68px;
	height: 68px;
	margin: 0 auto 16px;
}

.cgw-success-icon {
	width: 68px;
	height: 68px;
	stroke-width: 2.5;
	stroke: #22c55e;
	fill: none;
}

.cgw-success-circle {
	stroke-dasharray: 166;
	stroke-dashoffset: 166;
	stroke-width: 2.5;
	stroke-miterlimit: 10;
	stroke: #22c55e;
	animation: cgw-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.cgw-success-check {
	transform-origin: 50% 50%;
	stroke-dasharray: 48;
	stroke-dashoffset: 48;
	animation: cgw-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
}

@keyframes cgw-stroke {
	100% { stroke-dashoffset: 0; }
}

.cgw-success-title {
	font-size: 18px;
	font-weight: 600;
	color: #0f172a;
	margin: 0 0 8px;
}

.cgw-success-desc {
	font-size: 13px;
	color: #64748b;
	line-height: 1.5;
	margin: 0 0 24px;
}

.cgw-reset-btn {
	background: #f1f5f9;
	color: #0d54c0;
	border: 1px solid #cbd5e1;
	padding: 9px 18px;
	font-size: 13.5px;
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.cgw-reset-btn:hover {
	background: #e2e8f0;
	color: #0b459e;
}

/* ==========================================================================
   Footer note
   ========================================================================== */

.cgw-footer-note {
	background: #f8fafc;
	border-top: 1px solid #f1f5f9;
	padding: 9px 16px;
	text-align: center;
	font-size: 11.5px;
	color: #64748b;
	font-weight: 500;
}

/* ==========================================================================
   Custom HTML Mode Styling (Fallback)
   ========================================================================== */

.cgw-custom-html-wrapper table {
	width: 100%;
	border-collapse: collapse;
}

.cgw-custom-html-wrapper table td {
	padding: 6px 0;
	font-size: 13px;
}

.cgw-custom-html-wrapper input[type="text"],
.cgw-custom-html-wrapper input[type="email"],
.cgw-custom-html-wrapper textarea,
.cgw-custom-html-wrapper select {
	width: 100%;
	padding: 8px 10px;
	font-size: 13px;
	border: 1px solid #cbd5e1;
	border-radius: 8px;
}

.cgw-custom-html-wrapper input[type="submit"] {
	width: 100%;
	background: #0d54c0;
	color: #ffffff;
	border: none;
	padding: 10px;
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
	margin-top: 10px;
}

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

@media (max-width: 480px) {
	.cgw-window {
		width: calc(100vw - 24px);
		bottom: 70px;
		right: 0 !important;
		left: auto !important;
		max-height: 85vh;
	}

	.cgw-trigger-pill {
		display: none !important;
	}

	.cgw-trigger-btn {
		width: 52px;
		height: 52px;
	}
}
