/* ===========================================
   تراث كود شات - تصميم الودجت العام
   =========================================== */

#tcc-widget-wrapper, #tcc-widget-wrapper * {
    box-sizing: border-box;
}

.tcc-widget-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: 'Tahoma', 'Segoe UI', Arial, sans-serif;
    direction: rtl;
}

:root {
    --tcc-primary-color: #1e8e5a;
    --tcc-online-color: #2ecc71;
}

/* ---------- الأيقونة العائمة ---------- */
.tcc-bubble-btn {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--tcc-primary-color);
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}

.tcc-bubble-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

/* مؤشر "رسالة جديدة": نبضة حمراء صغيرة فوق الأيقونة لما يرد الأدمن والشات مقفول */
.tcc-widget-wrapper.tcc-has-new-message .tcc-bubble-btn::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 16px;
    height: 16px;
    background: #e74c3c;
    border: 2px solid #fff;
    border-radius: 50%;
    animation: tcc-pulse 1.4s infinite;
}

.tcc-bubble-logo-wrap {
    position: relative;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tcc-bubble-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.tcc-bubble-close-icon {
    display: none;
    color: #fff;
}

.tcc-widget-wrapper.tcc-open .tcc-bubble-logo-wrap {
    display: none;
}

.tcc-widget-wrapper.tcc-open .tcc-bubble-close-icon {
    display: flex;
}

/* نقطة "متصل الآن" */
.tcc-online-dot {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 14px;
    height: 14px;
    background: var(--tcc-online-color);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    animation: tcc-pulse 2s infinite;
}

.tcc-online-dot-small {
    width: 10px;
    height: 10px;
    border-width: 2px;
}

@keyframes tcc-pulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55); }
    70% { box-shadow: 0 0 0 6px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

.tcc-dot-inline {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tcc-online-color);
    margin-left: 5px;
}

/* ---------- نافذة المحادثة ---------- */
.tcc-chat-window {
    position: fixed;
    bottom: 95px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 30px);
    height: 520px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.tcc-widget-wrapper.tcc-open .tcc-chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* الهيدر */
.tcc-chat-header {
    background: var(--tcc-primary-color);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.tcc-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tcc-header-logo-wrap {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.tcc-header-logo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
}

.tcc-header-text {
    display: flex;
    flex-direction: column;
}

.tcc-header-title {
    font-size: 15px;
    font-weight: 700;
}

.tcc-header-subtitle {
    font-size: 12px;
    opacity: 0.92;
    display: flex;
    align-items: center;
}

.tcc-header-close-btn {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.tcc-header-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* جسم الرسائل */
.tcc-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    background: #f4f6f8;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tcc-chat-body::-webkit-scrollbar {
    width: 6px;
}
.tcc-chat-body::-webkit-scrollbar-thumb {
    background: #c7cdd3;
    border-radius: 10px;
}

.tcc-msg {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 100%;
    animation: tcc-fade-in 0.2s ease;
}

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

.tcc-msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

.tcc-msg-bubble {
    background: #fff;
    color: #222;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    max-width: 78%;
    word-wrap: break-word;
}

.tcc-msg-user {
    flex-direction: row-reverse;
}

.tcc-msg-user .tcc-msg-bubble {
    background: var(--tcc-primary-color);
    color: #fff;
}

/* رد مباشر من الأدمن (يختلف بصرياً عن الرد التلقائي) */
.tcc-msg-admin .tcc-msg-bubble {
    background: #2563eb;
    color: #fff;
}

.tcc-msg-admin .tcc-msg-bubble::before {
    content: 'فريق العيادة';
    display: block;
    font-size: 10px;
    opacity: 0.8;
    margin-bottom: 3px;
}

/* قائمة الفئات */
.tcc-categories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-right: 34px;
}

.tcc-category-btn,
.tcc-question-btn {
    background: #fff;
    border: 1px solid #e1e5ea;
    color: #222;
    text-align: right;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.tcc-category-btn:hover,
.tcc-question-btn:hover {
    background: #f0fdf7;
    border-color: var(--tcc-primary-color);
}

.tcc-category-btn svg {
    transform: rotate(180deg);
    color: var(--tcc-primary-color);
    flex-shrink: 0;
}

.tcc-questions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-right: 34px;
}

.tcc-back-btn {
    background: none;
    border: none;
    color: var(--tcc-primary-color);
    font-size: 12.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 2px;
    margin-right: 34px;
    align-self: flex-start;
}

/* مؤشر الكتابة */
.tcc-typing {
    display: flex;
    gap: 4px;
    padding: 10px 13px;
    background: #fff;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.tcc-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9aa3ad;
    animation: tcc-typing-bounce 1.2s infinite;
}
.tcc-typing span:nth-child(2) { animation-delay: 0.15s; }
.tcc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes tcc-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* خانة الكتابة */
.tcc-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #ebedf0;
    background: #fff;
    flex-shrink: 0;
}

.tcc-input-field {
    flex: 1;
    border: 1px solid #e1e5ea;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 13.5px;
    outline: none;
    font-family: inherit;
    background: #f7f8fa;
}

.tcc-input-field:focus {
    border-color: var(--tcc-primary-color);
}

.tcc-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--tcc-primary-color);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.tcc-send-btn svg {
    transform: scaleX(-1);
}

.tcc-send-btn:hover {
    opacity: 0.9;
}

.tcc-footer-credit {
    text-align: center;
    font-size: 10.5px;
    color: #aab0b6;
    padding: 5px 0 8px;
    background: #fff;
}

.tcc-footer-credit span {
    color: var(--tcc-primary-color);
    font-weight: 600;
}

/* ---------- تجاوب الموبايل ---------- */
@media (max-width: 480px) {
    .tcc-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 110px);
        bottom: 88px;
        right: 10px;
    }
    .tcc-widget-wrapper {
        right: 14px;
        bottom: 14px;
    }
}
