/**
 * tt-chat.css — ThinkAI Chat Widget
 *
 * Floating chat button + sliding chat window.
 * Mobile-first, không dùng jQuery, không xung đột Bootstrap.
 *
 * @package AstraThinkAI
 * @since   1.3.0
 */

/* ── Variables ─────────────────────────────────────────────── */
:root {
	--tt-chat-primary:       #1e40af;
	--tt-chat-primary-dark:  #1d3a9b;
	--tt-chat-accent:        #3b82f6;
	--tt-chat-bg:            #ffffff;
	--tt-chat-bot-bg:        #f0f4ff;
	--tt-chat-user-bg:       #1e40af;
	--tt-chat-user-text:     #ffffff;
	--tt-chat-border:        #e2e8f0;
	--tt-chat-text:          #1e293b;
	--tt-chat-muted:         #64748b;
	--tt-chat-shadow:        0 8px 32px rgba(0, 0, 0, 0.18);
	--tt-chat-radius:        16px;
	--tt-chat-btn-size:      56px;
}

/* ── Floating Button ───────────────────────────────────────── */
#tt-chat-btn {
	position:        fixed;
	bottom:          24px;
	right:           24px;
	width:           var(--tt-chat-btn-size);
	height:          var(--tt-chat-btn-size);
	border-radius:   50%;
	background:      var(--tt-chat-primary);
	color:           #fff;
	border:          none;
	cursor:          pointer;
	box-shadow:      var(--tt-chat-shadow);
	z-index:         9999;
	display:         flex;
	align-items:     center;
	justify-content: center;
	font-size:       24px;
	opacity:         0;
	transform:       scale(0);
	transition:      opacity 0.35s ease, transform 0.35s ease, background 0.2s;
}

#tt-chat-btn.tt-chat-visible {
	opacity:   1;
	transform: scale(1);
}

#tt-chat-btn:hover {
	background: var(--tt-chat-primary-dark);
	transform:  scale(1.06);
}

#tt-chat-btn:active {
	transform: scale(0.94);
}

#tt-chat-btn svg {
	display:       block;
	pointer-events: none;
}

/* Notification badge (ẩn mặc định) */
#tt-chat-badge {
	position:        absolute;
	top:             -4px;
	right:           -4px;
	background:      #ef4444;
	color:           #fff;
	border-radius:   50%;
	width:           18px;
	height:          18px;
	font-size:       11px;
	font-weight:     700;
	display:         none;
	align-items:     center;
	justify-content: center;
	pointer-events:  none;
}

/* ── Chat Window ───────────────────────────────────────────── */
#tt-chat-window {
	position:       fixed;
	bottom:         92px;
	right:          24px;
	width:          360px;
	max-height:     520px;
	background:     var(--tt-chat-bg);
	border-radius:  var(--tt-chat-radius);
	box-shadow:     var(--tt-chat-shadow);
	z-index:        9998;
	display:        flex;
	flex-direction: column;
	overflow:       hidden;
	border:         1px solid var(--tt-chat-border);
	transform:      translateY(20px) scale(0.96);
	opacity:        0;
	pointer-events: none;
	transition:     transform 0.28s ease, opacity 0.28s ease;
}

#tt-chat-window.tt-chat-open {
	transform:      translateY(0) scale(1);
	opacity:        1;
	pointer-events: all;
}

/* Mobile */
@media (max-width: 480px) {
	#tt-chat-window {
		bottom:        0;
		right:         0;
		left:          0;
		width:         100%;
		max-height:    72vh;
		border-radius: var(--tt-chat-radius) var(--tt-chat-radius) 0 0;
	}

	#tt-chat-btn {
		bottom: 16px;
		right:  16px;
	}
}

/* ── Header ────────────────────────────────────────────────── */
#tt-chat-header {
	background:  var(--tt-chat-primary);
	color:       #fff;
	padding:     12px 14px;
	display:     flex;
	align-items: center;
	gap:         10px;
	flex-shrink: 0;
}

.tt-chat-avatar {
	width:           36px;
	height:          36px;
	border-radius:   50%;
	background:      rgba(255, 255, 255, 0.2);
	display:         flex;
	align-items:     center;
	justify-content: center;
	font-size:       18px;
	flex-shrink:     0;
}

.tt-chat-header-info {
	flex:      1;
	min-width: 0;
}

.tt-chat-header-name {
	font-weight:   600;
	font-size:     15px;
	line-height:   1.2;
	white-space:   nowrap;
	overflow:      hidden;
	text-overflow: ellipsis;
}

.tt-chat-header-status {
	font-size:   12px;
	opacity:     0.85;
	display:     flex;
	align-items: center;
	gap:         5px;
	margin-top:  2px;
}

.tt-chat-status-dot {
	width:         7px;
	height:        7px;
	border-radius: 50%;
	background:    #4ade80;
	flex-shrink:   0;
}

.tt-chat-status-dot.offline {
	background: #fbbf24;
}

#tt-chat-close {
	background:  none;
	border:      none;
	color:       rgba(255, 255, 255, 0.75);
	cursor:      pointer;
	font-size:   18px;
	line-height: 1;
	padding:     4px 6px;
	border-radius: 4px;
	transition:  background 0.15s, color 0.15s;
	flex-shrink: 0;
}

#tt-chat-close:hover {
	background: rgba(255, 255, 255, 0.18);
	color:      #fff;
}

/* ── Messages Area ─────────────────────────────────────────── */
#tt-chat-messages {
	flex:            1;
	overflow-y:      auto;
	padding:         14px 12px;
	display:         flex;
	flex-direction:  column;
	gap:             8px;
	scroll-behavior: smooth;
}

#tt-chat-messages::-webkit-scrollbar      { width: 4px; }
#tt-chat-messages::-webkit-scrollbar-track { background: transparent; }
#tt-chat-messages::-webkit-scrollbar-thumb {
	background:    #cbd5e1;
	border-radius: 2px;
}

/* ── Message Bubbles ───────────────────────────────────────── */
.tt-chat-msg {
	display:    flex;
	gap:        8px;
	animation:  ttFadeUp 0.22s ease;
	max-width:  92%;
}

@keyframes ttFadeUp {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

.tt-chat-msg--bot  { align-self: flex-start; }
.tt-chat-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.tt-chat-bubble {
	padding:     10px 13px;
	border-radius: 14px;
	font-size:   14px;
	line-height: 1.55;
	word-break:  break-word;
}

.tt-chat-msg--bot  .tt-chat-bubble {
	background:    var(--tt-chat-bot-bg);
	color:         var(--tt-chat-text);
	border-radius: 4px 14px 14px 14px;
}

.tt-chat-msg--user .tt-chat-bubble {
	background:    var(--tt-chat-user-bg);
	color:         var(--tt-chat-user-text);
	border-radius: 14px 4px 14px 14px;
}

/* Typing indicator */
.tt-chat-typing {
	display:     flex;
	gap:         4px;
	align-items: center;
	padding:     10px 13px !important;
}

.tt-chat-typing span {
	width:         7px;
	height:        7px;
	background:    #94a3b8;
	border-radius: 50%;
	display:       block;
	animation:     ttBlink 1.2s infinite;
}

.tt-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.tt-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ttBlink {
	0%, 60%, 100% { transform: translateY(0); opacity: 1; }
	30%           { transform: translateY(-5px); opacity: 0.6; }
}

/* ── Maintenance Panel ─────────────────────────────────────── */
#tt-chat-maintenance {
	padding:     24px 18px;
	text-align:  center;
	color:       var(--tt-chat-muted);
	font-size:   14px;
	line-height: 1.6;
}

.tt-chat-maint-icon {
	font-size:     36px;
	margin-bottom: 10px;
	display:       block;
}

/* ── Telegram Button ───────────────────────────────────────── */
.tt-chat-telegram-btn {
	display:         flex;
	align-items:     center;
	justify-content: center;
	gap:             8px;
	background:      #2481cc;
	color:           #fff !important;
	border:          none;
	border-radius:   10px;
	padding:         10px 16px;
	font-size:       14px;
	font-weight:     500;
	cursor:          pointer;
	width:           100%;
	margin-top:      10px;
	text-decoration: none !important;
	transition:      background 0.18s;
}

.tt-chat-telegram-btn:hover {
	background: #1a6faa;
	color:      #fff !important;
}

/* ── Footer (Telegram fallback slot) ──────────────────────── */
#tt-chat-footer {
	padding:    0 12px 12px;
	flex-shrink: 0;
}

/* ── Input Area ────────────────────────────────────────────── */
#tt-chat-input-area {
	display:     flex;
	gap:         8px;
	padding:     10px 12px;
	border-top:  1px solid var(--tt-chat-border);
	flex-shrink: 0;
	align-items: flex-end;
}

#tt-chat-input {
	flex:          1;
	border:        1px solid var(--tt-chat-border);
	border-radius: 20px;
	padding:       9px 14px;
	font-size:     14px;
	font-family:   inherit;
	resize:        none;
	max-height:    100px;
	outline:       none;
	transition:    border-color 0.15s;
	line-height:   1.45;
	background:    #fff;
	color:         var(--tt-chat-text);
}

#tt-chat-input:focus { border-color: var(--tt-chat-accent); }

#tt-chat-send {
	width:           38px;
	height:          38px;
	border-radius:   50%;
	background:      var(--tt-chat-primary);
	color:           #fff;
	border:          none;
	cursor:          pointer;
	display:         flex;
	align-items:     center;
	justify-content: center;
	flex-shrink:     0;
	transition:      background 0.15s, transform 0.1s;
}

#tt-chat-send:hover    { background: var(--tt-chat-primary-dark); }
#tt-chat-send:active   { transform: scale(0.9); }
#tt-chat-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Preview bubble ──────────────────────────────────────────────────────── */

.tt-chat-preview {
	position:      fixed;
	bottom:        88px;
	right:         20px;
	background:    #fff;
	border-radius: 14px;
	box-shadow:    0 4px 24px rgba(0,0,0,.16);
	padding:       14px 38px 14px 16px;
	max-width:     260px;
	min-width:     180px;
	cursor:        pointer;
	z-index:       9998;
	font-family:   inherit;
	font-size:     14px;
	line-height:   1.45;
	color:         #333;
	animation:     tt-preview-in .3s ease both;
	border-left:   4px solid var(--tt-chat-primary, #1e40af);
}

.tt-chat-preview p {
	margin: 0;
}

.tt-chat-preview-close {
	position:   absolute;
	top:        8px;
	right:      8px;
	background: none;
	border:     none;
	cursor:     pointer;
	font-size:  12px;
	color:      #aaa;
	padding:    2px 4px;
	line-height: 1;
	border-radius: 4px;
}

.tt-chat-preview-close:hover { color: #555; background: #f0f0f0; }

.tt-chat-preview-hide {
	animation: tt-preview-out .3s ease both;
}

@keyframes tt-preview-in {
	from { opacity: 0; transform: translateY(10px) scale(.97); }
	to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

@keyframes tt-preview-out {
	from { opacity: 1; transform: translateY(0)    scale(1);   }
	to   { opacity: 0; transform: translateY(10px) scale(.97); }
}
