/* Author Chat Premium Glassmorphism styling */

#author-chat-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Chat button pulse and hover styling */
#chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(79, 70, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

#chat-toggle-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 35px rgba(79, 70, 229, 0.6);
}

.chat-pulse {
    animation: chat-subtle-pulse 2s infinite;
}

@keyframes chat-subtle-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(79, 70, 229, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

/* Chat window layout & glassmorphism style */
#chat-window-container {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    height: 520px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 20px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

/* Dark mode compatibility if OJS theme is dark */
@media (prefers-color-scheme: dark) {
    #chat-window-container {
        background: rgba(20, 24, 33, 0.9);
        border-color: rgba(255, 255, 255, 0.1);
        box-shadow: 0 15px 45px rgba(0, 0, 0, 0.4);
    }
}

#chat-window-container.chat-hidden {
    transform: scale(0.6);
    opacity: 0;
    pointer-events: none;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    padding: 18px 20px;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-window-title {
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
}

#chat-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    padding: 0;
    margin: 0;
}

#chat-close-btn:hover {
    color: #ffffff;
}

/* Chat Body */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar for Chat Body */
.chat-body::-webkit-scrollbar {
    width: 6px;
}
.chat-body::-webkit-scrollbar-track {
    background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}
@media (prefers-color-scheme: dark) {
    .chat-body::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.15);
    }
}

/* Messages styling */
.chat-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    margin-bottom: 2px;
}

.chat-msg-row.msg-self {
    align-self: flex-end;
}

.chat-msg-row.msg-other {
    align-self: flex-start;
}

.chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.msg-self .chat-msg-bubble {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.msg-other .chat-msg-bubble {
    background: rgba(243, 244, 246, 0.95);
    color: #1f2937;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    .msg-other .chat-msg-bubble {
        background: rgba(37, 41, 50, 0.95);
        color: #f3f4f6;
        border-color: rgba(255, 255, 255, 0.05);
    }
}

.chat-msg-meta {
    font-size: 0.72rem;
    color: #6b7280;
    margin-top: 4px;
    display: flex;
    gap: 6px;
}

.msg-self .chat-msg-meta {
    justify-content: flex-end;
}

@media (prefers-color-scheme: dark) {
    .chat-msg-meta {
        color: #9ca3af;
    }
}

/* Guest prompt state */
.chat-guest-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 16px;
    padding: 0 10px;
}

.chat-guest-text {
    font-size: 0.95rem;
    color: #4b5563;
    line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
    .chat-guest-text {
        color: #d1d5db;
    }
}

.chat-btn-primary {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: #ffffff;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
    text-decoration: none;
    display: inline-block;
}

.chat-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    color: #ffffff;
}

/* Chat Footer / Input area */
.chat-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
}

@media (prefers-color-scheme: dark) {
    .chat-footer {
        border-color: rgba(255, 255, 255, 0.08);
        background: rgba(0, 0, 0, 0.2);
    }
}

.chat-footer.chat-hidden {
    display: none;
}

#chat-message-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.9rem;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#chat-message-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

@media (prefers-color-scheme: dark) {
    #chat-message-input {
        border-color: rgba(255, 255, 255, 0.15);
        background: rgba(20, 24, 33, 0.9);
        color: #ffffff;
    }
    #chat-message-input:focus {
        border-color: #06b6d4;
        box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
    }
}

#chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #4f46e5;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

#chat-send-btn:hover {
    background: #4338ca;
    transform: scale(1.05);
}

/* Admin Dashboard Interface styling */
.admin-threads-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.admin-thread-item {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-thread-item:hover {
    background: rgba(79, 70, 229, 0.05);
    border-color: rgba(79, 70, 229, 0.15);
}

@media (prefers-color-scheme: dark) {
    .admin-thread-item {
        background: rgba(255, 255, 255, 0.03);
        border-color: rgba(255, 255, 255, 0.03);
    }
    .admin-thread-item:hover {
        background: rgba(6, 182, 212, 0.08);
        border-color: rgba(6, 182, 212, 0.15);
    }
}

.admin-thread-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
}

@media (prefers-color-scheme: dark) {
    .admin-thread-name {
        color: #f9fafb;
    }
}

.admin-thread-last {
    font-size: 0.85rem;
    color: #4b5563;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (prefers-color-scheme: dark) {
    .admin-thread-last {
        color: #9ca3af;
    }
}

.admin-thread-time {
    font-size: 0.72rem;
    color: #9ca3af;
    align-self: flex-end;
}

/* Chat back header for admin */
.chat-back-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    margin-bottom: 8px;
}

@media (prefers-color-scheme: dark) {
    .chat-back-bar {
        background: rgba(255, 255, 255, 0.03);
    }
}

#chat-back-btn {
    background: none;
    border: none;
    color: #4f46e5;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
}

@media (prefers-color-scheme: dark) {
    #chat-back-btn {
        color: #06b6d4;
    }
}

.chat-active-author {
    font-weight: 600;
    font-size: 0.88rem;
    color: #374151;
}

@media (prefers-color-scheme: dark) {
    .chat-active-author {
        color: #d1d5db;
    }
}

/* Tab styles */
.chat-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-tab-btn {
    flex: 1;
    padding: 12px 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    outline: none;
}

.chat-tab-btn:hover {
    color: #374151;
    background: rgba(0, 0, 0, 0.02);
}

.chat-tab-btn.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    font-weight: 600;
}

@media (prefers-color-scheme: dark) {
    .chat-tabs {
        background: rgba(20, 24, 33, 0.5);
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }
    .chat-tab-btn {
        color: #9ca3af;
    }
    .chat-tab-btn:hover {
        color: #f3f4f6;
        background: rgba(255, 255, 255, 0.02);
    }
    .chat-tab-btn.active {
        color: #06b6d4;
        border-bottom-color: #06b6d4;
    }
}

/* Chat Image Message */
.chat-msg-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    margin-top: 4px;
    transition: transform 0.2s;
    background: #eaeaea;
}

.chat-msg-image:hover {
    transform: scale(1.02);
}

@media (prefers-color-scheme: dark) {
    .chat-msg-image {
        background: #1f242d;
    }
}


