/* --- Universal Box-Sizing & Font --- */
#chinaitech-chatbot,
#chinaitech-chatbot * {
    box-sizing: border-box;
}
#chinaitech-chatbot {
    font-family: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
}
/* --- NEW --- Style for the "You Reply" status */
#chinaitech-chatbot .status-you-reply { 
    background-color: #fef3c7; 
    color: #92400e; 
}

/* --- Chat Bubble (Floating Icon) --- */
#chinaitech-chatbot .chat-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #0803b2, #0700ff);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}
#chinaitech-chatbot .chat-bubble:hover {
    transform: scale(1.12) rotate(8deg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
}
#chinaitech-chatbot .chat-bubble svg {
    width: 34px;
    height: 34px;
}

/* --- Chat Window --- */
/* This is the SPECIFICITY FIX from before, keep this */
div#chinaitech-chatbot .chat-window.open {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 80vh;
    max-height: 700px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
    padding-bottom: 10px;
}
div#chinaitech-chatbot .chat-window {
    opacity: 0;
    transform: translateY(15px);
    display: none;
}


/* --- Chat Header --- */
#chinaitech-chatbot .chat-header {
    background: linear-gradient(135deg, #0803b2, #0700ff);
    color: white;
    padding: 16px 20px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
#chinaitech-chatbot .chat-header-title {
    display: flex;
    align-items: center;
    font-size: 18px;
}
#chinaitech-chatbot .chat-logo {
    width: 38px;
    height: 38px;
    margin-right: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
}
#chinaitech-chatbot .chat-title-container {
    display: flex;
    flex-direction: column;
}
#chinaitech-chatbot .chat-subtitle {
    font-size: 11px;
    opacity: 0.85;
    font-weight: 400;
    margin-top: 3px;
}
#chinaitech-chatbot .chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    font-size: 28px;
    font-weight: 300;
}
#chinaitech-chatbot .chat-close:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* --- Chat Body & Messages --- */
#chinaitech-chatbot .chat-body {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#chinaitech-chatbot .bot-message {
    padding: 12px 18px;
    border-radius: 18px;
    background-color: rgb(245, 245, 245);
    color: #1a1818;
    border-bottom-left-radius: 5px;
    align-self: flex-start;
    max-width: 95%;
    font-size: 13px;
    line-height: 1.65;
}
#chinaitech-chatbot .user-message {
    padding: 12px 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, #0803b2, #0e00ff);
    color: white;
    border-bottom-right-radius: 5px;
    align-self: flex-end;
    font-size: 13px;
}

/* NEW: Styles for text content inside a bot message */
#chinaitech-chatbot .bot-message p {
    margin: 0 0 1em 0;
}
#chinaitech-chatbot .bot-message p:last-of-type {
    margin-bottom: 0;
}
#chinaitech-chatbot .bot-message ol,
#chinaitech-chatbot .bot-message ul {
    padding-left: 20px;
    margin: 1em 0;
}
#chinaitech-chatbot .bot-message li {
    margin-bottom: 0.5em;
}
#chinaitech-chatbot .bot-message li:last-child {
    margin-bottom: 0;
}
#chinaitech-chatbot .bot-message h1,
#chinaitech-chatbot .bot-message h2,
#chinaitech-chatbot .bot-message h3,
#chinaitech-chatbot .bot-message h4,
#chinaitech-chatbot .bot-message strong {
    font-weight: 500;
    color: #1e293b;
    margin: 1.2em 0 0.8em 0;
}
#chinaitech-chatbot .bot-message h1:first-child,
#chinaitech-chatbot .bot-message h2:first-child,
#chinaitech-chatbot .bot-message h3:first-child,
#chinaitech-chatbot .bot-message h4:first-child,
#chinaitech-chatbot .bot-message strong:first-child {
    margin-top: 0;
}
#chinaitech-chatbot .bot-message a {
    color: #0700ff;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid rgba(7, 0, 255, 0.3);
    transition: all 0.2s ease;
}
#chinaitech-chatbot .bot-message a:hover {
    background-color: rgba(7, 0, 255, 0.05);
    border-bottom-color: #0700ff;
}

/* --- Typing Indicator --- */
#chinaitech-chatbot .typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 16px;
    background-color: #e2e8f0;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
#chinaitech-chatbot .typing-indicator span {
    height: 7px;
    width: 7px;
    background-color: #6b7280;
    border-radius: 50%;
    display: inline-block;
    margin: 0 3px;
    animation: bounce 1.4s infinite ease-in-out;
}
#chinaitech-chatbot .typing-indicator span:nth-of-type(2) {
    animation-delay: 0.2s;
}
#chinaitech-chatbot .typing-indicator span:nth-of-type(3) {
    animation-delay: 0.4s;
}
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.8); }
    40% { transform: scale(1.2); }
}
@keyframes blink {
    50% { opacity: 0; }
}

/* --- Buttons Styling (Options, Back, Actions) --- */
#chinaitech-chatbot .chat-options {
    margin-top: 12px;
    width: 100%;
}
#chinaitech-chatbot .option-button,
#chinaitech-chatbot .back-button {
    width: 100%;
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border: 1px solid #e5e7eb;
    color: #1f2937;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    font-weight: 500;
    margin-bottom: 8px;
    position: relative;
}
#chinaitech-chatbot .option-button.typing::after {
    content: '|';
    display: inline-block;
    animation: blink 0.7s infinite;
    margin-left: 4px;
}
#chinaitech-chatbot .option-button:hover,
#chinaitech-chatbot .back-button:hover {
    background: linear-gradient(135deg, #f0f2f5, #e5e7eb);
    border-color: #0803b2;
    color: #0803b2;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
#chinaitech-chatbot .back-button {
    text-align: center;
    background: linear-gradient(135deg, #f0f2f5, #e5e7eb);
    margin-top: 12px;
}
#chinaitech-chatbot .chat-options > .back-button {
    margin-top: 0;
    margin-bottom: 12px;
}

/* --- Action Button (Send Message) --- */
#chinaitech-chatbot .action-button {
    background: linear-gradient(to right, #0803b2, #0e00ff);
    color: white;
    text-align: center;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 50px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#chinaitech-chatbot .action-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(109, 40, 217, 0.25), 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* --- MODIFIED: This style is now simpler --- */
#chinaitech-chatbot .message-tab-content {
    display: flex;
    justify-content: center;
    padding-bottom: 20px;
}


/* --- Bottom Navigation Footer --- */
#chinaitech-chatbot .chat-nav {
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    border-top: 1px solid #e5e7eb;
    background-color: #ffffff;
    flex-shrink: 0;
}
#chinaitech-chatbot .nav-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #6b7280;
    flex: 1;
    padding: 8px 0;
    transition: color 0.3s ease;
}
#chinaitech-chatbot .nav-button svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    fill: #6b7280;
    transition: fill 0.3s ease;
}
#chinaitech-chatbot .nav-button:hover,
#chinaitech-chatbot .nav-button.active {
    color: #0803b2;
}
#chinaitech-chatbot .nav-button:hover svg,
#chinaitech-chatbot .nav-button.active svg {
    fill: #0803b2;
}

/* --- Custom Scrollbar Styling --- */
#chinaitech-chatbot .chat-body::-webkit-scrollbar {
    width: 6px;
}
#chinaitech-chatbot .chat-body::-webkit-scrollbar-track {
    background: transparent;
}
#chinaitech-chatbot .chat-body::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 12px;
    border: 2px solid #f8fafc;
}
#chinaitech-chatbot .chat-body::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 480px) {
    div#chinaitech-chatbot .chat-window.open { /* Added specificity */
        width: 100%;
        height: 100%;
        max-height: 100%;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }
    #chinaitech-chatbot .chat-bubble {
        bottom: 95px;
        right: 15px;
    }
}

/* --- News Feed Styles --- */
#chinaitech-chatbot .news-item {
    display: block;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}
#chinaitech-chatbot .news-item:hover {
    border-color: #4F46E5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
#chinaitech-chatbot .news-item h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #1f2937;
}
#chinaitech-chatbot .news-item p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}
#chinaitech-chatbot .news-item small {
    font-size: 12px;
    color: #9ca3af;
}

/* --- NEW TICKET HISTORY STYLES --- */
#chinaitech-chatbot .ticket-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
#chinaitech-chatbot .ticket-item-link {
    display: block;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}
#chinaitech-chatbot .ticket-item-link:hover {
    border-color: #0803b2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
#chinaitech-chatbot .ticket-subject {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#chinaitech-chatbot .ticket-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}
#chinaitech-chatbot .ticket-date {
    color: #6b7280;
}
#chinaitech-chatbot .ticket-status {
    padding: 3px 10px;
    border-radius: 9999px;
    font-weight: 500;
    text-transform: capitalize;
    background-color: #fff06f;
  color: #846300;
}

/* Status Colors - mirrored from your ticket page styles */
#chinaitech-chatbot .status-open { background-color: #dbeafe; color: #1e40af; }
#chinaitech-chatbot .status-answered { background-color: #d1fae5; color: #065f46; }
#chinaitech-chatbot .status-closed { background-color: #fee2e2; color: #991b1b; }
#chinaitech-chatbot .status-customerreply { background-color: #fef3c7; color: #92400e; }

/* --- NEW SECTION TITLE STYLE --- */
#chinaitech-chatbot .chat-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 15px;
    padding-left: 4px;
}

/* --- NEW: Search Container Styles --- */
#chinaitech-chatbot .search-container {
    display: flex;
    margin-top: 15px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background-color: #fff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
#chinaitech-chatbot #chatSearchInput {
    flex-grow: 1;
    border: none;
    padding: 12px 16px;
    font-size: 15px;
    background-color: transparent;
    color: #1f2937;
    outline: none;
}
#chinaitech-chatbot #chatSearchInput::placeholder {
    color: #9ca3af;
}
#chinaitech-chatbot #chatSearchBtn {
    background-color: #f3f4f6;
    border: none;
    padding: 0 16px;
    cursor: pointer;
    color: #4b5568;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}
#chinaitech-chatbot #chatSearchBtn:hover {
    background-color: #e5e7eb;
    color: #0803b2;
}
#chinaitech-chatbot #chatSearchBtn svg {
    width: 20px;
    height: 20px;
}

/* --- NEW STYLES TO FIX POSITIONING --- */
/* This is the new block that fixes the position */
#chinaitech-chatbot .message-tab-actions {
    margin-top: auto; /* This pushes the entire block to the bottom */
    padding-top: 20px; /* Adds space between ticket list and this block */
}
#chinaitech-chatbot .ask-question-title {
    text-align: center;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 10px;
}
/* This rule overrides the general margin for the search container */
#chinaitech-chatbot .message-tab-actions .search-container {
    margin-top: 0;
}