/* =========================
   Layout
========================= */
.tw-container {
    width:835px;
	margin:0 auto;
	/*
    margin:40px auto;
    padding:20px;
	*/
}

.tw-card {
    background:#fff;
    border-radius:18px;
    box-shadow:0 12px 30px rgba(0,0,0,0.08);
    overflow:hidden;
    border:1px solid #e5e7eb;
}

/* =====================
   Header Layout
===================== */

.tw-header {
    padding:18px 22px;
    border-bottom:1px solid #eee;
    background:#fafafa;
    font-weight:600;
    font-size:18px;

    display:flex;
    align-items:center;
    justify-content:space-between;
}

.tw-header-left {
    display:flex;
    align-items:center;
    gap:8px;
}

.tw-header-left i {
    color:#6366f1;
}

/* =====================
   New Chat Button
===================== */

.new-chat-btn {
    height:38px;
    padding:0 16px;
    border-radius:12px;
    border:1px solid #e5e7eb;
    background:#fff;
    font-size:13px;
    font-weight:600;
    cursor:pointer;
    display:flex;
    align-items:center;
    gap:6px;
    transition:.2s;
}

.new-chat-btn i {
    color:#6366f1;
}

.new-chat-btn:hover {
    background:#f5f7ff;
    border-color:#6366f1;
}

/* =========================
   Chat Area
========================= */
.chat-area {
    height:520px;
    overflow-y:auto;
    padding:22px;
    background:#f9fafb;
}

.chat-row {
    display:flex;
    margin-bottom:18px;
}

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

.chat-bubble {
    max-width:72%;
    padding:13px 16px;
    border-radius:16px;
    font-size:14px;
    line-height:1.6;
    word-break:break-word;
}

/* Bot */
.chat-bubble.bot {
    background:#eef2f7;
    color:#222;
}

/* User */
.chat-bubble.user {
    background:#6366f1;
    color:#fff;
}

/* Bubble */
.msg-bubble {
    max-width:80%;
    padding:14px 16px;
    border-radius:18px;
    font-size:14px;
    line-height:1.6;
    word-break:break-word;
    position:relative;
}

/* Bot */
.msg-bubble.bot {
    background:#ffffff;
    border:1px solid #e5e7eb;
    color:#1f2937;
}

/* User */
.msg-bubble.user {
    background:#6366f1;
    color:#fff;
    box-shadow:0 8px 20px rgba(99,102,241,.25);
}

/* Avatar */
.msg-avatar {
    width:34px;
    height:34px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    margin-right:10px;
    background:#eef2ff;
    color:#6366f1;
    font-size:15px;
}

/* =========================
   Input Area
========================= */
.input-area {
    padding:16px;
    border-top:1px solid #eee;
    background:#fff;
}

.input-wrap {
    display:flex;
    gap:10px;
}

.chat-input {
    flex:1;
    padding:13px 14px;
    border-radius:12px;
    border:1px solid #ddd;
    font-size:14px;
    transition:all .2s;
}

.chat-input:focus {
    border-color:#6366f1;
    outline:none;
    box-shadow:0 0 0 2px rgba(99,102,241,0.15);
}

.send-btn {
    padding:0 24px;
    border-radius:12px;
    border:none;
    background:#6366f1;
    color:#fff;
    font-weight:600;
    cursor:pointer;
    transition:all .2s;
}

.send-btn:hover {
    background:#5558e3;
}

/* =========================
   Scrollbar
========================= */
.chat-scroll::-webkit-scrollbar { width:4px; }
.chat-scroll::-webkit-scrollbar-track { background:transparent; }
.chat-scroll::-webkit-scrollbar-thumb { background:#e2e8f0; border-radius:10px; }

/* =========================
   Loading Animation
========================= */
.loading-dots:after {
    content:' .';
    animation:dots 1s steps(5,end) infinite;
}

@keyframes dots {
    0%,20% {
        color:rgba(0,0,0,0);
        text-shadow:.25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0);
    }
    40% {
        color:#6366f1;
        text-shadow:.25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0);
    }
    60% {
        text-shadow:.25em 0 0 #6366f1, .5em 0 0 rgba(0,0,0,0);
    }
    80%,100% {
        text-shadow:.25em 0 0 #6366f1, .5em 0 0 #6366f1;
    }
}

/* =========================
   Mobile
========================= */
@media (max-width:768px){
    .tw-container {
        margin:10px;
        padding:10px;
    }
    .chat-area {
        height:420px;
    }
}


.msg-bubble.bot.typing::after {
    content: "●";
    margin-left: 5px;
    font-size: 10px;
    animation: blink 0.8s infinite;
    vertical-align: middle;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* =========================
   Error Message
========================= */
.error-text {
    margin-top: 8px;
    padding: 10px 14px;
    background-color: #fef2f2;
    border: 1px solid #fee2e2;
    border-radius: 10px;
    color: #dc2626 !important;
    font-size: 13px !important;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: fadeIn 0.3s ease-out; 
}

.error-text::before {
    content: "\f06a";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.tw-header { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid #eee; }
.new-chat-btn { cursor: pointer; background: #f8f9fa; border: 1px solid #ddd; padding: 5px 12px; border-radius: 5px; font-size: 13px; }
.new-chat-btn:hover { background: #e9ecef; }