* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f5;
    height: 100vh;
    display: flex;
    color: #333;
}
.container {
    display: flex;
    width: 100%;
    height: 100%;
}
.sidebar {
    width: 260px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    padding: 16px;
}
/* Trainer page has two panels side-by-side on desktop */
#trainerSidebar {
    width: auto;
    min-width: 480px;
    flex-shrink: 0;
}
#trainerSidebar .trainer-sidebar-panel {
    flex-shrink: 0;
}
.sidebar h3 {
    font-size: 14px;
    color: #555;
    margin-bottom: 8px;
    font-weight: 600;
}
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}
.header {
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 14px;
}
.message.user {
    align-self: flex-end;
    background: #007bff;
    color: white;
}
.message.assistant {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e0e0e0;
    color: #333;
}
.message.has-comment {
    border-left: 3px solid #ffc107;
}
.input-area {
    padding: 16px 24px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
}
input[type="text"], textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}
input[type="text"]:focus, textarea:focus {
    border-color: #007bff;
}
button {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}
button:hover { background: #0056b3; }
button:disabled {
    background: #a0c4e8;
    cursor: not-allowed;
}
button.secondary {
    background: #6c757d;
}
button.secondary:hover { background: #545b62; }
.conversation-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 12px;
}
.conv-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.conv-item:hover { background: #f0f0f0; }
.conv-item.active { background: #e7f1ff; }
.conv-item button {
    padding: 2px 6px;
    font-size: 12px;
    background: transparent;
    color: #999;
    border: none;
    cursor: pointer;
}
.conv-item button:hover { color: #dc3545; background: transparent; }
.new-chat-btn {
    width: 100%;
    margin-bottom: 8px;
}
.username-section {
    margin-bottom: 16px;
}
.trainer-comment {
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 13px;
    color: #92400e;
}
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h3 { margin-bottom: 12px; }
.comment-list { margin: 12px 0; }
.comment-item {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13px;
}
.comment-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.hidden { display: none !important; }
.user-list-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.user-list-item:hover { background: #f0f0f0; }
.user-list-item.active { background: #e7f1ff; }
.badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #e0e0e0;
    color: #555;
}
.powered-by {
    font-size: 11px;
    font-weight: 500;
    color: #4f46e5;
    background: #eef2ff;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid #c7d2fe;
    white-space: nowrap;
}
.message .msg-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}
.comment-actions {
    display: flex;
    gap: 4px;
}
.comment-actions button {
    padding: 2px 6px;
    font-size: 11px;
}
.typing-indicator {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #aaa;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ===== Responsive / Mobile ===== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    color: #333;
}
.mobile-menu-btn:hover { background: #f0f0f0; border-radius: 6px; }
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 500;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    .sidebar, #trainerSidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 600;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    }
    .sidebar.mobile-open, #trainerSidebar.mobile-open {
        transform: translateX(0);
    }
    /* Trainer page: stack user list (top) and conversation list (bottom) on mobile */
    #trainerSidebar {
        width: 85vw;
        max-width: 320px;
        flex-direction: column !important;
    }
    #trainerSidebar .trainer-sidebar-panel {
        width: 100% !important;
        flex: 1;
        overflow-y: auto;
        border-right: none !important;
        border-bottom: 1px solid #e0e0e0;
    }
    #trainerSidebar .trainer-sidebar-panel:last-child {
        border-bottom: none;
    }
    .sidebar-backdrop.show {
        display: block;
    }
    .header {
        padding: 12px 16px;
    }
    .header h3 {
        font-size: 15px;
    }
    .chat-area {
        padding: 16px;
    }
    .message {
        max-width: 90%;
        font-size: 15px;
    }
    .input-area {
        padding: 12px 16px;
    }
    .powered-by {
        display: none;
    }
}
