/* ==========================================================================
   TALHA AI ENTERPRISE - CHAT MESSAGES (chat.css v2)
   ========================================================================== */

.chat-wrapper {
   flex: 1;
   display: flex;
   flex-direction: column;
   height: 100vh;
   overflow: hidden;
   position: relative;
}

/* Header */
.chat-header {
   height: var(--header-height);
   padding: 0 24px;
   display: flex;
   align-items: center;
   justify-content: space-between;
   background: var(--bg-glass-heavy);
   backdrop-filter: var(--glass-backdrop);
   -webkit-backdrop-filter: var(--glass-backdrop);
   border-bottom: 1px solid var(--border-color);
   z-index: 100;
}

.chat-header-left {
   display: flex;
   align-items: center;
   gap: 14px;
}

.sidebar-toggle-btn {
   width: 36px;
   height: 36px;
   display: flex;
   align-items: center;
   justify-content: center;
   border-radius: var(--radius-sm);
   color: var(--text-secondary);
   background: rgba(255, 255, 255, 0.04);
   border: 1px solid var(--border-color);
   transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
   background: rgba(255, 255, 255, 0.1);
   color: var(--text-primary);
}

.header-title-container {
   display: flex;
   align-items: center;
   gap: 10px;
}

.header-avatar {
   width: 34px;
   height: 34px;
   border-radius: var(--radius-sm);
   object-fit: cover;
   border: 1px solid var(--border-light);
}

.header-title {
   font-size: 17px;
   font-weight: 700;
   letter-spacing: -0.2px;
}

.chat-header-right {
   display: flex;
   align-items: center;
   gap: 12px;
}

.status-badge {
   display: inline-flex;
   align-items: center;
   gap: 6px;
   padding: 4px 10px;
   background: rgba(16, 185, 129, 0.1);
   border: 1px solid rgba(16, 185, 129, 0.3);
   border-radius: var(--radius-full);
   font-size: 12px;
   font-weight: 600;
   color: var(--accent-emerald);
}

.status-badge.disconnected {
   background: rgba(244, 63, 94, 0.1);
   border-color: rgba(244, 63, 94, 0.3);
   color: var(--accent-rose);
}

.status-dot {
   width: 7px;
   height: 7px;
   border-radius: 50%;
   background: var(--accent-emerald);
   box-shadow: 0 0 8px var(--accent-emerald);
   animation: statusPulse 2s infinite;
}

.status-badge.disconnected .status-dot {
   background: var(--accent-rose);
   box-shadow: 0 0 8px var(--accent-rose);
   animation: none;
}

.tech-pills {
   display: flex;
   align-items: center;
   gap: 6px;
}

.tech-pill {
   padding: 3px 9px;
   background: rgba(255, 255, 255, 0.05);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-sm);
   font-size: 11.5px;
   font-weight: 500;
   color: var(--text-secondary);
}

/* Messages Area */
.chat-messages-container {
   flex: 1;
   overflow-y: auto;
   padding: 24px 0 170px;
   scroll-behavior: smooth;
   display: flex;
   flex-direction: column;
   align-items: center;
}

.chat-messages-inner {
   width: 100%;
   max-width: 860px;
   padding: 0 24px;
   display: flex;
   flex-direction: column;
   gap: 24px;
}

/* Welcome Hero */
.welcome-hero {
   display: flex;
   flex-direction: column;
   align-items: center;
   text-align: center;
   padding: 40px 20px;
   max-width: 640px;
   margin: auto;
}

.welcome-logo-wrapper {
   width: 72px;
   height: 72px;
   margin-bottom: 20px;
}

.welcome-logo {
   width: 100%;
   height: 100%;
   border-radius: var(--radius-lg);
   box-shadow: var(--shadow-glow);
}

.welcome-title {
   font-size: 28px;
   font-weight: 800;
   background: var(--gradient-primary);
   -webkit-background-clip: text;
   background-clip: text;
   -webkit-text-fill-color: transparent;
   margin-bottom: 10px;
}

.welcome-subtitle {
   font-size: 15px;
   color: var(--text-secondary);
   margin-bottom: 28px;
   line-height: 1.65;
}

.starter-suggestions {
   display: grid;
   grid-template-columns: repeat(2, 1fr);
   gap: 12px;
   width: 100%;
}

.suggestion-card {
   display: flex;
   flex-direction: column;
   align-items: flex-start;
   padding: 14px 16px;
   background: var(--bg-card);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-md);
   text-align: left;
   cursor: pointer;
   transition: all var(--transition-fast);
}

.suggestion-card:hover {
   background: var(--bg-card-hover);
   border-color: var(--border-glow);
   transform: translateY(-2px);
   box-shadow: var(--shadow-md);
}

.suggestion-card .icon {
   font-size: 18px;
   margin-bottom: 6px;
}

.suggestion-card .title {
   font-weight: 600;
   font-size: 13.5px;
}

.suggestion-card .desc {
   font-size: 12px;
   color: var(--text-muted);
}

/* Message Rows */
.message-row {
   display: flex;
   width: 100%;
   gap: 14px;
   opacity: 0;
   transform: translateY(12px);
   animation: messageSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.user-row {
   justify-content: flex-end;
}

.message-avatar {
   width: 36px;
   height: 36px;
   border-radius: var(--radius-sm);
   object-fit: cover;
   flex-shrink: 0;
   box-shadow: var(--shadow-sm);
}

.message-bubble-wrapper {
   display: flex;
   flex-direction: column;
   max-width: 82%;
}

.user-row .message-bubble-wrapper {
   align-items: flex-end;
}

.message-sender-name {
   font-size: 12px;
   font-weight: 600;
   color: var(--text-muted);
   margin-bottom: 4px;
   padding: 0 4px;
}

.message-bubble {
   padding: 14px 18px;
   border-radius: var(--radius-lg);
   font-size: 15px;
   line-height: 1.65;
   word-break: break-word;
   position: relative;
   box-shadow: var(--shadow-sm);
}

.assistant-row .message-bubble {
   background: var(--bg-card);
   backdrop-filter: var(--glass-backdrop);
   border: 1px solid var(--border-color);
   color: var(--text-primary);
   border-top-left-radius: 4px;
}

.user-row .message-bubble {
   background: var(--gradient-user);
   color: #fff;
   border-top-right-radius: 4px;
   box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
}

/* Message Action Buttons */
.message-actions {
   display: flex;
   gap: 6px;
   margin-top: 6px;
   margin-bottom: 8px;
   opacity: 0;
   transition: opacity var(--transition-fast);
}

.message-row:hover .message-actions {
   opacity: 1;
}

.msg-action-btn {
   padding: 4px 10px;
   font-size: 11.5px;
   color: var(--text-muted);
   background: rgba(255, 255, 255, 0.05);
   border: 1px solid var(--border-color);
   border-radius: 4px;
   transition: all var(--transition-fast);
}

.msg-action-btn:hover {
   color: var(--text-primary);
   background: rgba(255, 255, 255, 0.12);
}

/* Tool Execution Timeline Cards */
.tool-status-card {
   display: inline-flex;
   align-items: center;
   gap: 10px;
   padding: 8px 14px;
   margin: 6px 0;
   background: rgba(15, 23, 42, 0.7);
   border: 1px solid var(--border-glow);
   border-radius: var(--radius-md);
   font-size: 13px;
   color: var(--text-secondary);
   font-family: var(--font-code);
   transition: all var(--transition-fast);
}

.tool-status-card.running {
   border-color: rgba(99, 102, 241, 0.5);
   background: rgba(99, 102, 241, 0.08);
}

.tool-status-card.completed {
   border-color: rgba(16, 185, 129, 0.5);
   color: var(--accent-emerald);
}

.tool-spinner {
   width: 14px;
   height: 14px;
   border: 2px solid rgba(99, 102, 241, 0.3);
   border-top-color: var(--primary);
   border-radius: 50%;
   animation: spin 0.8s linear infinite;
   flex-shrink: 0;
}

/* Thinking Indicator — animated dots only (no "Thinking" text) */
.thinking-indicator {
   display: inline-flex;
   align-items: center;
   gap: 6px;
   padding: 14px 18px;
   background: var(--bg-card);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-lg);
   border-top-left-radius: 4px;
}

.thinking-indicator .dot {
   width: 7px;
   height: 7px;
   display: inline-block;
   background: var(--primary);
   border-radius: 50%;
   animation: pulseDot 1.4s infinite ease-in-out both;
}

.thinking-indicator .dot:nth-child(1) {
   animation-delay: -0.32s;
}

.thinking-indicator .dot:nth-child(2) {
   animation-delay: -0.16s;
}

.thinking-indicator .dot:nth-child(3) {
   animation-delay: 0s;
}

/* Markdown Content Styles */
.message-bubble p {
   margin-bottom: 10px;
}

.message-bubble p:last-child {
   margin-bottom: 0;
}

.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
   margin: 14px 0 6px;
}

.message-bubble ul,
.message-bubble ol {
   margin: 8px 0 12px 22px;
}

.message-bubble li {
   margin-bottom: 3px;
}

.message-bubble blockquote {
   border-left: 3px solid var(--primary);
   padding: 8px 12px 8px 16px;
   margin: 10px 0;
   color: var(--text-secondary);
   font-style: italic;
   background: rgba(99, 102, 241, 0.06);
   border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-bubble table {
   width: 100%;
   border-collapse: collapse;
   margin: 12px 0;
   font-size: 14px;
}

.message-bubble th,
.message-bubble td {
   padding: 8px 12px;
   border: 1px solid var(--border-color);
   text-align: left;
}

.message-bubble th {
   background: rgba(255, 255, 255, 0.06);
   font-weight: 600;
}

.message-bubble code:not(pre code) {
   font-family: var(--font-code);
   font-size: 13px;
   padding: 2px 6px;
   background: rgba(255, 255, 255, 0.1);
   border-radius: 4px;
}

.user-row .message-bubble code:not(pre code) {
   background: rgba(0, 0, 0, 0.25);
}

.message-bubble a {
   color: var(--accent-cyan);
}

.message-bubble hr {
   border: none;
   border-top: 1px solid var(--border-color);
   margin: 12px 0;
}

/* Code Blocks */
.code-block-wrapper {
   margin: 12px 0;
   border-radius: var(--radius-md);
   overflow: hidden;
   border: 1px solid var(--border-light);
   background: #0d1117;
   box-shadow: var(--shadow-sm);
}

.code-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 8px 14px;
   background: #161b22;
   border-bottom: 1px solid var(--border-color);
   font-family: var(--font-code);
   font-size: 12px;
   color: var(--text-muted);
}

.code-lang-tag {
   font-weight: 600;
   color: var(--accent-cyan);
   text-transform: lowercase;
}

.code-actions {
   display: flex;
   align-items: center;
   gap: 8px;
}

.code-action-btn {
   display: flex;
   align-items: center;
   gap: 4px;
   padding: 3px 8px;
   font-size: 11.5px;
   color: var(--text-secondary);
   background: rgba(255, 255, 255, 0.05);
   border: 1px solid var(--border-color);
   border-radius: 4px;
   transition: all var(--transition-fast);
}

.code-action-btn:hover {
   background: rgba(255, 255, 255, 0.15);
   color: var(--text-primary);
}

.code-block-content {
   padding: 14px 16px;
   overflow-x: auto;
   font-family: var(--font-code);
   font-size: 13.5px;
   line-height: 1.55;
}

.code-block-content pre {
   margin: 0;
}

.code-block-wrapper.collapsed .code-block-content {
   display: none;
}

/* Input Dock */
.chat-input-wrapper {
   position: absolute;
   bottom: 0;
   left: 0;
   right: 0;
   padding: 16px 24px 20px;
   background: linear-gradient(180deg, rgba(11, 15, 25, 0) 0%, rgba(11, 15, 25, 0.96) 40%, rgba(11, 15, 25, 1) 100%);
   display: flex;
   flex-direction: column;
   align-items: center;
   z-index: 100;
}

.chat-input-box {
   width: 100%;
   max-width: 860px;
   background: var(--bg-card-hover);
   backdrop-filter: var(--glass-backdrop);
   border: 1px solid var(--border-light);
   border-radius: var(--radius-xl);
   padding: 10px 14px;
   display: flex;
   flex-direction: column;
   box-shadow: var(--shadow-lg), var(--shadow-glow);
   transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-input-box:focus-within {
   border-color: var(--border-glow);
   box-shadow: var(--shadow-lg), 0 0 24px rgba(99, 102, 241, 0.3);
}

.attachment-preview-container {
   display: flex;
   gap: 8px;
   padding: 0 6px 6px;
   flex-wrap: wrap;
}

.attachment-chip {
   display: inline-flex;
   align-items: center;
   gap: 6px;
   padding: 4px 10px;
   background: rgba(255, 255, 255, 0.08);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-sm);
   font-size: 12px;
}

.attachment-chip-remove {
   cursor: pointer;
   color: var(--text-muted);
   font-weight: bold;
}

.attachment-chip-remove:hover {
   color: var(--accent-rose);
}

.chat-textarea {
   width: 100%;
   min-height: 48px;
   max-height: 200px;
   padding: 10px 8px;
   resize: none;
   line-height: 1.5;
   color: var(--text-primary);
   font-size: 15px;
}

.chat-textarea::placeholder {
   color: var(--text-muted);
}

.chat-input-toolbar {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding-top: 6px;
}

.toolbar-actions-left,
.toolbar-actions-right {
   display: flex;
   align-items: center;
   gap: 6px;
}

.toolbar-btn {
   width: 36px;
   height: 36px;
   display: flex;
   align-items: center;
   justify-content: center;
   border-radius: var(--radius-full);
   color: var(--text-secondary);
   transition: all var(--transition-fast);
}

.toolbar-btn:hover {
   background: rgba(255, 255, 255, 0.08);
   color: var(--text-primary);
}

.toolbar-btn.recording {
   color: var(--accent-rose);
   background: rgba(244, 63, 94, 0.15);
   animation: pulseRecord 1.2s infinite;
}

.send-btn {
   width: 40px;
   height: 40px;
   border-radius: var(--radius-full);
   background: var(--gradient-primary);
   color: #fff;
   display: flex;
   align-items: center;
   justify-content: center;
   box-shadow: var(--shadow-sm);
   transition: all var(--transition-fast);
}

.send-btn:hover {
   transform: scale(1.06);
   box-shadow: var(--shadow-glow);
}

.stop-btn {
   width: 40px;
   height: 40px;
   border-radius: var(--radius-full);
   background: var(--accent-rose);
   color: #fff;
   display: flex;
   align-items: center;
   justify-content: center;
   transition: all var(--transition-fast);
}

.stop-btn:hover {
   transform: scale(1.06);
}

.input-disclaimer {
   font-size: 11px;
   color: var(--text-muted);
   margin-top: 8px;
   text-align: center;
}

@keyframes statusPulse {

   0%,
   100% {
      opacity: 1;
   }

   50% {
      opacity: 0.4;
   }
}